diff --git a/src/hm/Communication.h b/src/hm/Communication.h index d0878dd5..5c1b1f21 100644 --- a/src/hm/Communication.h +++ b/src/hm/Communication.h @@ -141,6 +141,8 @@ class Communication : public CommQueue<> { q->iv->radio->switchFrequency(q->iv, HOY_BOOT_FREQ_KHZ, (q->iv->config->frequency*FREQ_STEP_KHZ + HOY_BASE_FREQ_KHZ)); mWaitTime.startTimeMonitor(1000); } + if(IV_MI == q->iv->ivGen) + q->iv->mIvTxCnt++; } closeRequest(q, false); break; @@ -733,17 +735,16 @@ class Communication : public CommQueue<> { miNextRequest((p->packet[0] - ALL_FRAMES + 1), q); } else { q->iv->miMultiParts = 7; // indicate we are ready - //miComplete(q->iv); } } else if((p->packet[0] == (MI_REQ_CH1 + ALL_FRAMES)) && (q->iv->type == INV_TYPE_2CH)) { //addImportant(q->iv, MI_REQ_CH2); miNextRequest(MI_REQ_CH2, q); mHeu.evalTxChQuality(q->iv, true, (q->attemptsMax - 1 - q->attempts), q->iv->curFrmCnt); - //use also miMultiParts here for better statistics? - //mHeu.setGotFragment(q->iv); - } else { // first data msg for 1ch, 2nd for 2ch + q->iv->mIvRxCnt++; // statistics workaround... + + } else { // first data msg for 1ch, 2nd for 2ch q->iv->miMultiParts += 6; // indicate we are ready - //miComplete(q->iv); + } } @@ -757,13 +758,9 @@ class Communication : public CommQueue<> { DBGHEXLN(cmd); } - if(q->iv->miMultiParts == 7) { - //mHeu.setGotAll(q->iv); + if(q->iv->miMultiParts == 7) q->iv->radioStatistics.rxSuccess++; - } else - //mHeu.setGotFragment(q->iv); - /*iv->radioStatistics.rxFail++; // got no complete payload*/ - //q->iv->radioStatistics.retransmits++; + q->iv->radio->sendCmdPacket(q->iv, cmd, 0x00, true); mWaitTime.startTimeMonitor(MI_TIMEOUT); @@ -871,6 +868,26 @@ class Communication : public CommQueue<> { DPRINT_IVID(DBG_INFO, iv->id); DBGPRINTLN(F("got all data msgs")); } + + if (iv->mGetLossInterval >= AHOY_GET_LOSS_INTERVAL) { // initially mIvRxCnt = mIvTxCnt = 0 + iv->mGetLossInterval = 1; + iv->radioStatistics.ivSent = iv->mIvRxCnt + iv->mDtuTxCnt; // iv->mIvRxCnt is the nr. of additional answer frames, default we expect one frame per request + 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) { + DPRINT_IVID(DBG_INFO, iv->id); + DBGPRINTLN("DTU loss: " + + String (iv->radioStatistics.ivLoss) + "/" + + String (iv->radioStatistics.ivSent) + " frames for " + + String (iv->radioStatistics.dtuSent) + " requests"); + } + iv->mIvRxCnt = 0; // start new interval, iVRxCnt is abused to collect additional possible frames + iv->mIvTxCnt = 0; // start new interval, iVTxCnt is abused to collect nr. of unanswered requests + iv->mDtuRxCnt = 0; // start new interval + iv->mDtuTxCnt = 0; // start new interval + } + record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0)); diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index 4e714cfd..aeb40c19 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -212,16 +212,22 @@ class Inverter { cb(RealTimeRunData_Debug, false); // get live data } } else { // MI - if(0 == getFwVersion()) + if(0 == getFwVersion()) { + mIvRxCnt +=2; cb(0x0f, false); // get firmware version; for MI, this makes part of polling the device software and hardware version number - else { + } else { record_t<> *rec = getRecordStruct(InverterDevInform_Simple); - if (getChannelFieldValue(CH0, FLD_PART_NUM, rec) == 0) + if (getChannelFieldValue(CH0, FLD_PART_NUM, rec) == 0) { cb(0x0f, false); // hard- and firmware version for missing HW part nr, delivered by frame 1 - else if((getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec) == 0) && generalConfig->readGrid) // read grid profile + mIvRxCnt +=2; + } else if((getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec) == 0) && generalConfig->readGrid) // read grid profile cb(0x10, false); // legacy GPF command - else + else { cb(((type == INV_TYPE_4CH) ? MI_REQ_4CH : MI_REQ_CH1), false); + mGetLossInterval++; + if (type != INV_TYPE_4CH) + mIvRxCnt++; // statistics workaround... + } } } } @@ -619,7 +625,7 @@ class Inverter { radioStatistics.dtuSent = txCnt + ((uint16_t)65535 - mIvTxCnt) + 1; else radioStatistics.dtuSent = txCnt - mIvTxCnt; - + radioStatistics.dtuLoss = radioStatistics.dtuSent - mDtuRxCnt; DPRINT_IVID(DBG_INFO, id); @@ -831,15 +837,16 @@ class Inverter { bool mDevControlRequest; // true if change needed uint8_t mGridLen = 0; uint8_t mGridProfile[MAX_GRID_LENGTH]; - uint8_t mGetLossInterval; // request iv every AHOY_GET_LOSS_INTERVAL RealTimeRunData_Debug - uint16_t mIvRxCnt = 0; - uint16_t mIvTxCnt = 0; uint8_t mAlarmNxtWrPos = 0; // indicates the position in array (rolling buffer) bool mNextLive = true; // first read live data after booting up then version etc. public: uint16_t mDtuRxCnt = 0; uint16_t mDtuTxCnt = 0; + uint8_t mGetLossInterval = 0; // request iv every AHOY_GET_LOSS_INTERVAL RealTimeRunData_Debug + uint16_t mIvRxCnt = 0; + uint16_t mIvTxCnt = 0; + }; template diff --git a/src/hm/radio.h b/src/hm/radio.h index 1ef32e05..e5eda128 100644 --- a/src/hm/radio.h +++ b/src/hm/radio.h @@ -42,8 +42,10 @@ class Radio { void prepareDevInformCmd(Inverter<> *iv, uint8_t cmd, uint32_t ts, uint16_t alarmMesId, bool isRetransmit, uint8_t reqfld=TX_REQ_INFO) { // might not be necessary to add additional arg. if(IV_MI == getIvGen(iv)) { - DPRINT(DBG_DEBUG, F("legacy cmd 0x")); - DPRINTLN(DBG_DEBUG,String(cmd, HEX)); + if(*mSerialDebug) { + DPRINT(DBG_DEBUG, F("legacy cmd 0x")); + DPRINTLN(DBG_DEBUG,String(cmd, HEX)); + } sendCmdPacket(iv, cmd, cmd, false, false); return; }