简体   繁体   English

如何从客户端的串行端口(RS-232)获取数据

[英]how to get the data from serial port (RS-232) on client side

My project i'm doing now is getting the weigh from the scale that use RS-232 port and post it into the website then press submit and the data will be saved into the server. 我现在正在执行的项目是从使用RS-232端口的秤上获取重量,并将其发布到网站上,然后按Submit(提交),数据将保存到服务器中。 I also study how to get the value from these port using the java API called javax.comm. 我还研究了如何使用名为javax.comm的Java API从这些端口获取值。 However, I think it just work on the server, and could be work for one computer. 但是,我认为它只能在服务器上运行,并且可以在一台计算机上运行。 that's the problem. 那就是问题所在。 therefore, I want to make a website that the client computer can access to the website and weigh the scale then save it into the server. 因此,我想创建一个网站,供客户端计算机访问该网站并对其进行称重,然后将其保存到服务器中。 So, how can we do it? 那么,我们该怎么做呢? Does javascript work on it? javascript可以处理吗?

thanks :) 谢谢 :)

Of course you amy do this with a browser plugin, but that will make the application browser specific. 当然,您可以使用浏览器插件来完成此操作,但这将使应用程序特定于浏览器。 Instead what you may do it to create a simple desktop agent (windows service, taskbar app) that will be installed on the client machine itself. 相反,您可以执行以下操作来创建将安装在客户端计算机本身上的简单桌面代理(Windows服务,任务栏应用)。

Now this agent should respond to HTTP requests from your web page that are directed to http://[localhost]:[port]. 现在,该代理应响应您网页中指向http:// [localhost]:[port]的HTTP请求。 This might need to embed a simple HTTP server inside the agent. 这可能需要在代理中嵌入一个简单的HTTP服务器。 The other complexity you will have to handle is on Cross Origin Requests. 您将要处理的其他复杂性是在跨源请求上。 You may either use JSONp OR CORS in handling that. 您可以使用JSONp或CORS来处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM