问题
I have hardware which is connected to the mac or windows via USB Serial Mode. Currently, I have a nodejs application which sends and receive messages to this hardware using "serial" node module. I am trying to connect to the hardware from WebPage. I used WebUSB serial.js. I am able to see the device and guess it is connecting. But when I try to send/receive the message - it says unable to claim the interface.
I would like to know can I use the WebUSB for USB with serial support?
回答1:
The claimInterface()
call is failing because your operating system has already loaded the USB serial class driver for this device (or perhaps a vendor-specific one such as FTDI). USB interfaces can only be claimed by one thing at a time. The option to change the device firmware so that the interface is no longer recognized by the driver (modify the interface class or product IDs) then you will be able to claim the interface and use code like the Arduino WebUSB library's serial.js that you found.
The other option is to wait for Chrome to finish implementing the Serial API. Status on that can be tracked here.
回答2:
What worked for me was to run sudo modprobe -r ftdi_sio
in the console.
That way, it unloads the USB from the OS and makes it available for WebUSB to use it and claim the interface.
来源:https://stackoverflow.com/questions/54430134/connecting-to-serial-usb-device-via-webusb