mirror of https://github.com/arendst/Tasmota.git
Add debugging info to modbus.ino
This commit is contained in:
parent
22803e3e3d
commit
587e8299d6
|
@ -319,6 +319,7 @@ void EnergyUpdateTotal(void) {
|
|||
|
||||
if ((Energy.total[i] < (Energy.import_active[i] - 0.01f)) && // We subtract a little offset to avoid continuous updates
|
||||
Settings->flag3.hardware_energy_total) { // SetOption72 - Enable hardware energy total counter as reference (#6561)
|
||||
// The following calculation allows total usage (Energy.import_active[i]) up to +/-21474 kWh
|
||||
RtcSettings.energy_kWhtotal_ph[i] = (int32_t)((Energy.import_active[i] * 100000) - Energy.kWhtoday_offset[i] - Energy.kWhtoday[i]);
|
||||
Settings->energy_kWhtotal_ph[i] = RtcSettings.energy_kWhtotal_ph[i];
|
||||
Energy.total[i] = (float)(RtcSettings.energy_kWhtotal_ph[i] + Energy.kWhtoday_offset[i] + Energy.kWhtoday[i]) / 100000;
|
||||
|
|
|
@ -280,10 +280,6 @@ void EnergyModbusLoop(void) {
|
|||
// Even data type is single register, Odd data type is double registers
|
||||
register_count = 2 - (NrgMbsReg[NrgMbsParam.state].datatype & 1);
|
||||
uint32_t error = EnergyModbus->ReceiveBuffer(buffer, register_count);
|
||||
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NRG: Modbus register %d, phase %d, rcvd %*_H"),
|
||||
NrgMbsParam.state, NrgMbsParam.phase, EnergyModbus->ReceiveCount(), buffer);
|
||||
|
||||
if (error) {
|
||||
/* Return codes from TasmotaModbus.h:
|
||||
* 0 = No error
|
||||
|
@ -302,6 +298,10 @@ void EnergyModbusLoop(void) {
|
|||
* 13 = Register data not specified
|
||||
* 14 = To many registers
|
||||
*/
|
||||
#ifdef ENERGY_MODBUS_DEBUG
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NRG: Modbus register %d, phase %d, rcvd %*_H"),
|
||||
NrgMbsParam.state, NrgMbsParam.phase, EnergyModbus->ReceiveCount(), buffer);
|
||||
#endif
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Modbus error %d"), error);
|
||||
} else {
|
||||
/* Modbus protocol format:
|
||||
|
@ -386,6 +386,10 @@ void EnergyModbusLoop(void) {
|
|||
value *= factor;
|
||||
}
|
||||
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NRG: Modbus register %d, phase %d, rcvd %*_H, T %d, F %d, value %4_f"),
|
||||
NrgMbsParam.state, NrgMbsParam.phase, EnergyModbus->ReceiveCount(), buffer,
|
||||
NrgMbsReg[NrgMbsParam.state].datatype, NrgMbsReg[NrgMbsParam.state].factor, &value);
|
||||
|
||||
switch (NrgMbsParam.state) {
|
||||
case NRG_MBS_VOLTAGE:
|
||||
Energy.voltage[NrgMbsParam.phase] = value; // 230.2 V
|
||||
|
|
Loading…
Reference in New Issue