Possible to add multiple blocks of holding registers?
githubadminGTI opened this issue · 0 comments
githubadminGTI commented
Hi,
I'm trying to have an Arduino Uno serve as a Modbus RTU server to simulate a device I need for work. I'd like to setup multiple holding register blocks but so far I'm not having any luck as I get the "illegal data address" error.
What I mean is that if I would like to read from holding registers 6, 254, 867, and 1023 then I can't get it to work just by running
//Configure 1024 registers
result = ModbusRTUServer.configureHoldingRegisters(0, 1023) ;
if(result != 0)
{
Serial.println("Holding registers configured incorrectly!");
}
//initialize the 1024 registers with the number of the register
for(int i = 0; i < 1024; i++)
{
result = result = ModbusRTUServer.holdingRegisterWrite(i, (uint16_t) i);
if(result != 1)
{
Serial.println("Failed to write to the holding registers!");
break;
}
}
What would be the correct way to go about doing this?
Thank you!