A Python3 MODBUS TCP server for testing purposes
Project description
modbus-tcp-server
A thread-based MODBUS TCP server for testing purposes.
Installation
Just type
pip install modbus-tcp-server
And to run it
modbus-tcp-server 127.0.0.1
Just run it without any arguments to see the command line.
Limitations
It does only the commands related to reading and writing analog inputs, discrete inputs, holding registers and coils, so only commands 1-6 and 15-16 are supported.
Also, it spawns a thread per a client. This might be unacceptable to you, however it can also with with gevent.
Custom data provider
To implement a custom data provider, just extend BaseDataSource to provide data of your choosing and launch it that way:
from modbus_tcp_server.network import ModbusTCPServer
from modbus_tcp_server.data_source import BaseDataSource
class CustomDB(BaseDataSource):
...
c_db = CustomDB()
at = ModbusTCPServer('0.0.0.0', 502, c_db).start()
Note that since everything is handled in a single thread, if your reads or writes take too long this will hang on them. File a Issue if you've got a problem with that.
Change log
v0.3
- added
CustomMODBUSError
- renamed
AcceptThread
toModbusTCPServer
v0.2
- added support for commands 15 and 16
- added exceptions
GatewayPathUnavailable
andGatewayTargetDeviceFailedToRespond
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for modbus_tcp_server-0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e93255b8f56b835dbffc3c298d55f410dd499f58f5748e8a3f7a5cea60bfd831 |
|
MD5 | a82a050ffa07193a4add66ee7258673d |
|
BLAKE2b-256 | 2237fcbe0f011cb4fde01dbdc4ef60b73c21af1f4772081d721c2a8e466556d6 |