Skip to main content

pyModbusTCP

A simple Modbus/TCP client library for Python.

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

pyModbusTCP is pure Python code without any extension or external module dependency.

Test

The module is currently test on Python 2.6, 2.7, 3.2, 3.3, 3.4 and 3.5.

Status:

https://api.travis-ci.org/sourceperl/pyModbusTCP.svg?branch=master https://readthedocs.org/projects/pymodbustcp/badge/?version=latest

Setup

You can install this package from:

PyPI, the easy way:

sudo pip install pyModbusTCP

GitHub:

git clone https://github.com/sourceperl/pyModbusTCP.git
cd pyModbusTCP
sudo python setup.py install

Install the current devel-release:

sudo pip install git+https://github.com/sourceperl/pyModbusTCP.git@devel

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, 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)

module init (with accessor functions)

c = ModbusClient()
c.host("localhost")
c.port(502)
# managing TCP sessions with call to c.open()/c.close()
c.open()

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")

Documentation

Documentation available online at http://pymodbustcp.readthedocs.io/.

Metadata

Release files for pyModbusTCP 0.1.8

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.1.8
File Size Uploaded Provenance Actions
pyModbusTCP-0.1.8.tar.gz 15.3 kB Without provenance Details for pyModbusTCP-0.1.8.tar.gz

Release files / pyModbusTCP-0.1.8.tar.gz

Download URL pyModbusTCP-0.1.8.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
61721105608bd533a703c15f62e431426f986398e2fdbe7f9729ddc58678a90b
BLAKE2b-256 checksum
How to use checksums
862fdba4265b4072116350051f76fc57fe22b1fb24ee253ba581cd18f35038e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.9.1 pkginfo/1.4.1 requests/2.12.4 setuptools/33.1.1 requests-toolbelt/0.8.0 tqdm/4.17.1 CPython/2.7.13

Security for pyModbusTCP 0.1.8

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