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 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 to ModbusTCPServer

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.3.tar.gz (9.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

modbus_tcp_server-0.3-py3.8.egg (9.4 kB view details)

Uploaded Egg

modbus_tcp_server-0.3-py2.py3-none-any.whl (11.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file modbus-tcp-server-0.3.tar.gz.

File metadata

  • Download URL: modbus-tcp-server-0.3.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for modbus-tcp-server-0.3.tar.gz
Algorithm Hash digest
SHA256 07bf13fc4aa00ce8f0f72caf195d7a32e4e98971fc42d7a67ded49e7d330a676
MD5 2d8e4779da375b69264284762d81681d
BLAKE2b-256 cc8c3838a7e1518df072574d0946ceb654355419c2ad315f7a180918c3872e39

See more details on using hashes here.

File details

Details for the file modbus_tcp_server-0.3-py3.8.egg.

File metadata

  • Download URL: modbus_tcp_server-0.3-py3.8.egg
  • Upload date:
  • Size: 9.4 kB
  • Tags: Egg
  • Uploaded using 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

File hashes

Hashes for modbus_tcp_server-0.3-py3.8.egg
Algorithm Hash digest
SHA256 cb58735e8186c64be9c980b6e448b885f7c69667eeb7c41fa64104cd79a23e62
MD5 7ab159c22e2d1cb70a9e89233f77caa2
BLAKE2b-256 0488b4dcef7c83523515521490cdc4d2d3abfdf662abbc73120948b9e5668d52

See more details on using hashes here.

File details

Details for the file modbus_tcp_server-0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: modbus_tcp_server-0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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

File hashes

Hashes for modbus_tcp_server-0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e93255b8f56b835dbffc3c298d55f410dd499f58f5748e8a3f7a5cea60bfd831
MD5 a82a050ffa07193a4add66ee7258673d
BLAKE2b-256 2237fcbe0f011cb4fde01dbdc4ef60b73c21af1f4772081d721c2a8e466556d6

See more details on using hashes here.

Supported by

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