Skip to content

Commit

Permalink
0.8.73
Browse files Browse the repository at this point in the history
* fix nullpointer during communication #1401
* added `max_power` to MqTT total values #1375
  • Loading branch information
lumapu committed Feb 4, 2024
1 parent 14c5a7a commit 6b5435a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
4 changes: 4 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Development Changes

## 0.8.73 - 2024-02-03
* fix nullpointer during communication #1401
* added `max_power` to MqTT total values #1375

## 0.8.72 - 2024-02-03
* fixed translation #1403
* fixed sending commands to inverters which are soft turned off #1397
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 72
#define VERSION_PATCH 73

//-------------------------------------
typedef struct {
Expand Down
33 changes: 16 additions & 17 deletions src/hm/Communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,14 @@ class Communication : public CommQueue<> {
return;
}

compilePayload(q);
if(compilePayload(q)) {
if((NULL != mCbPayload) && (GridOnProFilePara != q->cmd) && (GetLossRate != q->cmd))
(mCbPayload)(q->cmd, q->iv);

if((NULL != mCbPayload) && (GridOnProFilePara != q->cmd) && (GetLossRate != q->cmd))
(mCbPayload)(q->cmd, q->iv);
closeRequest(q, true);
} else
closeRequest(q, false);

closeRequest(q, true);
break;
}
}
Expand Down Expand Up @@ -498,7 +500,7 @@ class Communication : public CommQueue<> {
return accepted;
}

inline void compilePayload(const queue_s *q) {
inline bool compilePayload(const queue_s *q) {
uint16_t crc = 0xffff, crcRcv = 0x0000;
for(uint8_t i = 0; i < mMaxFrameId; i++) {
if(i == (mMaxFrameId - 1)) {
Expand All @@ -514,13 +516,12 @@ class Communication : public CommQueue<> {
DBGPRINT(F("CRC Error "));
if(q->attempts == 0) {
DBGPRINTLN(F("-> Fail"));
closeRequest(q, false);

} else
DBGPRINTLN(F("-> complete retransmit"));
mCompleteRetry = true;
mState = States::RESET;
return;
return false;
}

memset(mPayload, 0, MAX_BUFFER);
Expand All @@ -530,7 +531,7 @@ class Communication : public CommQueue<> {
for(uint8_t i = 0; i < mMaxFrameId; i++) {
if(mLocalBuf[i].len + len > MAX_BUFFER) {
DPRINTLN(DBG_ERROR, F("payload buffer to small!"));
return;
return true;
}
memcpy(&mPayload[len], mLocalBuf[i].buf, mLocalBuf[i].len);
len += mLocalBuf[i].len;
Expand All @@ -552,30 +553,27 @@ class Communication : public CommQueue<> {

if(GridOnProFilePara == q->cmd) {
q->iv->addGridProfile(mPayload, len);
return;
return true;
}

record_t<> *rec = q->iv->getRecordStruct(q->cmd);
if(NULL == rec) {
if(GetLossRate == q->cmd) {
q->iv->parseGetLossRate(mPayload, len);
return;
} else {
return true;
} else
DPRINTLN(DBG_ERROR, F("record is NULL!"));
closeRequest(q, false);
}
return;

return false;
}
if((rec->pyldLen != len) && (0 != rec->pyldLen)) {
if(*mSerialDebug) {
DPRINT(DBG_ERROR, F("plausibility check failed, expected "));
DBGPRINT(String(rec->pyldLen));
DBGPRINTLN(F(" bytes"));
}
/*q->iv->radioStatistics.rxFail++;*/
closeRequest(q, false);

return;
return false;
}

rec->ts = q->ts;
Expand All @@ -597,6 +595,7 @@ class Communication : public CommQueue<> {
yield();
}
}
return true;
}

void sendRetransmit(const queue_s *q, uint8_t i) {
Expand Down
13 changes: 10 additions & 3 deletions src/publisher/pubMqttIvData.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class PubMqttIvData {

if((RealTimeRunData_Debug != mCmd) || !mRTRDataHasBeenSent) { // send RealTimeRunData only once
mSendTotals = (RealTimeRunData_Debug == mCmd);
memset(mTotal, 0, sizeof(float) * 4);
memset(mTotal, 0, sizeof(float) * 5);
mState = FIND_NXT_IV;
} else
mSendList->pop();
Expand Down Expand Up @@ -164,6 +164,9 @@ class PubMqttIvData {
case FLD_PDC:
mTotal[3] += mIv->getValue(mPos, rec);
break;
case FLD_MP:
mTotal[4] += mIv->getValue(mPos, rec);
break;
}
} else
mAllTotalFound = false;
Expand Down Expand Up @@ -204,7 +207,7 @@ class PubMqttIvData {
void stateSendTotals() {
uint8_t fieldId;
mRTRDataHasBeenSent = true;
if(mPos < 4) {
if(mPos < 5) {
bool retained = true;
switch (mPos) {
default:
Expand All @@ -230,6 +233,10 @@ class PubMqttIvData {
fieldId = FLD_PDC;
retained = false;
break;
case 4:
fieldId = FLD_MP;
retained = false;
break;
}
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "total/%s", fields[fieldId]);
snprintf(mVal, 40, "%g", ah::round3(mTotal[mPos]));
Expand All @@ -251,7 +258,7 @@ class PubMqttIvData {
uint8_t mCmd;
uint8_t mLastIvId;
bool mSendTotals, mTotalFound, mAllTotalFound, mSendTotalYd;
float mTotal[4], mYldTotalStore;
float mTotal[5], mYldTotalStore;

Inverter<> *mIv, *mIvSend;
uint8_t mPos;
Expand Down

0 comments on commit 6b5435a

Please sign in to comment.