-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Hi,
I needed single threaded, non-blocking and fast serial RTU Modbus client for embedded Linux controllers. Because I have used Pymodbus and Tornado non-blocking IOLoop before, I decided to make my work based on them.
Pymodbus has already async client implemented with Twisted but it didn't look a good idea to run Twisted on top of Tornado or Tornado on top of Twisted (it should be possible). It is not very well documented either and based on code I can't see how it can be run in non-blocking without additional threads or processes. At least all existing serial I/O is blocking.
Anyway, here is the module right now including example code in the comments:
https://github.com/droid4control/pymodbus_async
At 19200 I can make 67 register read requests in second (with patch from #74).
This code includes a lot of debugging witch can be removed. It also needs unit tests and maybe some more documentation. The module works in Python3 only right now. Back porting to Python2 should be possible.
I use FifoTransactionManager but it is not possible to queue multiple requests right now. New request can be sent only after previous one is finished (by calling callback function). I do not need such queueing right now but this would be nice feature to add.
I would like to merge it with Pymodbus but client/async is already taken by Twisted example. Maybe we can rename it so that two different async implementations can co-exist?
PS! Suggestions for the licence are also welcome. I mostly write code under GPL but Tornado is licensed under Apache License and Pymodbus is released under the BSD License. I'm not very familiar with differences between them.
Enjoy!