Hi,
i have one COM port in RS485 mode with 2 devices on this port.
One is MODBUS with ID6 so the dataprocessor of the port is nrModbus1
For the other device with ID1 i have a different nrDataProcessor
How to manage the two different dataprocessors ?
Thank you,
Hello
You need to use ONE instance of nrModbus component. It allows to change ADDRESS for request different modbus slaves. You can read various modbus slaves, see following code:
nrModbus1.WriteRegister($1234, 11, 6); // write value 11 into REGISTER 0x1234 for modbus slave 6
nrModbus1.WriteRegister($1234, 11, 7); // write value 11 into REGISTER 0x1234 for modbus slave 7
Roman Novgorodov
Sorry for the misunderstanding !
It was my fault !
The second device is not modbus.
It is a device where i send an ASCII command and replies with ASCII line.
I have a nrDataProcessor for the second device and an nrModbus for the first.
Do i have to activate once the nrModbus and once the nrDataProcessor and vice versa
or
is there a way to have the two of them activated ?
Hello
It is not good idea to use one serial line with two devices with two different data transfer protocols.
Of course, You can try to use something like following:
nrComm1.DataProcessor := nrDataProcessor1;
nrDataProcessor1.DataProcessor := nrModbus1;
But there are no guaranties to correct work, it depends on data transfer logic.
Instead that you can switch between necessary protocols at runtime:
// switch to custom ASCII protocol
nrModbus1.Active := false;
nrComm1.DataProcessor := nrDataProcessor1;
nrDataProcessor1.Active : = true;
// switch back to modbus
nrDataProcessor1.Active : = false;
nrComm1.DataProcessor := nrModbus1;
nrModbus1.Active := true;
Roman Novgorodov
DeepSoftware llc