Fix: Ignore incomplete SystemConfigPara packages

Some inverters seem to transmit too less and incomplete data. These packages will be ignored now.
This commit is contained in:
Thomas Basler 2023-09-07 23:10:01 +02:00
parent 0260af9ada
commit 8023b6620a
3 changed files with 22 additions and 1 deletions

View File

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

View File

@ -85,3 +85,8 @@ void SystemConfigParaParser::setLastUpdateRequest(uint32_t lastUpdate)
_lastUpdateRequest = lastUpdate; _lastUpdateRequest = lastUpdate;
setLastUpdate(lastUpdate); setLastUpdate(lastUpdate);
} }
uint8_t SystemConfigParaParser::getExpectedByteCount()
{
return SYSTEM_CONFIG_PARA_SIZE;
}

View File

@ -23,6 +23,9 @@ public:
uint32_t getLastUpdateRequest(); uint32_t getLastUpdateRequest();
void setLastUpdateRequest(uint32_t lastUpdate); void setLastUpdateRequest(uint32_t lastUpdate);
// Returns 1 based amount of expected bytes of data
uint8_t getExpectedByteCount();
private: private:
uint8_t _payload[SYSTEM_CONFIG_PARA_SIZE]; uint8_t _payload[SYSTEM_CONFIG_PARA_SIZE];
uint8_t _payloadLength; uint8_t _payloadLength;