[cups] programmatically detect network printer power state

Boncek, John jboncek at hunter.com
Thu Jun 2 06:41:36 PDT 2016


Thanks for the clarification.  We got it working.

Regards.

-----Original Message-----
From: cups-bounces at cups.org [mailto:cups-bounces at cups.org] On Behalf Of Johannes Meixner
Sent: Thursday, June 02, 2016 2:47 AM
To: The CUPS user discussion list.
Subject: Re: [cups] programmatically detect network printer power state


Hello,

On Jun 1 19:07 Brian Potkin wrote (excerpt):
> On Thu 26 May 2016 at 18:56:00 +0000, Boncek, John wrote:
>
>> With CUPS 1.7.2 under Ubuntu 14.04, I am able to programmatically add
>> a network printer (an HP Officejet Pro 6230) at a socket IP address
>> and port combination, make it the default printer, and send jobs to
>> it.  Now I want to programmatically detect whether the printer is on
>> or off, but I haven't been able to find a way to do that.  Regardless
>
> For a printer directly connected to the network you could probe for its
> IP address with nmap or ping.
>
>> of whether the printer is on or off, CUPS seems to always report that
>> the printer is Idle, Accepting Jobs, etc.  How can I detect the power
>> state (if there is a way)?
>
> I think CUPS reports the state of the print queue.

"printer" =~ "printer device" != "print queue" =~ "printer"

Cf. "CUPS: The server between user and printer" at
https://en.opensuse.org/Concepts_printing

To avoid possile misunderstandings that might lead to
possibly endless talking at cross purposes I recommend
to keep printers (i.e. printer devices) and print queues
strictly separated and accordingly I recommend to use
unambiguous wording to keep "printer devices" obviously
separated from "print queues".

"Whether the printer is on or off" talks about the state
of the printer device.

In contrast
"CUPS seems to always report that the printer is Idle"
talks about the state of the print queue.

Therefore:
"to programmatically detect whether the printer is on or off"
you need a program that talks to the printer device.

In general to get the state of a network printer device
you can usually use SNMP.

It depends what exactly "on or off" means.

When a printer device is only switched to an "off" state
but still connected to its power supply and still
connected to the computer, the device may nevertheless
respond in some basic way via its computer connection
e.g. USB device detection may still work or a
network printer may still respond to some network I/O.

When you have a program that detects the state for your
particular network printer device as you need it in
your particular case, you can integrate that into the
CUPS printing framework so that in the end when CUPS
reports the print queue state that report also contains
some information about the printer device state.

In the CUPS printing framework the so called "backend"
is the program that communicates with the printer device
so that you would need to integrate your program into a
CUPS backend (e.g. enhance the CUPS "socket" backend)
or make your own CUPS backend that implements all what
you need it in your particular case for your particular
network printer device.

For some basic information about how one could
"Using Your Own Backends to Print with CUPS" see
https://en.opensuse.org/SDB:Using_Your_Own_Backends_to_Print_with_CUPS


Kind Regards
Johannes Meixner
-- 
SUSE LINUX GmbH - GF: Felix Imendoerffer, Jane Smithard,
Graham Norton - HRB 21284 (AG Nuernberg)

_______________________________________________
cups mailing list
cups at cups.org
https://www.cups.org/mailman/listinfo/cups



More information about the cups mailing list