Why does Pymodbus change baudrate when running on linux without requesting a baudrate change?

Question:

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:

  • pymodbus 3.1.0 (error also present with 2.5.3)
  • pyserial 3.5
  • python 3.8.10
  • kubuntu 22.04 (same behaviour with ubuntu)
Asked By: Ricard Molins

||

Answers:

The issue was confirmed to be caused by spike in the CPU caused by the dead SSD.

Answered By: Ricard Molins
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.