0

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]);   
}
zombi
  • 1
  • You are the one defining each server on a different port, you should be able to keep track of them. Why are you fixing `z=0`? If you do that you'll be working always over the same server. – Marcos G. Jun 14 '20 at 10:17
  • @MarcosG. I put z=0 because not have information about server index (0 or 1). I have only start address and quantity. – zombi Jun 14 '20 at 11:00
  • Then I guess you should ask whomever is in charge of those servers – Marcos G. Jun 14 '20 at 11:02

0 Answers0