Browse Source

0.8.2720

finally GetLossRate seems to work without troubles...
pull/1284/head
rejoe2 2 years ago
committed by GitHub
parent
commit
1bffc7528e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/defines.h
  2. 6
      src/hm/Communication.h
  3. 11
      src/hm/hmInverter.h
  4. 19
      src/hm/hmRadio.h

2
src/defines.h

@ -13,7 +13,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 8 #define VERSION_MINOR 8
#define VERSION_PATCH 2716 #define VERSION_PATCH 2720
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {

6
src/hm/Communication.h

@ -488,8 +488,10 @@ class Communication : public CommQueue<> {
record_t<> *rec = q->iv->getRecordStruct(q->cmd); record_t<> *rec = q->iv->getRecordStruct(q->cmd);
if(NULL == rec) { if(NULL == rec) {
if(GetLossRate == q->cmd) { if(GetLossRate == q->cmd) {
q->iv->parseGetLossRate(q->iv->id, mPayload, len); //q->iv->parseGetLossRate(q->iv->id, mPayload, len);
closeRequest(q, true); q->iv->parseGetLossRate(mPayload, len);
//closeRequest(q, true);
return;
} else { } else {
DPRINTLN(DBG_ERROR, F("record is NULL!")); DPRINTLN(DBG_ERROR, F("record is NULL!"));
closeRequest(q, false); closeRequest(q, false);

11
src/hm/hmInverter.h

@ -175,6 +175,10 @@ class Inverter {
mIsSingleframeReq = false; mIsSingleframeReq = false;
radio = NULL; radio = NULL;
commEnabled = true; commEnabled = true;
mIvRxCnt = 0;
mIvTxCnt = 0;
mDtuRxCnt = 0;
mDtuTxCnt = 0;
memset(&radioStatistics, 0, sizeof(statistics_t)); memset(&radioStatistics, 0, sizeof(statistics_t));
memset(heuristics.txRfQuality, -6, 5); memset(heuristics.txRfQuality, -6, 5);
@ -601,18 +605,21 @@ class Inverter {
memset(mLastYD, 0, sizeof(float) * 6); memset(mLastYD, 0, sizeof(float) * 6);
} }
bool parseGetLossRate(uint8_t id, uint8_t pyld[], uint8_t len) { //bool parseGetLossRate(uint8_t id, uint8_t pyld[], uint8_t len) {
bool parseGetLossRate(uint8_t pyld[], uint8_t len) {
if (len == HMGETLOSSRATE_PAYLOAD_LEN) { if (len == HMGETLOSSRATE_PAYLOAD_LEN) {
uint16_t rxCnt = (pyld[0] << 8) + pyld[1]; uint16_t rxCnt = (pyld[0] << 8) + pyld[1];
uint16_t txCnt = (pyld[2] << 8) + pyld[3]; uint16_t txCnt = (pyld[2] << 8) + pyld[3];
if (mIvRxCnt || mIvTxCnt) { // there was successful GetLossRate in the past if (mIvRxCnt || mIvTxCnt) { // there was successful GetLossRate in the past
DPRINT_IVID(DBG_INFO, id); DPRINT_IVID(DBG_INFO, id);
DBGPRINTLN("Inv loss: " + String (mDtuTxCnt - (rxCnt - mIvRxCnt)) + " of " + DBGPRINTLN("Inv loss: " +
String (mDtuTxCnt - (rxCnt - mIvRxCnt)) + " of " +
String (mDtuTxCnt) + ", DTU loss: " + String (mDtuTxCnt) + ", DTU loss: " +
String (txCnt - mIvTxCnt - mDtuRxCnt) + " of " + String (txCnt - mIvTxCnt - mDtuRxCnt) + " of " +
String (txCnt - mIvTxCnt)); String (txCnt - mIvTxCnt));
} }
mIvRxCnt = rxCnt; mIvRxCnt = rxCnt;
mIvTxCnt = txCnt; mIvTxCnt = txCnt;
mDtuRxCnt = 0; // start new interval mDtuRxCnt = 0; // start new interval

19
src/hm/hmRadio.h

@ -130,10 +130,12 @@ class HmRadio : public Radio {
//mRxChannels - 1; // //mRxChannels - 1; //
//(mTxChIdx + mRxChannels) % RF_MAX_CHANNEL_ID; // start with a fixed offset //(mTxChIdx + mRxChannels) % RF_MAX_CHANNEL_ID; // start with a fixed offset
bool switchch = true; bool switchch = true;
uint8_t looprounds = 0;
while ((millis() - loopMillis) < mRxTmoOuterLoop) { while ((millis() - loopMillis) < mRxTmoOuterLoop) {
while ((micros() - startMicros) < mRxTmoInnerLoop) { // listen (4088us or?) 5110us to each channel while ((micros() - startMicros) < mRxTmoInnerLoop) { // listen (4088us or?) 5110us to each channel
if (mIrqRcvd) { if (mIrqRcvd) {
mIrqRcvd = false; mIrqRcvd = false;
mLastIv->mRxChanSync = false; //reset
if (getReceived()) { // everything received if (getReceived()) { // everything received
return; return;
@ -142,10 +144,22 @@ class HmRadio : public Radio {
yield(); yield();
} }
// switch to next RX channel // switch to next RX channel
bool chgchan = true;
/*if (mLastIv->mRxChanSync) { /*if (mLastIv->mRxChanSync) {
switchch = !switchch; if (!looprounds) {
mRxChIdx = mLastIv->mRxChanIdx - switchch; mRxChIdx = mLastIv->mRxChanIdx - switchch;
} else if (++looprounds > 9) {
looprounds = 0;
switchch = !switchch;
mRxChIdx = mLastIv->mRxChanIdx - switchch;
if(switchch)
mLastIv->mRxChanSync = false; // we didn't receive st. timely on this channel
} else
chgchan = false;
}*/ }*/
if(chgchan) {
if(++mRxChIdx >= RF_CHANNELS) if(++mRxChIdx >= RF_CHANNELS)
mRxChIdx = 0; mRxChIdx = 0;
@ -157,6 +171,7 @@ class HmRadio : public Radio {
mNrf24->setChannel(mRfChLst[mRxChIdx]); mNrf24->setChannel(mRfChLst[mRxChIdx]);
//mNrf24->setChannel(mRfChLst[nextRxCh]); //mNrf24->setChannel(mRfChLst[nextRxCh]);
}
startMicros = micros(); startMicros = micros();
} }
// not finished but time is over // not finished but time is over

Loading…
Cancel
Save