Closed ekawahyu closed 6 years ago
Why do you have two different UNIT_TO_DATA
variables?
The Slave
doesn't send the Illegal Data Address
exception. You choose when it's sent in the requestHandler
.
You can specify custom unit along with other options when calling a request function, for example:
master.readHoldingRegisters(0, 1, {unit: 1});
Because they are on two separate computers, 0x01 in one desktop and another as 0x02. The third computer is the master. They all are on a wired RS485 network. I am guessing 0x01 and 0x02 in the UNIT_TO_DATA
object is the slave ID, right?
Ok, got it, thanks!
I have some questions about connecting more than one slave devices to a master. Modbus protocol is RTU, so I have physical (and virtual) RS485 network for this. I took the example and modified the UNIT_TO_DATA object for slave ID=1 as this:
And slave ID=2 like this:
They both work just fine, but when the modbus request is sent to slave ID=1, slave ID=2 gets
Illegal Data Address
exception. And vice versa. In my opinion, any message comes with mismatched slave ID, it should just drop it and do not send any exception.Another question, for master device, how to send a modbus request and pass the unit ID as parameter, so that it does not pick up the
defaultUnit
?