2007/11/9, Ed K <>:
> My solution (although it's not pretty) is that I now do this:
>
> #define LPGETSTATUS 0x060b (from ioctl.h I think)
>
> fd = open("/dev/usb/lp0", O_RDWR);
> ioctl(fd, LPGETSTATUS, &status);
>
> I check "status" to see if the printer is on-line. It seems to work.
> I don't know if it is a bad practice to be mucking about with ioctl
> from within a user-space program or not but it's the only thing I've
> found that will work for me.
No, that's fine. That is how you find out whether a printer is online
right now or not.
The only "cleaner" solution would be to use some printing library or
subsystem like cups but it's likely that most likely keep you so far
away from the printer that you;d end up with even less control. There
may be some library or part of some printing system you could rip out
if you want to hide that behind a nice function interface.
Actually, the grottiest thing your program is doing is to use
system(), which is more heavyweight and unreliable than necessary and
means you can't do anything about the printer running out of paper or
jamming during a print job.
M
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|