带有 RS-232 串行端口的 Javascript 接口
我目前正在从事一个涉及 4 端口 A/V 交换机的项目。 该开关可通过 RS-232 进行控制。
与交换机连接的计算机运行 Vista。 我想创建一个侧边栏小工具,它有 4 个按钮 - 交换机上的每个端口 1 个。 当用户按下按钮时,它会切换到该端口。
我做了一些谷歌搜索,似乎没有很好的方法来连接 javascript 和 rs-232。
有人对我有什么建议吗?
谢谢!
I am currently working on a project that involves a 4 Port A/V switch. This switch can be controlled via RS-232.
The computer that will interface with the switch runs Vista. I would like to create a sidebar gadget that has 4 buttons- 1 for each port on the switch. When the user presses the button, it switches to that port.
I have done a bit of googling, and it seems that there isn't a very good way to interface between javascript and rs-232.
Does anyone have any suggestions for me?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
你喜欢复杂的黑客吗?
安装网络服务器。 使用 CGI、Python、PHP、Perl 或其他方法从 Web 服务器上的页面控制串行端口。
将控件指向网页。
Do you like convoluted hacks?
Install a webserver. Use CGI, Python, PHP, Perl, or some other method to control the serial port from a page on the webserver.
Point the control at the webpage.
我认为您需要在两者之间添加 Java 或 Active-X 层。 JavaScript 与操作系统很好地隔离(故意)。
I think you'll need to add a Java or Active-X layer in between. JavaScript is pretty well isolated (deliberately) from the OS.
特别是 Javascript,或者只是通过某种方法从浏览器中获取? 哪个浏览器? (IE 或 Firefox?)使用 XUL + javascript 的 Firefox 插件非常简单,尽管您仍然需要在 XPCOM(Mozilla 的 ActiveX/COM 等效项)中实现某些功能才能使用 RS232。
或者,您可以使用 JSDB 作为临时 Web 服务器(在本地计算机的备用端口上)。 在 JSDB 中使用 RS232 端口非常简单:
因此您的浏览器端实现可以是您最喜欢的书签/链接/东西,链接到
http://localhost:9999/comport/1
其中9999是JSDB正在监听的端口#,“1”是串口开关。 JSDB 代码将侦听端口并在解析来自浏览器的 GET 请求后发送适当的 RS232 命令。Javascript in particular, or just from the browser with some method? And which browser? (IE or Firefox?) Firefox plugins using XUL + javascript are pretty easy, although you'd still have to implement something in XPCOM (the Mozilla equivalent of ActiveX/COM) to work the RS232.
Alternatively you could use JSDB as an impromptu web server (on an alternate port of the local machine). It's ridiculously easy to use the RS232 port in JSDB:
So your browser-side implementation could just be whatever your favorite bookmark/link/thingy is that links to
http://localhost:9999/comport/1
where 9999 is the port # JSDB is listening to, and "1" is the serial port switch. The JSDB code would listen to the port and send the appropriate RS232 command after parsing a GET request from the browser.RealTerm 具有广泛的 COM 接口,并且可以轻松地在 Windows 上通过 JavaScript 进行控制。 SourceForge 下载页面 的版本为 2.0.0.57,并且 i2cchip.com
有版本2.0.0.70。
默认安装的“examples”子目录中有一个 JavaScript 示例。
遗憾的是,JavaScript 示例似乎已从更高版本中删除4仍然可以做到,但没有例子。
RealTerm has an extensive COM interface and is easy to control from JavaScript on windows. The SourceForge downloads page has version 2.0.0.57, and i2cchip.com
has a version 2.0.0.70.
There is a JavaScript example in the "examples" subdirectory which is installed by default.
Sadly, the JavaScript examples appear to have been removed from later versions4 It may still be possible to do it, but there are no examples.
我没有解决方案,但这可能是一个开始。
现在,如果您在自己的计算机上运行 javascript,则可以使用 HTA 获得完全访问权限到系统。
I don't have a solution, but here could be a start of one.
Now if you're running the javascript from your own machine you could use HTA to have full access to the system.
您可以尝试查看 V8 之类的东西,并为 C 库编写一个小包装器以暴露给 VM。
You could try looking at something like V8 and writing a small wrapper for the C library to expose to the VM.
您需要在系统上安装一个 RS-232 ActiveX 组件,然后在侧边栏小部件的 javascript 代码中创建一个对象。 请注意,没有从 ActiveX 组件创建对象的标准,这仅在 JScript 中可用,JScript 是 Microsoft 对我们都称为 Javascript 的语言的实现。
You need a RS-232 ActiveX component that you install on the system and then create an object from in the javascript code in your sidebar widget. Note that there is no standard to create objects from ActiveX components, this is only available in JScript, Microsoft's implementation of the language we all know as Javascript.
我很抱歉在我自己的问题下发帖 - 我没有注册,所以现在我无法编辑它。
我想为该任务实现一个 Vista 侧边栏小工具。 不幸的是,看起来这些基本上只是带有 javascript 的 html 文档,所以看起来这对我来说不是一个好的解决方案。 我可能只会写一些 .Net 应用程序或其他东西。
不过还是感谢您的所有意见。 如果有人还有想法,我会采纳。
I'm sorry to be posting under my own question- I hadn't registered, so now I cannot edit it.
I wanted to implement a Vista Sidebar Gadget for the task. unfortunately it looks like those are just basically html documents with javascript, so it doesn't look like that is going to be a good solution for me. I'll probably just write a little .Net application or something.
Thank you for all of your input though. If any one still has ideas, I'll take them.
AFAIK,Vista 小工具的运行时支持使用签名的 ActiveX 控件。 您也许还可以使用 Java。 您可以创建一个 .Net 的 ActiveX 包装器,它对串行设备有相当多的支持。 大多数情况下,ActiveX + 串行通信仅限于商业控件。
AFAIK, Vista gadget's runtime supports the use of signed ActiveX controls. You may also be able to use Java. You can create an ActiveX wrapper to .Net which has a fair amount of support for serial devices. For the most part ActiveX + Serial communications is limited to commercial controls.