问题
I have a simple little dongle I want to debug by sending/receiving basic USB messages. It enumerates as an HID device (like an additional mouse), but am worried that I won't have access to it. I forgot the hardware and can't test with it for a couple days.
Is it a futile effort to continue building a chrome extension to test it?
Chrome App, USB documentation: https://developer.chrome.com/apps/app_usb Getting-started example: https://github.com/GoogleChrome/chrome-app-samples/tree/master/usb/knob
回答1:
Google Chrome now proposes a USB HID API. Have a look at the API: https://developer.chrome.com/apps/hid
The API is still defined as experimental at the time of this message. But it is functional. I have just written a tutorial to explain how to use this API.
Have a look: http://www.appnearme.com/blog/2014/7/21/chrome-usb-hid-controlling-your-usb-device-javascr/
回答2:
You can't build a Chrome Extension to use that API, only Apps are allowed access.
That said, the JS side of things will probably not be the hard part, the example you linked provides an ample starting point. But I can't quickly find a ready library to do so, so prepare for relatively low-level hardware stuff.
Edit: Seems like there will be an API for that: https://code.google.com/p/chromium/issues/detail?id=290428
来源:https://stackoverflow.com/questions/23037402/can-i-access-usb-hid-device-via-a-chrome-app