asyncio client library for tcp modbus devices
Project description
tcp-modbus-aio
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 aumodbus.functions.ModbusFunction
to the modbus device and returns the correspondingModbusFunction
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 nextexpiry_period
seconds athz
frequency.memo_key
is used to allow multiple calls tolog_watch
without having overlapping log watch loops.await conn.close()
: for cleaning up the connection (kills TCP conn and ping loop)
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8961765dc68c3394051d0e20628fb93cec1544e1925feec1454f9a62e3d33356 |
|
MD5 | e5fdf675cf1866133088fb736a06e779 |
|
BLAKE2b-256 | 135b5a9aa957e733aea099151896d478c86a0b4d266e154a6b9184cfcca24260 |
File details
Details for the file tcp_modbus_aio-0.4.3-py3-none-any.whl
.
File metadata
- Download URL: tcp_modbus_aio-0.4.3-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9d7a618a554c90011cfaa027888af114ca5c579c218ece32530a0c49cdc1841 |
|
MD5 | 33e02646f495019edf3b88f907f7461d |
|
BLAKE2b-256 | 60f96896f46b99c7f7784785b50ab36dde4177fc1fd12da8bdcde7a8216993bf |