Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Modbus2Websocket (further, M2W) is an python-based application that routes data between Modbus TCP protocol and Websockets.
The main goal of M2W router is to deliver data between industrial system and web application. Modbus TCP - industrial protocol, used to exchange information between industrial devices and HMIs. Usually, to visualize data engineers have to use heavy and expensive SCADA or HMI. On other hand web technologies provide easy and powerful tools for data visualization in your own web browser, without any thick client. That is why M2W was created in first place - to make simple webHMI server that works with Industrial systems.
async_modbus_server.py
async_modbus_client.py
async_websocket_server.py
router.py
Modbus2websocket library installs with pip:
pip install modbus2websocket
Before creating you application you have to specify following:
If you don't have running Modbus/TCP server, you can use server simulator.
Class Router will manage data between Modbus/TCP and websockets client, that runs in your browser
from modbus2websocket.router import Router
Router has two public methods:
Router.add_modbus_reg()
- that adds registers you want to readRouter.run()
- that runs router.You should add registers that you want to read, as a list of dictionaries. Structure of single registers looks like that:
Input_register_1 = {'ir':
{
'adr': 0,
'num': 1,
'name': 'Input Register 1',
},
},
Where:
ir
- registers type. (see Modbus details).adr
- regsiter's address. It starts from 0 to 65535.num
- number of registers to read. It is limited between 1 to 2000.name
- unique name for your register.from modbus2websocket.router import Router
if __name__ == '__main__':
ws_ip = '192.168.220.10' # websocket ip address
ws_port = 8888 # websocket port
modbus_ip = '192.168.220.5' # Modbus ip address
router = Router(ws_ip, ws_port, modbus_ip)
# Modbus registers to read
regs = [
{'ir':
{
'adr': 0,
'num': 1,
'name': 'Reg1',
},
},
{'hr':
{
'adr': 1,
'num': 1,
'name': 'Reg2',
},
},
{'ir':
{
'adr': 2,
'num': 1,
'name': 'Reg3',
},
},
]
router.add_modbus_reg(regs)
router.run()
Registers type | Short name | Description |
---|---|---|
Digital Input | DI | Read only, bool, 1-bit |
Input Register | IR | Read only, float/int, 16-bit |
Coil | C | Read/write, bool, 1-bit |
Holding register | HR | Read/write, float/int, 16-bit |
FAQs
Modbus/TCP to websocket router.
We found that modbus2websocket demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.