emelianov / modbus-esp8266

Most complete Modbus library for Arduino. A library that allows your Arduino board to communicate via Modbus protocol, acting as a master, slave or both. Supports network transport (Modbus TCP) and Serial line/RS-485 (Modbus RTU). Supports Modbus TCP Security for ESP8266/ESP32.
Other
519 stars 186 forks source link

Reference to holding register #334

Closed bvtvusn closed 4 months ago

bvtvusn commented 7 months ago

This is a great library! Is it possible to get a reference or pointer to the modbus slave array that is used behind the scenes in the library? The idea is that I want to make a new variable that points directly to the memory location where the library stores the states of the holding registers. This way, I don't have to call mb.Hreg() every loop. It would also make it easier to transfer floating point values directly over modbus.

Thank you.

emelianov commented 5 months ago

Internally registers stored objects in or custom equivalent (depending on Arduino board used) so it's not possible to provide access you want. You can use onGet callback dynamically to return custom data on register query no setting the value.