Connecting to Serial USB device via WebUSB

2019-07-25 07:28发布

问题:

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.



标签: webusb