I have python3 program that acts as a Modbus Master. I start a ModbusSerialClient and then proceed to read register from the slave. This is working fine on Windows. The issue is that on Ubuntu I am seeing that the ModbusSerialClient keeps changing the baudrate which makes the communication inconsistent.
I start the communication with:
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
...
try:
self.client = ModbusClient(
method = 'rtu'
,port= self.port
,baudrate=int(115200)
,parity = 'N'
,stopbits=1
,bytesize=8
,timeout=3
,RetryOnEmpty = True
,RetryOnInvalid = True
)
self.connection = self.client.connect()
# Some delay may be necessary between connect and first transmission
time.sleep(2)
Where self.port = "COM_X"
in Windows and self.port = "/dev/ttyS1"
in Linux
And then I read the registers using:
rr = self.client.read_holding_registers(register_addr,register_block,unit=MODBUS_CONFIG_ID)
if(rr.isError()):
logger.debug(rr)
else:
# Proceed with the processing
The error I log in some ocasions is:
Modbus Error: [Input/Output] Modbus Error: [Invalid Message] No response received, expected at least 2 bytes (0 received)
I have verified the baudrate change physically measuring the signals.
I have verified that with a command line tools like cu
the baudrate remains consistent.
The verions I am using are:
3.1.0
(error also present with 2.5.3
)3.5
3.8.10
22.04
(same behaviour with ubuntu)The issue was confirmed to be caused by spike in the CPU caused by the dead SSD.