pixma: Fix device enumeration for open devices
If sane_get_devices is called while a device is already open,
read_serial_number tries to open the usb device to read it, but fails
(possibly because it's already open), so the returned device ends up
lacking a serial. For example pixma:04A91913_401D8C
gets returned as
pixma:04a91913
.
This in turn might promp frontend applications to close existing connection and open a new one to new device, which now fails, because once the device is closed enumeration returns full name again.
EDIT: The implementation touches so many files, because only USB devices have a serial computed this way, and there is no (apparent) way to detect a USB device from just the name. BJNP devices have name pattern MODEL_SERIAL
, but I'm unsure what the model looks like. Maybe a simpler string manipulation might work (like search for _
and take what's before it), but I preferred to err on the side of correctness than simplicity.
EDIT 2: I changed the implementation to a simple substring.