Is there a way to communicate with USB devices from browser?

前端 未结 6 1980
孤独总比滥情好
孤独总比滥情好 2021-02-14 23:45

Is there a way to communicate with USB devices within regular browser (FF, Safari, IE8, etc)? I assume it could be Javascript -> Java bridge or something else.

Please a

相关标签:
6条回答
  • 2021-02-15 00:01

    Electron can also be put to a good use here, since its build on node, it can access HID devices. There's also a nice node plugin to access HID devices.

    0 讨论(0)
  • 2021-02-15 00:05

    If your CC and barcode scanners work as HID devices (basically, keyboard emulation), yes you can, and I have seen it done. If they're more complicated than that, it depends, the system is going to require drivers for the device and it is then OS dependant. But, for example, there are smartcard readers that will hook the card into the system's certificate framework for authentication.

    You're not going to be able to use a chipped credit card with that sort of reader, however, since the protocol for those requires bidirectional communication with the card. I think there may be a way to talk to a proper point of sale CC terminal over USB, but that will most likely require drivers.

    0 讨论(0)
  • 2021-02-15 00:08

    There are two choices

    1. Use a browser plugin runtime like (Silverlight or Flash) that talks to Windows HID.

    or 2. Use a local HTTP server and have JQuery post backs to the local HTTP Server which inturns talks to HID.

    0 讨论(0)
  • 2021-02-15 00:18

    Google chrome offers a javascript USB device interface but this is chrome specific.

    https://developer.chrome.com/apps/usb

    Not sure what you would do on other browsers.

    0 讨论(0)
  • 2021-02-15 00:23

    With Silverlight 4 (beta) there are ways do things like that, but only for trusted applications and maybe not the way you hope...

    It provides a API for COM Automation. That means you need a drive that exposes some COM interop for you or you have to write something to control the USB-Port/Device yourself.

    this article seems to be a good sample:

    http://sblakemore.com/blog/post/Silverlight-4-COM-Automation-e28093-Taking-photos-with-a-DSLR-using-Windows-Image-Acquisition.aspx

    0 讨论(0)
  • 2021-02-15 00:25

    Why would the point of browser based sofware be useless?

    Browser -> USB seems like a huge security flaw.

    I don't let the browser talk to my hard drive, why should it talk to my flash drive?

    I don't let my browser talk to my built in webcam; why should it take to my usb webcam?

    0 讨论(0)
提交回复
热议问题