Fix: calc expected statistics packet length per parser
tbnobody/OpenDTU/issues/1022
This commit is contained in:
parent
a510afe53e
commit
4ae6a2b4ef
@ -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()->getMaxByteCount()) {
|
||||
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()->getMaxByteCount());
|
||||
inverter->Statistics()->getExpectedByteCount());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -32,25 +32,18 @@ void StatisticsParser::setByteAssignment(const byteAssign_t* byteAssignment, uin
|
||||
{
|
||||
_byteAssignment = byteAssignment;
|
||||
_byteAssignmentSize = size;
|
||||
}
|
||||
|
||||
uint8_t StatisticsParser::getMaxByteCount()
|
||||
{
|
||||
static uint8_t maxByteCount = 0;
|
||||
|
||||
// Use already calculated value
|
||||
if (maxByteCount > 0) {
|
||||
return maxByteCount;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < _byteAssignmentSize; i++) {
|
||||
if (_byteAssignment[i].div == CMD_CALC) {
|
||||
continue;
|
||||
}
|
||||
maxByteCount = max<uint8_t>(maxByteCount, _byteAssignment[i].start + _byteAssignment[i].num);
|
||||
_expectedByteCount = max<uint8_t>(_expectedByteCount, _byteAssignment[i].start + _byteAssignment[i].num);
|
||||
}
|
||||
}
|
||||
|
||||
return maxByteCount;
|
||||
uint8_t StatisticsParser::getExpectedByteCount()
|
||||
{
|
||||
return _expectedByteCount;
|
||||
}
|
||||
|
||||
void StatisticsParser::clearBuffer()
|
||||
|
||||
@ -110,7 +110,7 @@ public:
|
||||
void setByteAssignment(const byteAssign_t* byteAssignment, uint8_t size);
|
||||
|
||||
// Returns 1 based amount of expected bytes of statistic data
|
||||
uint8_t getMaxByteCount();
|
||||
uint8_t getExpectedByteCount();
|
||||
|
||||
const byteAssign_t* getAssignmentByChannelField(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId);
|
||||
fieldSettings_t* getSettingByChannelField(ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId);
|
||||
@ -142,6 +142,7 @@ private:
|
||||
|
||||
const byteAssign_t* _byteAssignment;
|
||||
uint8_t _byteAssignmentSize;
|
||||
uint8_t _expectedByteCount;
|
||||
std::list<fieldSettings_t> _fieldSettings;
|
||||
|
||||
uint32_t _rxFailureCount = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user