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.2.7.tar.gz
(9.5 kB
view hashes)
Built Distribution
Close
Hashes for tcp_modbus_aio-0.2.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26f0313403047ce5057d0748f4a2e895366659f37ec671ad1f960f3f1aaf95bc |
|
MD5 | f3572ae1abb21cd9f72134933f9b8c81 |
|
BLAKE2b-256 | 200f705a6f34892d998eeb65cf1111c55866802ad27ccb2eff30bce80344d82e |