Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

linux backend usb libusb fails to detect Canon MP110 - get_device_id empty #3799

Closed

Description

@michaelrsweet

Version: 1.4-current
CUPS.org User: markh

Linux, kernel 2.6.35 without usblp module, cups compiled with libusb support.
Connected a Canon MP110 printer via USB, lsusb -vv output for this device attached as canon-lsusb.txt

Summary: printer not found by cups using libusb, but is found on system using cups with usblp.

Executing the usb backend fails to list the Canon MP110 printer connected to this system, other printers like an HP F2280, Epson SX215 are found by both backend and webinterface. On an older system with cups 1.3 without the libusb backend (using usblp kernel module) the Canon printer is found and is working.

While debugging backend/usb-libusb.c I found the following:
In function find_device() it fails in the call get_device_id().
usb_control_msg() in this function returns an empty string, causing the function to return -1.

With this info I've added some debug prints to the linux kernel's usblp module (drivers/usb/class/usblp.c), function usblp_get_id, which is a macro around usblp_ctrl_msg() and noticed that usblp uses a different value for the index parameter for usb_control_msg(), namely 256 where cups uses 1.

Cups uses for index = printer->iface
usblp module uses the following in case of a GET_ID request which is what we are doing:
/* High byte has the interface index.
Low byte has the alternate setting.
*/
if ((request == USBLP_REQ_GET_ID) && (type == USB_TYPE_CLASS)) {
index = (usblp->ifnum<<8)|usblp->protocol[usblp->current_protocol].alt_setting; }

Resulting in the value 256 for index for this Canon MP110 printer (for an HP F2280 printer, usblp also uses 256).

As a test I modified backend/usb-libusb.c to also leftshift the printer->iface by 8, and sure enough the backend now finds the Canon:

direct usb://Canon/MP110?serial=65D6te&interface=1 "Canon MP110" "Canon MP110" "MFG:Canon;CMD:BJL,HAPS,BSCCe;MDL:MP110;CLS:PRINTER;DES:Canon MP110;VER:1.58;STA:10;" ""

Im not sure how to find the lowbyte for this index properly like usblp does inside usb-libusb.c (maybe printer->altset??)

However with this change the webinterface still does not find the printer so most likely some more changes are needed.

I hope this provides enough info to fix this usb-libusb issue in Cups, if not I'm happy to provide more information.

Regards,
Mark

Activity

  1. michaelrsweet commented on Feb 22, 2011

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    P3, not P5.

    Thanks for the investigation, will see if I can come up with a suitable patch...

  2. michaelrsweet commented on Feb 23, 2011

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: markh

    Today I had a chance to test another printer, Epson Stylus Photo R360

    Apart from the fact that initially the libusb backend also fails to find this printer (see STR #3801), the change I did to make the Canon work and keeps my HP working, breaks it for Epson. Using index 256 in libusb seems to write interface 0 (deducted this from a kernel msg reporting that the cups usb backend used interface 0 without claiming it), so it looks to me that the kernel version of usb_control_msg behaves differently from libusb's version?

    For all 3 printers: 'printer->iface << 8 | printer->iface' for index seems to work in usb-libusb.c. I'm no expert in (lib)usb, but maybe this update provides the experts with some more information.

    usblp works for this Epson Stylus Photo R360 and usblp does use value 256 for index.

  3. michaelrsweet commented on Mar 4, 2011

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    Fixed in Subversion repository.

  4. michaelrsweet commented on Mar 4, 2011

    @michaelrsweet
    ContributorAuthor

    "str3799.patch":

    Index: backend/usb-libusb.c

    --- backend/usb-libusb.c (revision 9570)
    +++ backend/usb-libusb.c (working copy)
    @@ -411,7 +411,7 @@

    if (usb_control_msg(printer->handle,
    USB_TYPE_CLASS | USB_ENDPOINT_IN | USB_RECIP_INTERFACE,

    •         0, printer->conf, printer->iface,
      
    •         0, printer->conf, (printer->iface << 8) | printer->altset,
            buffer, bufsize, 5000) < 0)
      
      {
      *buffer = '\0';
      @@ -675,6 +675,7 @@
      goto error;
      }

    +#if 0 /* STR #3801: Claiming interface 0 causes problems with some printers */
    if (number != 0)
    while (usb_claim_interface(printer->handle, 0) < 0)
    {
    @@ -685,6 +686,7 @@

       goto error;
     }
    

    +#endif /* 0 */

    /*

    • Set alternate setting...
  5. added this to the Stable milestone on Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions