Skip to content

Possible to add multiple blocks of holding registers? #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
githubadminGTI opened this issue Oct 17, 2022 · 0 comments
Closed

Possible to add multiple blocks of holding registers? #101

githubadminGTI opened this issue Oct 17, 2022 · 0 comments
Labels
conclusion: duplicate Has already been submitted

Comments

@githubadminGTI
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: duplicate Has already been submitted
Projects
None yet
Development

No branches or pull requests

2 participants