Proprietary USB device access via browser… possibl

2020-06-20 19:13发布

问题:

Probably there are a lot of similar questions around, but since I know only few solutions to this which I am not sure will work for us, I am looking for something else, maybe new technologies...

What we have is this USB device which is not so fancy (of course, it requires a driver to be loaded), and it has couple of C++ dlls to help getting certain output from it. On top, we made a C# desktop application which makes use of the device in a more attractive way (plenty of interop inside).

So far so good, but to have the application lifted up to the web in order to gain more flexibility... What options are there?

Known solutions are:

  • 1) ActiveX - kinda old technology and not cross-browser;
  • 2) .Net 'applet' - not so common (is this even a solution?)
  • 3) Java applet - well known, but JVM needed (since we went for C++ C# maybe is out of scope);
  • 4) Web service on the usb device itself - our device is very light, we cannot have it there.

Are there other ways? Is Silverlight 4, 5 (maybe "out of browser") a feasable solution? What about these new technologies nowadays? Html 5 or something?

EDIT1: In particular I am interested in Silverlight. Is there a way using Silverlight?

EDIT2: I found this question: Can Silverlight access a .Net library that accesses a USB port? . What shall I understand from that? Is really Silverlight not a feasable solution for my scenario?

EDIT 3: VERY IMPORTANT!

These devices need to be used on customer side! People browsing must use them locally on their PCs!

Thanks in advance.

回答1:

to have the application lifted up to the web [...]

Simple solution: Let the webserver (http server) run on the PC connected to the USB device, and use one of the webserver's interfaces like CGI to talk to your USB device. This way you need to code only a USB-to-CGI wrapper program, which can be C++ or C#.



回答2:

Another way is to write a browser plugin.

The issue that you're going to face is that content in a browser is often run in a sandbox, in such a way that the web app does not have access to the computer. There are good reasons for this - security, primarily. One way to have some code running in the context of the computer is to have a browser plugin that can access the computer's hardware resources, but that can interact with browser content. Unfortunately, you may end up writing a different plugin for different browsers.

There do exist frameworks out there that make writing browser plugins more manageable. A simple search should turn up some of those candidates.



回答3:

You can use Silverlight 5, it can give you access to your file system and USB storage device. If you want to get control for other USB device (printer, scanner, etc), you should give a device type. I know, Silverlight 5 works fine with a file system and web-cams...)