Skip to main content

pyModbusTCP badge_tests badge_docs

A simple Modbus/TCP client library for Python. pyModbusTCP is pure Python code without any extension or external module dependency.

Since version 0.1.0, a server is also available for test purpose only (don’t use in project).

Tests

The module is currently test on Python 3.7, 3.8, 3.9, 3.10 and 3.11.

For Linux, Mac OS and Windows.

Documentation

Documentation of the last release is available online at https://pymodbustcp.readthedocs.io/.

Setup

You can install this package from:

PyPI, the easy way:

# install the last available release (stable)
sudo pip install pyModbusTCP
# install a specific version (here release v0.1.10)
sudo pip install pyModbusTCP==v0.1.10

From GitHub:

# install a specific version (here release v0.1.10) directly from github servers
sudo pip install git+https://github.com/sourceperl/pyModbusTCP.git@v0.1.10

Note on the use of versions:

Over time, some things can change. So, it’s a good practice that you always use a specific version of a package for your project, instead of just relying on the default behavior. Without precision, the installation tools will always install the latest version available for a package, this may have some drawbacks. For example, in pyModbusTCP, the TCP automatic open mode will be active by default from version 0.2.0. It is not the case with previous versions and it just doesn’t exist before the 0.0.12. This can lead to some strange behaviour of your application if you are not aware of the change. Look at CHANGES for details on versions available.

Usage example

See examples/ for full scripts.

include (for all samples)

from pyModbusTCP.client import ModbusClient

module init (TCP always open)

# TCP auto connect on first modbus request
c = ModbusClient(host="localhost", port=502, unit_id=1, auto_open=True)

module init (TCP open/close for each request)

# TCP auto connect on modbus request, close after it
c = ModbusClient(host="127.0.0.1", auto_open=True, auto_close=True)

Read 2x 16 bits registers at modbus address 0 :

regs = c.read_holding_registers(0, 2)

if regs:
    print(regs)
else:
    print("read error")

Write value 44 and 55 to registers at modbus address 10 :

if c.write_multiple_registers(10, [44,55]):
    print("write ok")
else:
    print("write error")

Metadata

Release files for pyModbusTCP 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyModbusTCP 0.2.1
File Size Uploaded Provenance Actions
pyModbusTCP-0.2.1.tar.gz 27.1 kB Without provenance Details for pyModbusTCP-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyModbusTCP 0.2.1
File Interpreter ABI Platform Actions
pyModbusTCP-0.2.1-py3-none-any.whl Python 3 none any Details for pyModbusTCP-0.2.1-py3-none-any.whl

Total release size: 52.0 kB

Release files / pyModbusTCP-0.2.1.tar.gz

Download URL pyModbusTCP-0.2.1.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8a086c5799ee29f47e42e24326bae4cd259ba56c5aeebe04ce00bc29ec7fcbfc
BLAKE2b-256 checksum
How to use checksums
e6a60c27322f0329644352d54687bb4679adbff3bc15d975c75a9a3c453055b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

Release files / pyModbusTCP-0.2.1-py3-none-any.whl

Download URL pyModbusTCP-0.2.1-py3-none-any.whl
Size 24.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42775ff4b29f2c0675f91a430825e7c78783bbb0729c7761370e6af8445339fc
BLAKE2b-256 checksum
How to use checksums
47788ae3867450c471fcd8ffd629be93e40db569324a3e8ea30d2452c4eefc0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

Security for pyModbusTCP 0.2.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page