Skip to content

Commit

Permalink
Fix: Queue consumed whole memory on inverter timeout
Browse files Browse the repository at this point in the history
When the poll interval was e.g. 1sec it was possible that the queue ran full and consumed the whole memory.
Now new entries are only added to the queue automatically if the queue is empty.  This issue also caused a lot of "DTU command failed" messages.
  • Loading branch information
tbnobody committed Apr 25, 2023
1 parent 5996fb0 commit 0441bbb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/Hoymiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void HoymilesClass::loop()
}
}

if (iv != nullptr && iv->getRadio()->isInitialized() && iv->getRadio()->isIdle()) {
if (iv != nullptr && iv->getRadio()->isInitialized() && iv->getRadio()->isQueueEmpty()) {
_messageOutput->print("Fetch inverter: ");
_messageOutput->println(iv->serial(), HEX);

Expand Down
7 changes: 6 additions & 1 deletion lib/Hoymiles/src/HoymilesRadio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ bool HoymilesRadio::isInitialized()
bool HoymilesRadio::isIdle()
{
return !_busyFlag;
}
}

bool HoymilesRadio::isQueueEmpty()
{
return _commandQueue.size() == 0;
}
1 change: 1 addition & 0 deletions lib/Hoymiles/src/HoymilesRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class HoymilesRadio {
virtual void setDtuSerial(uint64_t serial);

bool isIdle();
bool isQueueEmpty();
bool isInitialized();

template <typename T>
Expand Down

0 comments on commit 0441bbb

Please sign in to comment.