mbpoll
mbpoll copied to clipboard
Allow RTU also writing to address 0x00 (=broadcast address)
Some RTU devices need to get initialized to a certain address via the 0x00 broadcast address. But currently RTU_SLAVEADDR_MIN is defined as 1
If I change it to #define RTU_SLAVEADDR_MIN 0 I can write successfully to it and the device gets configured accordingly:
./mbpoll -a 0 -b 9600 -t 4 -r 0x4000 -0 /dev/ttyUSB3 2 -v
debug enabled
Set mode to RTU for serial port
Set device=/dev/ttyUSB3
1 write data have been found
Set data=2
Word[0]=0x2
mbpoll 1.4-17 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright © 2015-2019 Pascal JEAN, https://github.com/epsilonrt/mbpoll
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type 'mbpoll -w' for details.
Opening /dev/ttyUSB3 at 9600 bauds (E, 8, 1)
Set response timeout to 1 sec, 0 us
Protocol configuration: Modbus RTU
Slave configuration...: address = [0]
start reference = 16384, count = 1
Communication.........: /dev/ttyUSB3, 9600-8E1
t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table
[00][06][40][00][00][02][1C][1A]
Waiting for a confirmation...
<02><06><00><00><00><02><08><38>
Request for slave 2 ignored (not 0)
Message length not corresponding to the computed length (0 != 8)
Write output (holding) register failed: Invalid data
But the check does not match, as the device now responds with its new configured address (=0x02) (which is okay, imo) - afaik responses to broadcasts are not defined/supported.
Is there any specific reason why the RTU_SLAVEADDR_MIN=1 for RTU? Or is there a other way to send to the broadcast address?