OpenPrinting / cups

OpenPrinting CUPS Sources
https://openprinting.github.io/cups
Apache License 2.0
967 stars 177 forks source link

@wawaclem Is there a way to map the printer on CUPS with its serial number? #885

Closed childish-gambino closed 3 months ago

childish-gambino commented 5 months ago

I have a use case where I would like to map the "discovered serial numbers" for the connected printers (via USB) with the printer/queue created on CUPS.

This is important, especially in cases where I have more than 1 printer of the same model from an OEM and I would like to identify (map) the physical printer with the printer on cups.

I tried looking at the printer.conf and can see some basic printer details but the serial number is not one of them. (at least in the case of the printer that I am using i.e DCP-T420W).

After exploring a bit, I deduced that it was probably a design choice to not identify a printer on cups with the serial number, but Michael's response on one of the older issues seems to suggest otherwise (?!)

          @wawaclem We are already reading the serial number from the device if there is no serial number in the IEEE 1284 device ID string. Can you run the following command and report what you get back?
lpinfo -l -v

Thanks!

Originally posted by @michaelrsweet in https://github.com/OpenPrinting/cups/issues/170#issuecomment-820697020

I tried lpinfo -l -v in my setup but did not see any serial number. Is there a way to map the printer on cups with the discovered serial number?

Rhanks ! -v

michaelrsweet commented 5 months ago

What is the output of lpinfo -l -v on your system? Can you attach/post the output?

Normally you will see URIs of the form "usb://MAKE/MODEL?serial=SERIAL" (with percent-encoding of spaces, etc.)

(non-USB printers do not report a serial number because it is unnecessary - the USB serial number is used to disambiguate between two or more printers with the same make/model)

childish-gambino commented 5 months ago

The model that I am working with gets detected as a Network (Class) printer even when connected via USB. Here's the output for lpinfo -l -v

Device: uri = ipp://Brother%20DCP-T420W%20(USB)._ipp._tcp.local/
        class = network
        info = Unknown (driverless)
        make-and-model = Unknown
        device-id =
        location =
michaelrsweet commented 5 months ago

That is probably for IPP-USB - the USB backend is only used for legacy USB printing.

childish-gambino commented 5 months ago

Understood. Thanks for clarification.

I have a followup question though. Is there any other way to automatically discover and map the serial numbers with printer/queue on CUPS? I have a use case where I can have multiple printers of same model placed next to each other, connect via USB on a singe device (laptop) and I want to be able to identify and tell apart each one of them from CUPS.

CUPS does identify each printer config separately (UUID and unique connection URLs) but there's no way for me to know for sure which printer config on CUPS (virtual printer) belongs to which printer on the remote site (physical printer).

michaelrsweet commented 5 months ago

For an IPP printer, the Identify-Printer operation allows you to visually or audibly identify a particular printer. You can also query the printer attributes - some report their serial number in the printer-device-id and/or printer-serial-number attributes.

michaelrsweet commented 3 months ago

Closing as there isn't anything actionable here...