1

USB is a packet protocol: it buffers bytes, then sends a packet. This is causing me a problem because the software I am using (pymodbus) sees an incomplete Modbus Packet in a complete USB packet, and reports a short-packet error ("No Response received from the remote unit/Unable to decode response")

With some devices I can mitigate against this problem by adjusting the USB packet latency to minimum. Other devices/drivers/systems don't offer this adjustment.

Is there a setting in pymodbus (ModbusSerialClient) that allows me to tell it to relax RTU inter-character timeout (which is meaningless in this case), or otherwise allow for USB devices?

david
  • 2,435
  • 1
  • 21
  • 33
  • Can you explain your setup a bit more? How are you adjusting the packet latency and on what devices? How many devices have you tried? It seems to me this might be a driver or hardware problem, do you have further proof that the problem is coming from the USB latency (other than the problem going away when you adjust it)? – Marcos G. Dec 14 '22 at 18:42
  • USB latency /is/ a hardware or driver problem. – david Dec 14 '22 at 21:25
  • Indeed, in general, I would rather deal with those issues instead but I agree it is nice to have good old hacks in your toolbox, thanks. – Marcos G. Dec 15 '22 at 08:38

1 Answers1

2

ModbusSerialClient takes a parameter 'strict' with default value True, which controls strict RTU timing. For relaxed RTU timing, set strict=False.

try:
  from pymodbus.client.sync import ModbusSerialClient as ModbusClient
except:
  from pymodbus.client import ModbusSerialClient as ModbusClient

client = ModbusClient(port='com3',strict=False)

answer = client.read_holding_registers(0XB2,2,unit=8).registers
david
  • 2,435
  • 1
  • 21
  • 33