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.4

  • added automatic connection termination after 60 seconds of inactivity
  • better error detection on connections
  • bugfix: fixed CustomMODBUSError

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.4.tar.gz (9.2 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.4-py3.8.egg (9.5 kB view details)

Uploaded Egg

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

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: modbus-tcp-server-0.4.tar.gz
  • Upload date:
  • Size: 9.2 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.4.tar.gz
Algorithm Hash digest
SHA256 6eaf8546ce8e5147e5250fc9ba72847a80906ceebba943b993d448232363cdce
MD5 9f8d78c249488b2623fc762cec169408
BLAKE2b-256 1c32bbd4ef9e454f546498216a0d17bd9c0fbd409b0b34d15b6decfa2a17949d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: modbus_tcp_server-0.4-py3.8.egg
  • Upload date:
  • Size: 9.5 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.4-py3.8.egg
Algorithm Hash digest
SHA256 be79e361ec43568e5021704368bfe299b5fe74e276f5760c1905d2deefaa8729
MD5 2ca0ae45585e6be291f59691ff8b423b
BLAKE2b-256 f0a3cb4ff8ee7e0009eadc53d5ca3355f532a29a247842fff5844449a9b70b69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: modbus_tcp_server-0.4-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.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d70b00d9675c72383b56019cf69a3103f2bcbbafc61d6b15afd64fb615cf9110
MD5 2d3f64157058df9db164465aa4acd62c
BLAKE2b-256 f58dceeb694aa95fc254c4045fc3b4ce51c45469c2209a997c290e7e50c055fc

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