diff --git a/src/CHANGES.md b/src/CHANGES.md index d57c90d6a..952659688 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,8 @@ # Development Changes +## 0.8.27 - 2023-12-18 +* fix set power limit #1276 + ## 0.8.26 - 2023-12-17 * read grid profile as HEX (`live` -> click inverter name -> `show grid profile`) diff --git a/src/defines.h b/src/defines.h index 4d94bc95e..b6e5b8aa0 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 26 +#define VERSION_PATCH 27 //------------------------------------- typedef struct { diff --git a/src/hm/CommQueue.h b/src/hm/CommQueue.h index d1beedfcb..37ffda62a 100644 --- a/src/hm/CommQueue.h +++ b/src/hm/CommQueue.h @@ -16,22 +16,22 @@ class CommQueue { public: CommQueue() {} - void addImportant(Inverter<> *iv, uint8_t cmd, bool delOnPop = true) { + void addImportant(Inverter<> *iv, uint8_t cmd) { dec(&mRdPtr); - mQueue[mRdPtr] = queue_s(iv, cmd, delOnPop, true); + mQueue[mRdPtr] = queue_s(iv, cmd, true); } - void add(Inverter<> *iv, uint8_t cmd, bool delOnPop = true) { - mQueue[mWrPtr] = queue_s(iv, cmd, delOnPop, false); + void add(Inverter<> *iv, uint8_t cmd) { + mQueue[mWrPtr] = queue_s(iv, cmd, false); inc(&mWrPtr); } - void chgCmd(Inverter<> *iv, uint8_t cmd, bool delOnPop = true) { - mQueue[mWrPtr] = queue_s(iv, cmd, delOnPop, false); + void chgCmd(Inverter<> *iv, uint8_t cmd) { + mQueue[mWrPtr] = queue_s(iv, cmd, false); } uint8_t getFillState(void) { - DPRINTLN(DBG_INFO, "wr: " + String(mWrPtr) + ", rd: " + String(mRdPtr)); + //DPRINTLN(DBG_INFO, "wr: " + String(mWrPtr) + ", rd: " + String(mRdPtr)); return abs(mRdPtr - mWrPtr); } @@ -45,11 +45,10 @@ class CommQueue { uint8_t cmd; uint8_t attempts; uint32_t ts; - bool delOnPop; bool isDevControl; queue_s() {} - queue_s(Inverter<> *i, uint8_t c, bool d, bool dev) : - iv(i), cmd(c), attempts(5), ts(0), delOnPop(d), isDevControl(dev) {} + queue_s(Inverter<> *i, uint8_t c, bool dev) : + iv(i), cmd(c), attempts(5), ts(0), isDevControl(dev) {} }; protected: @@ -78,8 +77,8 @@ class CommQueue { cb(true, &mQueue[mRdPtr]); } - void cmdDone(bool force = false) { - if(!mQueue[mRdPtr].delOnPop && !force) { + void cmdDone(bool keep = false) { + if(keep) { mQueue[mRdPtr].attempts = 5; add(mQueue[mRdPtr]); // add to the end again } diff --git a/src/hm/Communication.h b/src/hm/Communication.h index 3e95b665b..232549227 100644 --- a/src/hm/Communication.h +++ b/src/hm/Communication.h @@ -30,9 +30,9 @@ class Communication : public CommQueue<> { mInverterGap = inverterGap; } - void addImportant(Inverter<> *iv, uint8_t cmd, bool delOnPop = true) { + void addImportant(Inverter<> *iv, uint8_t cmd) { mState = States::RESET; // cancel current operation - CommQueue::addImportant(iv, cmd, delOnPop); + CommQueue::addImportant(iv, cmd); } void addPayloadListener(payloadListenerType cb) { @@ -84,7 +84,7 @@ class Communication : public CommQueue<> { q->iv->curFrmCnt = 0; mIsRetransmit = false; if(NULL == q->iv->radio) - cmdDone(true); // can't communicate while radio is not defined! + cmdDone(false); // can't communicate while radio is not defined! mState = States::START; break; @@ -177,6 +177,7 @@ class Communication : public CommQueue<> { closeRequest(q, true); else closeRequest(q, false); + q->iv->radio->mBufCtrl.pop(); return; // don't wait for empty buffer } else if(IV_MI == q->iv->ivGen) { if(parseMiFrame(p, q)) @@ -399,8 +400,6 @@ class Communication : public CommQueue<> { DBGPRINT(F("CRC Error ")); if(q->attempts == 0) { DBGPRINTLN(F("-> Fail")); - /*q->iv->radioStatistics.rxFail++; // got fragments but not complete response - cmdDone();*/ closeRequest(q, false); } else @@ -502,16 +501,19 @@ class Communication : public CommQueue<> { q->iv->radioStatistics.rxSuccess++; else if(q->iv->mGotFragment) q->iv->radioStatistics.rxFail++; // got no complete payload - else { + else q->iv->radioStatistics.rxFailNoAnser++; // got nothing - } mWaitTimeout = millis() + *mInverterGap; - cmdDone(q->delOnPop); + bool keep = false; + if(q->isDevControl) + keep = !crcPass; + + cmdDone(keep); q->iv->mGotFragment = false; q->iv->mGotLastMsg = false; q->iv->miMultiParts = 0; - mIsRetransmit = false; + mIsRetransmit = false; mFirstTry = false; // for correct reset mState = States::RESET; DBGPRINTLN(F("-----")); @@ -836,7 +838,7 @@ class Communication : public CommQueue<> { //closeRequest(iv, iv->miMultiParts > 5); //mHeu.setGotAll(iv); - //cmdDone(true); + //cmdDone(false); if(NULL != mCbPayload) (mCbPayload)(RealTimeRunData_Debug, iv); diff --git a/src/hm/hmRadio.h b/src/hm/hmRadio.h index 4fe3ea580..d0387aa4a 100644 --- a/src/hm/hmRadio.h +++ b/src/hm/hmRadio.h @@ -138,7 +138,7 @@ class HmRadio : public Radio { startMicros = micros(); } // not finished but time is over - mRxChIdx = 1; + mRxChIdx = (mRxChIdx + 1) % RF_CHANNELS; return; }