0

I'm trying to connect a USB Thermal Printer to my Android Tablet (Samsung Galaxy Tab S4, Android 9) via WEBUSB but I'm getting this error when trying to claim the interface: "Failed to claim interface 0: Device or resource busy (16)"

I'm posting the code but I don't think the issue is here since it works fine on Windows 10(after changing the default driver to WinUSB using Zadig):

this.printerProvider = navigator['usb'];
        this.printerProvider.requestDevice({filters: []})
            .then(selectedDevice => {
                this.device = selectedDevice;
                return this.device.open();
            })
            .then(() => {
                return this.device.selectConfiguration(1);
            })
            .then(() => {
                return this.device.claimInterface(this.device.configuration.interfaces[0].interfaceNumber);
            })
            .then(() => {
                for (let ep of this.device.configuration.interfaces[0].alternate.endpoints) {
                    if (ep.direction == 'out') {
                        this.endpoint = ep;
                        console.log('USB PRINTER CONNECTED')
                    }
                }
            })
            .catch((err) => {
                console.log(err);
            })

and in fact I got the same result using the nice tool provided in this article: https://labs.mwrinfosecurity.com/blog/webusb/ this tool basically tries to claim all the interfaces.

So, my guess is that Android itself has claimed the interface. I've also tried to enable the developer options to see if there was something useful there but I didn't find anything.

Any help is very appreciated.

Mat

  • What is the interface class for the interface you are trying to claim? You say you had to change the default driver on Windows 10, what driver was Windows loading instead? – Reilly Grant Jul 30 '19 at 19:41
  • Hi, thanks for answering, this is what I get from chrome://usb-internals: Configuration 1 -- Interface 0 ---- Alternate 0 ------ Class Code 7 ------ Subclass Code 1 ------ Protocol Code 2 ------ Endpoint 1 (IN) ------ Endpoint 3 (OUT) --------Usb Transfer type:BULK --------Packet Size: 64 ``` Honestly I don't remember the default driver that windows was loading. – Magnetizzato Aug 01 '19 at 11:39

2 Answers2

0

what does lsusb -v say, when the printer is plugged in? ls /sys/bus/usb/devices also should list the actual configuration. maybe try to set the USB port mode to "charging only" (because then there shouldn't be any specific kernel driver loaded)... or try the demo.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
0

The interface descriptor shows that this is a USB Printer Class device (protocol 2 indicates bi-directional). To my knowledge Android does not ship with a driver for this USB interface class built into the kernel. What may be happening is that there is another application on the device (such as a printer service) that has claimed this interface. Check the "Printing" section in system settings and see whether you have anything installed.

Reilly Grant
  • 5,590
  • 1
  • 13
  • 23