Modbus TCP communication from HTML/Javascript Webpage

爷,独闯天下 提交于 2019-11-29 21:23:28

问题


I have a device that uses Modbus TCP. I want to read data from it and display it on a webpage (Without an in between server).

I have found a project that does almost this exact same thing as a Chrome extension:

https://github.com/Cloud-Automation/chrome-modbus

It uses this in the javascript code: chrome.sockets.tcp

I was hoping that I could do the same thing on my webpage using WebSockets.

It seems that websockets would work on my webpage (acting as the client), sending and receiving information from the device (acting as the server). It doesn't seem that websockets is affected by cors.

Does anybody have pointers on where I could start on this? (Or a javascript library would be great)

Is this possible?


回答1:


Without an in between server will not be possible, unless your plc supports other protocol different than modbus (e.g. post/get).

If your plc is "completely closed" and you only have this port/protocol open, then you need an in between server that makes the conversion of modbus tcp to html. Using node-red as well as the dashboard and modbus flows, you can achieve it.

If you solved it other way, I would like to know how you did it.




回答2:


I did get this solved without a server in between. I did it using Chrome Sockets link I also made it work using a cordova app for smart phones. Firefox has a sockets api as well, but did not attempt to figure it out for that browser.




回答3:


I solve this using the PLC Connect in vb, i used vb to pass data in database and get the data through javascript.



来源:https://stackoverflow.com/questions/33527392/modbus-tcp-communication-from-html-javascript-webpage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!