pymodbus-dev / pymodbus

A full modbus protocol written in python
Other
2.22k stars 907 forks source link

Question: Multiple modbus clients with different modbus speed #1919

Closed stanceli closed 8 months ago

stanceli commented 8 months ago

Versions

Pymodbus Specific

Description

Is it allowed to use multiple clients with different modbus speed?

I have a setup of peripherals with different serial line speed (9600 and 115200). When I'm using mbpoll client to check registers state it work flawlessly with different speed.

However if I would create 2 modbus serial clients and will try to read registers states of those devices some strange things happens - big communication delay (like it's retrying on empty or something similar) and error finally occurs which breaks the usage of peripherals.

Code and Logs

from pymodbus.client import ModbusSerialClient

serial_port = '/dev/ttyRS485'

client_1 = ModbusSerialClient(port=serial_port, baudrate=115200, timeout=1, retries=1, retry_on_empty=True)
client_2 = ModbusSerialClient(port=serial_port, baudrate=9600, timeout=1, retries=1, retry_on_empty=True)

client_1.write_register(register=0, value=1, slave=10)
client_2.write_register(register=0, value=1, slave=11)
janiversen commented 8 months ago

one rs485 line can pr definition only have one speed. Pymodbus allows X clients with different speeds and e.g framers, however it must be on different serial/usb connection.

This is not a modbus restriction but a general serial line restriction.....allowing multi0le speeds/parameters on one serial line, will confuse the devices.

stanceli commented 8 months ago

@janiversen thank you for the reply. I thought at first about line restriction but In my case the line is used sequentially. I was confused a bit by using mbpoll - it did work without any issue despite the speed value, that's why I thought that will be okay. Maybe it did trigger something low level before send/recv.

Anyway, thank you for the note.