Skip to main content

A Python3 MODBUS TCP server for testing purposes

Project description

modbus-tcp-server

PyPI PyPI version PyPI Wheel

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 AcceptThread
from modbus_tcp_server.data_source import BaseDataSource

class CustomDB(BaseDataSource):
    ...

c_db = CustomDB()

at = AcceptThread('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.2

  • added support for commands 15 and 16
  • added exceptions GatewayPathUnavailable and GatewayTargetDeviceFailedToRespond

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

modbus-tcp-server-0.2.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distributions

modbus_tcp_server-0.2-py3.8.egg (9.2 kB view hashes)

Uploaded Source

modbus_tcp_server-0.2-py2.py3-none-any.whl (10.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page