[cups.general] How to access a printer via its DEVICE_URI?

Michael R Sweet msweet at apple.com
Thu Apr 17 12:40:53 PDT 2008


Justin Huang wrote:
>> Justin Huang wrote:
>>> I am trying to develop an application for monitoring a specific printer. The printer could be USB connected. Currently, I can enumerate the drivers by using IPP APIs or CUPS APIs. I also know how to get the DEVICE URI string for a certain driver. The DEVICE URI may look like this:
>>>   usb://manufacturer_name/model_name
>>>
>>> I am looking for a method to convert this string into another string which represents the physical device, e.g. "/dev/usb/lp01". With the physical device string, I can "open" it and then do bi-directional communication with the printer directly.
>> The backend code does this already, but keep in mind that USB support
>> is highly OS/distro-specific - sometimes it will map to a character
>> device you can read/write, but often you will need to do a lot more
>> work.
>>
>>> Am I doing my job in the correct direction?
>> You would probably be better off running the backend and communicating
>> via pipes - file descriptor 0 of the backend should be the incoming
>> side of a pipe to send data to the device, file descriptors 1, 2, and
>> 4 should go to /dev/null, and file descriptor 3 should be the outgoing
>> side of a pipe to receive data from the device.
>>
> 
> I can let my raster filter receive data from a network connected printer (port 9100) by calling cupsBackChannelRead(). I believe I can do it again for a USB printer. But if I do so, the end-user can monitor the printer only when he or she is making print. What about the other time? A standalone status monitor in Windows is common. Is it rare in CUPS world?

That is what command filters are for along with the cached printer
attributes (marker-*, printer-state-reasons, etc.) which can convey
most kinds of status information to a utility or the standard user
programs.

-- 
______________________________________________________________________
Michael R Sweet                        Senior Printing System Engineer





More information about the cups mailing list