Hello,
$ sysctl kern.version
kern.version=OpenBSD 5.4-current (GENERIC.MP) #222: Fri Dec 27 22:33:50 MST 2013
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
I just got this USB printer and I'm trying to write some
code to directly "control" it. It attaches as ulpt, which is
good.
Baby steps for me: write a very basic C program that
opens the appropriate /dev/ulpt* device, and write the
initialize command for this printer. Things Look OK.
Next write Status Information Request command sequence.
write(2) succeeds. I try to read(2) the response back, but
it fails with ENODEV (Operation not supported). The status
is actually printed in /var/log/messages.
Looking at sys/dev/usb/ultp.c, i see this done in
ulpt_statusmsg() which is called in ulpt_do_write().
Now here, I need an expert's help. I must be looking at
this upside down or sideways, because I don't see where
ulpt_do_write() is called, well, it is called from ulptwrite()
(ulpt.c), but I can't find who, or where it gets called from.
Need a pointer here please.
$ pwd
/usr/src/sys/dev/usb
$ grep -r ulptwrite ../..
../../dev/usb/ulpt.c: DPRINTF(("ulptwrite\n"));
../../dev/usb/ulpt.c: DPRINTFN(1, ("ulptwrite: transfer %d
bytes\n", n));
../../dev/usb/ulpt.c: DPRINTF(("ulptwrite: error=%d\n", err));
../../dev/usb/ulpt.c:ulptwrite(dev_t dev, struct uio *uio, int flags)
$ grep -r ulpt_do_write ../..
../../dev/usb/ulpt.c:int ulpt_do_write(struct ulpt_softc *, struct uio
*uio, int);
../../dev/usb/ulpt.c:ulpt_do_write(struct ulpt_softc *sc, struct uio
*uio, int flags)
../../dev/usb/ulpt.c: error = ulpt_do_write(sc, uio, flags);
As for the ENODEV on read(2), I guess I misunderstood
what is meant by "bi-directional":
Jan 15 20:55:28 puter /bsd: ulpt0: using bi-directional mode
bi-directional does not mean *I* get to read and write to
this device.
Setting that aside, it doesn't look like I can use ulpt device
to write a dedicated "driver" for this printer. Is this correct?
Do I need to "fudge" the kernel to not attach this device to
ulpt but instead as ugen? Is there a better way? I rather not
diverge from GENERIC.
Requesting any and all advice.
--patrick
p.s., if this belongs to misc@ I'll happily move it there.