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 502
Port is optional, it will be assumed to be 502 by default.
Just run it without any arguments to see the command line.
If you want verbosity, you can drop -v or -vv after providing port number.
Note that in this case giving port number is mandatory.
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.
Client connections will be closed after 60 seconds of inactivity.
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.6
- made logging received data log level debug
- socket will be opened with SO_REUSEADDR
v0.4
- added automatic connection termination after 60 seconds of inactivity
- better error detection on connections
- bugfix: fixed CustomMODBUSError
v0.3
- added
CustomMODBUSError - renamed
AcceptThreadtoModbusTCPServer
v0.2
- added support for commands 15 and 16
- added exceptions
GatewayPathUnavailableandGatewayTargetDeviceFailedToRespond
Metadata
Release files for modbus-tcp-server 0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| modbus-tcp-server-0.6.tar.gz | 9.7 kB | Without provenance | Details for modbus-tcp-server-0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| modbus_tcp_server-0.6-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for modbus_tcp_server-0.6-py2.py3-none-any.whl |
Total release size: 21.1 kB
Release files / modbus-tcp-server-0.6.tar.gz
| Download URL | modbus-tcp-server-0.6.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af6c8ae51b7b9a7272cf760cf15636898645c696cf20cf66e2dd8a2a397e61be
|
|
BLAKE2b-256 checksum How to use checksums |
91eb0f231a18791b3c3d74938c5197ff43d214252aeb7d5f575b5df565aa303c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.0
|
Release files / modbus_tcp_server-0.6-py2.py3-none-any.whl
| Download URL | modbus_tcp_server-0.6-py2.py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
9af1354c2ae5279cb734c0f1ef77de2df53e8e7358516d38ff5b8e827fd40a8d
|
|
BLAKE2b-256 checksum How to use checksums |
4731ab59eb3d9a9a33f42091c8ad738a5bb3ea5fb032fb2ce6ae45ea310cdaa2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.0
|
Security for modbus-tcp-server 0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.