For a project I have 4 modbus devices connected on a RS485 serial line. The devices are working fine and now that I'm writing a controller I'm quite unhappy with the performance of pymodbus
.
I found this thread Python modbus library and it seems to me that there may be better python modbus libraries out there. pymodbus
is easy to use and I'd rather like to continue using it if possible.
However I've found out that the time any read/write routine takes to return is equal to the timeout. This doesn't seem right to me so I wrote a quick test:
from pymodbus.client.sync import ModbusSerialClient
import time
for t in xrange(1, 11):
client = ModbusSerialClient("rtu", port="/dev/ttyUSB0", baudrate=9600, timeout=t)
start = time.time()
data = client.read_holding_registers(0x9000, count=7, unit=2)
stop = time.time()
if data:
succ = "was successful"
else:
succ = "failed"
print "timeout: %ss, read %s, time spent reading: %fs" % (t, succ, stop-start)
and this is the output I got
timeout: 1s, read was successful, time spent reading: 1.039731s
timeout: 2s, read was successful, time spent reading: 2.038965s
timeout: 3s, read was successful, time spent reading: 3.041441s
timeout: 4s, read was successful, time spent reading: 4.040762s
timeout: 5s, read was successful, time spent reading: 5.043523s
timeout: 6s, read was successful, time spent reading: 6.040139s
timeout: 7s, read was successful, time spent reading: 7.042159s
timeout: 8s, read was successful, time spent reading: 8.045216s
timeout: 9s, read was successful, time spent reading: 9.047682s
timeout: 10s, read was successful, time spent reading: 10.048799s
I've tested it with different RS845<->USB converters and I always get similar results.
Can anyboby else confirm this? Or am I missing some not-documented argument there that would increase ModbusSerialClient
's performance?