Skip to main content

asyncio client library for tcp modbus devices

Project description

tcp-modbus-aio

PyPI version

asyncio client library for tcp modbus devices. built on top of umodbus but extended for more industrial robustness and asyncio compat. the umodbus documentation is recommended reading to have any hope of using this code.

narrowly constructed for the use cases of Tutor Intelligence, but feel free to post an issue or PR if relevant to you.

usage

create a TCPModbusClient. once you have it, you can call the following methods on it:

  • await conn.send_modbus_message(request_function, **kwargs): sends a umodbus.functions.ModbusFunction to the modbus device and returns the corresponding ModbusFunction reply.
  • await conn.test_connection(): sends a modbus message to the device to ensure it's still operational (currently hardcoded to read coil 0) and return boolean of whether it succeeded. is implemented as a cached awaitable to allow you to spam this call.
  • await conn.clear_tcp_connection(): kill the current TCP socket (a new one will automatically be created for the next request)
  • await conn.log_watch(msg, memo_key="system_temperature", expiry_period_s=10, hz=1): spins up a background coroutine to log the result of that message for the next expiry_period seconds at hz frequency. memo_key is used to allow multiple calls to log_watch without having overlapping log watch loops.
  • await conn.close(): for cleaning up the connection (kills TCP conn and ping loop)

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

tcp_modbus_aio-0.4.3.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

tcp_modbus_aio-0.4.3-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file tcp_modbus_aio-0.4.3.tar.gz.

File metadata

  • Download URL: tcp_modbus_aio-0.4.3.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for tcp_modbus_aio-0.4.3.tar.gz
Algorithm Hash digest
SHA256 8961765dc68c3394051d0e20628fb93cec1544e1925feec1454f9a62e3d33356
MD5 e5fdf675cf1866133088fb736a06e779
BLAKE2b-256 135b5a9aa957e733aea099151896d478c86a0b4d266e154a6b9184cfcca24260

See more details on using hashes here.

File details

Details for the file tcp_modbus_aio-0.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for tcp_modbus_aio-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f9d7a618a554c90011cfaa027888af114ca5c579c218ece32530a0c49cdc1841
MD5 33e02646f495019edf3b88f907f7461d
BLAKE2b-256 60f96896f46b99c7f7784785b50ab36dde4177fc1fd12da8bdcde7a8216993bf

See more details on using hashes here.

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