Modbus-Master-Slave-for-Arduino Library

Hello everyone,

I am arduino newbie and could not find the answer for my question. For my projcet I use Modbus-Master-Slave-for-Arduino library. I set my arduino uno as a slave. I made a connection with openhab using tutorial and everything works. But I can not understand how uint16_t au16data[16]; works. How are the Coil, Discrete input, Input register and Holding register are assigned to the array. Is there any pattern I can use to understand that? How will object types be distributed in array if I for example create uint16_t au16data[11];

Thank you!

How are the Coil, Discrete input, Input register and Holding register are assigned to the array.

You need to look elsewhere in the code to determine that. That is nothing more than an array declaration.

How will object types be distributed in array if I for example create

Declaring an array is like saying "I have a box". How puppies will arrange themselves in the box will have nothing to do with the fact that it is your box.

Thank you! I had the declaration of the object types in the array indeed, it just wasnt so obvious for me as a newbie:

void io_poll() {
  //Copy Coil[1] to Discrete[0]
  au16data[0] = au16data[1];
  //Save button state in register 0.3
  bitWrite( au16data[0], 3, digitalRead( btnPin ));
  //Copy Holding[5,6,7] to Input[2,3,4]
  au16data[2] = au16data[5];
  au16data[3] = au16data[6];
  au16data[4] = au16data[7];
  //Debug information save
  au16data[8] = slave.getInCnt();
  au16data[9] = slave.getOutCnt();
  au16data[10] = slave.getErrCnt();
}