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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

help needed : how can i distinguish the callbacks at modbusRTU

Q7Jensen opened this issue · comments

If I have something like that
case 0:
result = mbRTU.readHreg(SLAVE_ID, 0, res, REG_COUNT, cbReadRTU); // voltage
break;
case 1:
result = mbRTU.readHreg(SLAVE_ID, 6, res, REG_COUNT, cbReadRTU); // current
break;
and
bool cbReadRTU(Modbus::ResultCode event, uint16_t transactionId, void* data) {
if (event != Modbus::EX_SUCCESS) {
Serial.printf_P("Request result from callback: 0x%02X", event); }
else {
// voltage or current ?
}
return true;
}

How can I distinguish the callbacks?
Do I need different callbacks?
BR Jens