* revert changes from yesterday regarding snprintf and its size #1410, #1411
* reduced cppcheck linter warnings significantly
* try to improve ePaper (ghosting) #1107
This commit is contained in:
lumapu 2024-02-07 22:50:13 +01:00
parent c447049e84
commit 7c532ca1cc
23 changed files with 164 additions and 158 deletions

View file

@ -698,7 +698,7 @@ class Communication : public CommQueue<> {
byte[23] to byte[26] Matching_APPFW_PN*/
DPRINT(DBG_INFO,F("HW_PartNo "));
DBGPRINTLN(String((uint32_t) (((p->packet[10] << 8) | p->packet[11]) << 8 | p->packet[12]) << 8 | p->packet[13]));
record_t<> *rec = q->iv->getRecordStruct(InverterDevInform_Simple); // choose the record structure
rec = q->iv->getRecordStruct(InverterDevInform_Simple); // choose the record structure
rec->ts = q->ts;
q->iv->setValue(0, rec, (uint32_t) ((((p->packet[10] << 8) | p->packet[11]) << 8 | p->packet[12]) << 8 | p->packet[13])/1);
rec->mqttSentStatus = MqttSentStatus::NEW_DATA;
@ -899,14 +899,16 @@ class Communication : public CommQueue<> {
q->iv->alarmCnt = 1; // minimum...
stsok = false;
//sth is or was wrong?
if ( (q->iv->type != INV_TYPE_1CH) && ( (statusMi != 3)
|| ((q->iv->lastAlarm[stschan].code) && (statusMi == 3) && (q->iv->lastAlarm[stschan].code != 1)))
if ((q->iv->type != INV_TYPE_1CH)
&& ((statusMi != 3)
|| ((q->iv->lastAlarm[stschan].code) && (q->iv->lastAlarm[stschan].code != 1)))
) {
q->iv->lastAlarm[stschan+q->iv->type==INV_TYPE_2CH ? 2: 4] = alarm_t(q->iv->lastAlarm[stschan].code, q->iv->lastAlarm[stschan].start,q->ts);
q->iv->lastAlarm[stschan] = alarm_t(prntsts, q->ts,0);
q->iv->alarmCnt = q->iv->type == INV_TYPE_2CH ? 3 : 5;
} else if ( (q->iv->type == INV_TYPE_1CH) && ( (statusMi != 3)
|| ((q->iv->lastAlarm[stschan].code) && (statusMi == 3) && (q->iv->lastAlarm[stschan].code != 1)))
} else if ((q->iv->type == INV_TYPE_1CH)
&& ( (statusMi != 3)
|| ((q->iv->lastAlarm[stschan].code) && (q->iv->lastAlarm[stschan].code != 1)))
) {
q->iv->lastAlarm[stschan] = alarm_t(q->iv->lastAlarm[0].code, q->iv->lastAlarm[0].start,q->ts);
} else if (q->iv->type == INV_TYPE_1CH)
@ -962,7 +964,7 @@ class Communication : public CommQueue<> {
iv->radioStatistics.ivLoss = iv->radioStatistics.ivSent - iv->mDtuRxCnt; // this is what we didn't receive
iv->radioStatistics.dtuLoss = iv->mIvTxCnt; // this is somehow the requests w/o answers in that periode
iv->radioStatistics.dtuSent = iv->mDtuTxCnt;
if (mSerialDebug) {
if (*mSerialDebug) {
DPRINT_IVID(DBG_INFO, iv->id);
DBGPRINTLN("DTU loss: " +
String (iv->radioStatistics.ivLoss) + "/" +

View file

@ -132,7 +132,7 @@ class Heuristic {
ih->lastRxFragments = rxFragments;
}
void printStatus(Inverter<> *iv) {
void printStatus(const Inverter<> *iv) {
DPRINT_IVID(DBG_INFO, iv->id);
DBGPRINT(F("Radio infos:"));
if((IV_HMS != iv->ivGen) && (IV_HMT != iv->ivGen)) {

View file

@ -395,9 +395,9 @@ class HmRadio : public Radio {
#endif*/
if(*mPrintWholeTrace) {
if(*mPrivacyMode)
ah::dumpBuf(mTxBuf, len, 1, 4);
ah::dumpBuf(mTxBuf.data(), len, 1, 4);
else
ah::dumpBuf(mTxBuf, len);
ah::dumpBuf(mTxBuf.data(), len);
} else {
DHEX(mTxBuf[0]);
DBGPRINT(F(" "));
@ -415,7 +415,7 @@ class HmRadio : public Radio {
}
mNrf24->setChannel(mRfChLst[mTxChIdx]);
mNrf24->openWritingPipe(reinterpret_cast<uint8_t*>(&iv->radioId.u64));
mNrf24->startWrite(mTxBuf, len, false); // false = request ACK response
mNrf24->startWrite(mTxBuf.data(), len, false); // false = request ACK response
mMillis = millis();
mLastIv = iv;

View file

@ -11,6 +11,7 @@
#define ALL_FRAMES 0x80
#define SINGLE_FRAME 0x81
#include <array>
#include <atomic>
#include "../utils/dbg.h"
#include "../utils/crc.h"
@ -34,6 +35,8 @@ class Radio {
virtual std::pair<uint16_t,uint16_t> getFreqRangeMhz(void) { return std::make_pair(0, 0); }
virtual bool loop(void) = 0;
Radio() : mTxBuf{} {}
void handleIntr(void) {
mIrqRcvd = true;
mIrqOk = IRQ_OK;
@ -107,7 +110,7 @@ class Radio {
mTxBuf[(*len)++] = (crc ) & 0xff;
}
// crc over all
mTxBuf[*len] = ah::crc8(mTxBuf, *len);
mTxBuf[*len] = ah::crc8(mTxBuf.data(), *len);
(*len)++;
}
@ -129,12 +132,11 @@ class Radio {
mDtuSn |= 0x80000000; // the first digit is an 8 for DTU production year 2022, the rest is filled with the ESP chipID in decimal
}
uint32_t mDtuSn;
std::atomic<bool> mIrqRcvd;
protected:
uint32_t mDtuSn = 0;
std::atomic<bool> mIrqRcvd = false;
bool *mSerialDebug = nullptr, *mPrivacyMode = nullptr, *mPrintWholeTrace = nullptr;
uint8_t mTxBuf[MAX_RF_PAYLOAD_SIZE];
std::array<uint8_t, MAX_RF_PAYLOAD_SIZE> mTxBuf;
};
#endif /*__RADIO_H__*/

View file

@ -118,9 +118,9 @@ class Simulator {
}
private:
HMSYSTEM *mSys;
uint8_t mIvId;
uint32_t *mTimestamp;
HMSYSTEM *mSys = nullptr;
uint8_t mIvId = 0;
uint32_t *mTimestamp = nullptr;
payloadListenerType mCbPayload = nullptr;
uint8_t payloadCtrl = 0;