Power switch on USB printer

Phil Endecott spam_from_cups_forum at chezphil.org
Sun Jul 16 08:15:16 PDT 2006


Dear All,

My printer's power comes from a switch which I can turn on and off under software control.  I'd like to arrange for it to be turned on when a print job is ready, and off after a couple of minutes of idleness.

Google has found this page:

    http://funderburgs.net/linux/x10printer/

where someone is doing something similar.  He has a backend script (at http://funderburgs.net/linux/x10printer/x10) which sends the command to turn on the printer, maybe waits for a few seconds, and then sends the print job.  "at" is used to turn the printer off.  I'm hoping that I can adapt / improve this to do what I want.

The first issue is that mine is a USB printer.  One question is, should I be doing all this at the USB level (hotplug?) rather than in CUPS?  But putting that aside, is there a way that I can avoid a hardcoded wait for the printer to be available after turning it on?  Clearly the OS knows when the printer is ready.  Maybe I need to wait until /dev/usblp0 or whatever it is called is created.  Or maybe it's OK to cat the data without waiting for it to be ready.  Any ideas?

Secondly, I'm a bit concerned that the printer could be turned off too soon: presumably the "cat" command in that script will terminate with some data still in buffers, either in the OS or in the printer itself.  If the last page takes a long time to print it may be turned off prematurely.  So, is there a better way to wait until the printer is idle?  (Does the lpq status change from "printing" to "ready" as soon as all the data has been sent and the backend script terminates, or does it actually know that the printer is now idle?)

Finally, is this backend script called at all when the printer is switched off?  I know that at present I have to use "cupsenable" after turning on the power before anything will happen.

Any suggestions would be much appreciated.

Cheers,  Phil.





More information about the cups mailing list