Skip to content

Commit

Permalink
Fix: do not calc sizes multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
jstammi committed Jun 28, 2023
1 parent 4ae6a2b commit 82038d3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/Hoymiles/src/commands/RealTimeRunDataCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ bool RealTimeRunDataCommand::handleResponse(InverterAbstract* inverter, fragment
// Check if at least all required bytes are received
// In case of low power in the inverter it occours that some incomplete fragments
// with a valid CRC are received.
if (getTotalFragmentSize(fragment, max_fragment_id) < inverter->Statistics()->getExpectedByteCount()) {
Hoymiles.getMessageOutput()->printf("ERROR in %s: Received fragment size: %d min. expected size: %d\r\n",
getCommandName().c_str(),
getTotalFragmentSize(fragment, max_fragment_id),
inverter->Statistics()->getExpectedByteCount());
uint8_t fragmentsSize = getTotalFragmentSize(fragment, max_fragment_id);
uint8_t expectedSize = inverter->Statistics()->getExpectedByteCount();
if (fragmentsSize < expectedSize) {
Hoymiles.getMessageOutput()->printf("ERROR in %s: Received fragment size: %d, min expected size: %d\r\n",
getCommandName().c_str(), fragmentsSize, expectedSize);

return false;
}
Expand Down

0 comments on commit 82038d3

Please sign in to comment.