Skip to content

Possible to add multiple blocks of holding registers? #102

@nikstp

Description

@nikstp

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 = 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?

I know this was just opened and closed, but I've used a wrong account for that (#101).

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions