[cups.development] How to get printer status via CUPS API?

Jerome Alet alet at librelogiciel.com
Tue Jun 17 06:04:00 PDT 2008


On Tue, Jun 17, 2008 at 05:46:41AM -0700, Toni Heimala wrote:
> How can I get the current printer status through the CUPS API?
> 
> What I would like to achieve is to get printer status messages like "Out 
> of paper", "Paper jam", etc.
> 
> I have tried calling the cupsLastErrorString() function for example but 
> it only returns "successfull-ok" after I've sent a file for printing via 
> the cupsPrintFile() function. Even though the printer is actually in out 
> of paper state.

The easiesy way for this is to use the snmpget command line tool
from net-snmp, and retrieve the 'hrPrinterDetectedErrorState' value :

  snmpget -v 1 -c public 192.168.12.34 1.3.6.1.2.1.25.3.5.1.2.1
  
(where 192.168.12.34 is your printer's IP address)

This will return either an empty string, or two bytes string
containing an error mask with the informations you want, as
described in RFC3805.

Other SNMP values might also be of interest, like hrDeviceStatus and
hrPrinterStatus, look at the RFC for details.

hth        

Jerome Alet





More information about the cups mailing list