Browse Source

0.8.147

* fixed send power limit #1757
pull/1759/head
lumapu 4 months ago
parent
commit
08bc773cc2
  1. 1
      src/CHANGES.md
  2. 17
      src/hm/CommQueue.h
  3. 41
      src/hm/Communication.h

1
src/CHANGES.md

@ -2,6 +2,7 @@
## 0.8.147 - 2024-09-29 ## 0.8.147 - 2024-09-29
* improved queue, added mutex * improved queue, added mutex
* fixed send power limit #1757
## 0.8.146 - 2024-09-23 ## 0.8.146 - 2024-09-23
* fix reset ticker #1754 * fix reset ticker #1754

17
src/hm/CommQueue.h

@ -1,5 +1,5 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// 2023 Ahoy, https://github.com/lumpapu/ahoy // 2024 Ahoy, https://github.com/lumpapu/ahoy
// Creative Commons - http://creativecommons.org/licenses/by-nc-sa/4.0/deed // Creative Commons - http://creativecommons.org/licenses/by-nc-sa/4.0/deed
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -140,24 +140,21 @@ class CommQueue {
if(this->rdPtr == this->wrPtr) if(this->rdPtr == this->wrPtr)
cb(false, nullptr); // empty cb(false, nullptr); // empty
else { else {
//xSemaphoreTake(this->mutex, portMAX_DELAY); xSemaphoreTake(this->mutex, portMAX_DELAY);
//uint8_t tmp = this->rdPtr; QueueElement el = mQueue[this->rdPtr];
//xSemaphoreGive(this->mutex); inc(&this->rdPtr);
cb(true, &mQueue[this->rdPtr]); xSemaphoreGive(this->mutex);
cb(true, &el);
} }
} }
void cmdDone(QueueElement *q, bool keep = false) { void cmdDone(QueueElement *q, bool keep = false) {
xSemaphoreTake(this->mutex, portMAX_DELAY);
if(keep) { if(keep) {
q->attempts = DefaultAttempts; q->attempts = DefaultAttempts;
q->attemptsMax = DefaultAttempts; q->attemptsMax = DefaultAttempts;
xSemaphoreGive(this->mutex);
add(q); // add to the end again add(q); // add to the end again
xSemaphoreTake(this->mutex, portMAX_DELAY);
} }
inc(&this->rdPtr); //inc(&this->rdPtr);
xSemaphoreGive(this->mutex);
} }
private: private:

41
src/hm/Communication.h

@ -21,7 +21,9 @@ typedef std::function<void(Inverter<> *)> alarmListenerType;
class Communication : public CommQueue<> { class Communication : public CommQueue<> {
public: public:
Communication() : CommQueue() {} Communication()
: CommQueue()
{}
~Communication() {} ~Communication() {}
@ -52,23 +54,29 @@ class Communication : public CommQueue<> {
} }
void loop() { void loop() {
get([this](bool valid, QueueElement *q) { if(States::RESET == mState) {
if(!valid) { get([this](bool valid, QueueElement *q) {
if(mPrintSequenceDuration) { if(!valid) {
mPrintSequenceDuration = false; if(mPrintSequenceDuration) {
DPRINT(DBG_INFO, F("com loop duration: ")); mPrintSequenceDuration = false;
DBGPRINT(String(millis() - mLastEmptyQueueMillis)); DPRINT(DBG_INFO, F("com loop duration: "));
DBGPRINTLN(F("ms")); DBGPRINT(String(millis() - mLastEmptyQueueMillis));
DBGPRINTLN(F("-----")); DBGPRINTLN(F("ms"));
DBGPRINTLN(F("-----"));
el.iv = nullptr;
}
return; // empty
} }
return; // empty
}
if(!mPrintSequenceDuration) // entry was added to the queue
mLastEmptyQueueMillis = millis();
mPrintSequenceDuration = true;
innerLoop(q); el = *q;
}); if(!mPrintSequenceDuration) // entry was added to the queue
mLastEmptyQueueMillis = millis();
mPrintSequenceDuration = true;
});
}
if(nullptr != el.iv)
innerLoop(&el);
} }
private: private:
@ -1035,6 +1043,7 @@ class Communication : public CommQueue<> {
private: private:
States mState = States::RESET; States mState = States::RESET;
uint32_t *mTimestamp = nullptr; uint32_t *mTimestamp = nullptr;
QueueElement el;
bool *mPrivacyMode = nullptr, *mSerialDebug = nullptr, *mPrintWholeTrace = nullptr; bool *mPrivacyMode = nullptr, *mSerialDebug = nullptr, *mPrintWholeTrace = nullptr;
TimeMonitor mWaitTime = TimeMonitor(0, true); // start as expired (due to code in RESET state) TimeMonitor mWaitTime = TimeMonitor(0, true); // start as expired (due to code in RESET state)
std::array<frame_t, MAX_PAYLOAD_ENTRIES> mLocalBuf; std::array<frame_t, MAX_PAYLOAD_ENTRIES> mLocalBuf;

Loading…
Cancel
Save