I want to write a c# application using EasyModbusTCP lib. My target is to have multiple modbus server on same pc using different tcp port( ex. 3001 for mbServer[0] and 3002 for mbServer[1]).
I want to use the code posted by @Alex (Issue while writing ModbusClient and ModbusServer together) but I have a problem to identify witch server is allocated the Ser_HoldingRegistersChanged method.
When change the holding registers the function Ser_HoldingRegistersChanged is started but not how know witch server called this function.
With code I read back the holding register value only for one server.
You have a solution for me to send on runtime the z indentifier? Thanks to all.
public static void holdingRegistersChanged(int startingAddress, int quantity)
{
Console.WriteLine(startingAddress);
Console.WriteLine(quantity);
int z=0;
Console.WriteLine(mbServer[z].holdingRegisters[startingAddress]);
}