编写使用JavaScript,HTML5,或任何跨平台语言数据保存到USB HID(支持安卓)语言、数据、平台、JavaScript

2023-09-05 09:38:58 作者:久伴会让你知道每一颗心

我已经写在HTML5和JavaScript的用户界面。我选择了这个实施,这样我既能Android的浏览器和Windows 8之间共享相同的code RT。

I've written an UI in HTML5 and JavaScript. I chose this implementation so that I could share the same code between both Android Chrome and Windows 8 RT.

现在,我的下一个目标是将数据写入到一个USB HID。我正在与被视为一个HID通讯的设备。我提到这部分的情况下,有一种方法来写一个HID设备,而不是一个USB RAW设备。

Now, my next objective is to write data to a USB HID. The device that I'm communicating with is treated as an HID. I'm mentioning this part in case there's a way to write to an HID device rather than a USB RAW device.

我已经对此事进行了大量的研究工作。但是,HTML5的规范是如此频繁,也许我错过了什么变化。

I've done a lot of research on the matter. But, the HTML5 specs are changing so often that maybe I missed something.

反正,可有人提出一个语言或实现,我可以用它来分享共同code访问USB设备上的Andr​​oid和Windows 8 RT?如果没有办法了两下,怎么样一个建议,得到的只有在Android?USB通信之间共享

下面是我的研究与结论:

Below is my research along with conclusions:

Silverlight的:不支持。在Web插件方面,不支持Windows 8 RT或Android

Silverlight: UNSUPPORTED. In terms of web plugin, not supported on Windows 8 RT or Android

闪光:可能的选项。支持两种操作系统,虽然他们删除支持与Android的果冻豆

Flash: Possible option. Supported in both operating systems, although they removed support for Android with release of Jelly Bean

HTML5:不支持

看着游戏手柄API,但它似乎只支持从手柄阅读 在看着设备的标签,但标签不再在当前的草案存在。我读了导航器对象替换它在Javascript中,但似乎完全不同。此外,设备只针对获得的视频和音频

JavaScript的:不支持。从我的理解,这是因为它会带来安全隐患。

JavaScript: UNSUPPORTED. From my understanding, this is because it'd be a security risk.

镀铬封装应用:不支持。不确定有关支持在Windows 8 RT。但是,它不支持机器人铬,或者

Chrome Packaged App: UNSUPPORTED. Unsure about support in Windows 8 RT. But, it is not supported in Android Chrome, either.

系统 USB API 存在的完成正是我需要的,但API只提供给打包应用程序 A USB API exists that accomplishes exactly what I need, but the API is only available to a packaged app

Java小程序:不支持。不确定有关支持在Windows 8 RT。但是,它不支持机器人铬,或者

Java Applet: UNSUPPORTED. Unsure about support in Windows 8 RT. But, it is not supported in Android Chrome, either.

在许多方面可以如何与USB设备进行通信的资源。然而,由于Java小程序不支持在智能手机上,这最终是不支持的。

几个有用的帖子

how发送和接收在asp.net数据串口或USB口? Is从Web应用程序的跨浏览器的跨OS可能在所有访问USB? Is这可能提供的JavaScript API来控制USB,LPT,COM设备? how to send and receive data to serial port or USB port in asp.net? Is Accessing USB from web application for cross browser cross os possible at all? Is that possible to provide javascript API to control USB, LPT, COM devices?

推荐答案

其实我已经想好怎么做的事情与此类似....

I've actually thought about how to do things similar to this....

下面的是一种方式,肯定的方式来做到这一点,如果你有以上的已连接的USB设备的计算机控制:

Here's is one way sure way to do it if you have control over the computer which has the usb device attached:

在计算机与USB设备运行一个Web服务器,如阿帕奇/ PHP的。拥有它只能听本地主机。

Have the computer with the USB device run a web server such as apache/php. Have it only listen to localhost.

然后在HTML页面被查看,执行一个ajax后到localhost / somescript.php(或CGI或CFM或其他)。

Then in the html page being viewed, execute an ajax post to localhost/somescript.php (or cgi or cfm or whatever).

在PHP / CGI脚本传送给USB设备,然后返回一个JSON字符串到浏览器说着什么事情发生了。

In php/cgi script communicate to the USB device and then return a json string to the browser saying something happened.

更新:

另一种方法是使用自定义URL协议。您创建一个可执行文件,并在客户端计算机上的安装,它与您的自定义URL协议。

Another approach is to use Custom URL Protocols. You create an executable and "install" it on the client computer along with your custom url protocol.

然后就可以使用您的自定义URL协议调用从浏览器中的可执行文件。

Then you can invoke the executable from the browser using your custom url protocol.