ModbusSMA  v1.0.0
ModbusSMA

modbusSMA is a smal and easy to use library for accessing the modbus interface of SMA inverters.The following code shows a basic example:

#include <modbusSMA/ModbusAPI.hpp>
#include <vector>
using namespace modbusSMA;
using namespace std;
int main() {
ModbusAPI mapi("127.0.0.1", 502); // Create the main API object
// Call further configuration functions here.
ErrorCode err = mapi.setup(); // Connect to the modbus interface with ModbusAPI::setup()
auto reg = mapi.getRegisters(); // Get a pointer to the RegisterContainer where all registers are stored.
// Use the shared RegisterContainer pointer (reg) to get a list of supported registers.
vector<uint16_t> toFetch = {30051, 30053, 30529, 30535, 30538};
err = mapi.updateRegisters(toFetch); // Fetch the values of the registers and store them in the RegisterContainer
// The fetched register values can now be retrieved from the shared RegisterContainer
vector<Register> registersWithValues = reg->getRegisters(toFetch);
return 0;
}
See also
ModbusAPI for more information