arduino-libraries / ArduinoModbus

250 stars 117 forks source link

Modbus TCP server polling a client with fixed slave ID? #54

Open jairuz opened 3 years ago

jairuz commented 3 years ago

I have a PLC with fixed ID that my Modbus TCP server using MKR1010 is trying to poll. How will I assign the slave ID into the server for communication?

pykoon commented 3 years ago

Did you check id param of begin function ?

int ModbusTCPServer::begin(int id)
{
  modbus_t* mb = modbus_new_tcp(NULL, IPAddress(0, 0, 0, 0), 0);

  if (!ModbusServer::begin(mb, id)) {
    return 0;
  }