Prevent null pointer exception
It could occur that the command queue contained commands for inverters which are already deleted. Therefor it has to be checked that getInverterBySerial returns a valid inverter
This commit is contained in:
parent
26b9bbf537
commit
0d619e780a
@ -127,7 +127,7 @@ void HoymilesRadio::loop()
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If inverter was not found, assume the command is invalid
|
// If inverter was not found, assume the command is invalid
|
||||||
Serial.println(F("Invalid inverter found"));
|
Serial.println(F("RX: Invalid inverter found"));
|
||||||
_commandQueue.pop();
|
_commandQueue.pop();
|
||||||
_busyFlag = false;
|
_busyFlag = false;
|
||||||
}
|
}
|
||||||
@ -137,8 +137,13 @@ void HoymilesRadio::loop()
|
|||||||
CommandAbstract* cmd = _commandQueue.front().get();
|
CommandAbstract* cmd = _commandQueue.front().get();
|
||||||
|
|
||||||
auto inv = Hoymiles.getInverterBySerial(cmd->getTargetAddress());
|
auto inv = Hoymiles.getInverterBySerial(cmd->getTargetAddress());
|
||||||
inv->clearRxFragmentBuffer();
|
if (nullptr != inv) {
|
||||||
sendEsbPacket(cmd);
|
inv->clearRxFragmentBuffer();
|
||||||
|
sendEsbPacket(cmd);
|
||||||
|
} else {
|
||||||
|
Serial.println(F("TX: Invalid inverter found"));
|
||||||
|
_commandQueue.pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user