cmcgerty/Sofar2mqtt

wrong order of if statement?

Opened this issue · 2 comments

Should this be the other way around?

if(!readSingleReg(SOFAR_SLAVE_ID, SOFAR_REG_GRIDW, &rs))
p = ((rs.data[0] << 8) | rs.data[1]);
else
Serial.println("modbus error");

Quite possibly. It certainly looks like p would only be set if readSingleReg fails. Do you have one connected with a serial console open? Does it constantly log “modbus error” when in battery save mode? I’ll take a look when I get a chance.

Not using batterysave but I just noticed it while modifying the code a bit to suit my own situation