Added check in statistics data that at least all required bytes are received

It can occour for some inverters that incomplete fragments with valid crc but less bytes are received

This was mentioned in #1084
This commit is contained in:
Thomas Basler
2023-06-27 18:59:54 +02:00
parent 12a18fb34b
commit 69aa247470
5 changed files with 46 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
* Copyright (C) 2022 Thomas Basler and others
*/
#include "RealTimeRunDataCommand.h"
#include "Hoymiles.h"
#include "inverters/InverterAbstract.h"
RealTimeRunDataCommand::RealTimeRunDataCommand(uint64_t target_address, uint64_t router_address, time_t time)
@@ -25,6 +26,18 @@ bool RealTimeRunDataCommand::handleResponse(InverterAbstract* inverter, fragment
return false;
}
// 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()->getMaxByteCount()) {
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()->getMaxByteCount());
return false;
}
// Move all fragments into target buffer
uint8_t offs = 0;
inverter->Statistics()->clearBuffer();