|
@ -36,7 +36,7 @@ class Communication : public CommQueue<> { |
|
|
|
|
|
|
|
|
void addImportant(Inverter<> *iv, uint8_t cmd) { |
|
|
void addImportant(Inverter<> *iv, uint8_t cmd) { |
|
|
if(!mIsDevControl) // only reset communication once there is no other devcontrol command
|
|
|
if(!mIsDevControl) // only reset communication once there is no other devcontrol command
|
|
|
mState = States::RESET; // cancel current operation
|
|
|
mState = States::IDLE; // cancel current operation
|
|
|
mIsDevControl = true; |
|
|
mIsDevControl = true; |
|
|
CommQueue::addImportant(iv, cmd); |
|
|
CommQueue::addImportant(iv, cmd); |
|
|
} |
|
|
} |
|
@ -54,7 +54,7 @@ class Communication : public CommQueue<> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void loop() { |
|
|
void loop() { |
|
|
if(States::RESET == mState) { |
|
|
if(States::IDLE == mState) { |
|
|
get([this](bool valid, QueueElement *q) { |
|
|
get([this](bool valid, QueueElement *q) { |
|
|
if(!valid) { |
|
|
if(!valid) { |
|
|
if(mPrintSequenceDuration) { |
|
|
if(mPrintSequenceDuration) { |
|
@ -63,12 +63,12 @@ class Communication : public CommQueue<> { |
|
|
DBGPRINT(String(millis() - mLastEmptyQueueMillis)); |
|
|
DBGPRINT(String(millis() - mLastEmptyQueueMillis)); |
|
|
DBGPRINTLN(F("ms")); |
|
|
DBGPRINTLN(F("ms")); |
|
|
DBGPRINTLN(F("-----")); |
|
|
DBGPRINTLN(F("-----")); |
|
|
el.iv = nullptr; |
|
|
|
|
|
} |
|
|
} |
|
|
return; // empty
|
|
|
return; // empty
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
el = *q; |
|
|
el = std::move(*q); |
|
|
|
|
|
mState = States::INIT; |
|
|
if(!mPrintSequenceDuration) // entry was added to the queue
|
|
|
if(!mPrintSequenceDuration) // entry was added to the queue
|
|
|
mLastEmptyQueueMillis = millis(); |
|
|
mLastEmptyQueueMillis = millis(); |
|
|
mPrintSequenceDuration = true; |
|
|
mPrintSequenceDuration = true; |
|
@ -82,7 +82,11 @@ class Communication : public CommQueue<> { |
|
|
private: |
|
|
private: |
|
|
inline void innerLoop(QueueElement *q) { |
|
|
inline void innerLoop(QueueElement *q) { |
|
|
switch(mState) { |
|
|
switch(mState) { |
|
|
case States::RESET: |
|
|
default: |
|
|
|
|
|
case States::IDLE: |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case States::INIT: |
|
|
if (!mWaitTime.isTimeout()) |
|
|
if (!mWaitTime.isTimeout()) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
@ -110,7 +114,8 @@ class Communication : public CommQueue<> { |
|
|
if((q->iv->ivGen == IV_MI) && ((q->cmd == MI_REQ_CH1) || (q->cmd == MI_REQ_4CH))) |
|
|
if((q->iv->ivGen == IV_MI) && ((q->cmd == MI_REQ_CH1) || (q->cmd == MI_REQ_4CH))) |
|
|
q->incrAttempt(q->iv->channels); // 2 more attempts for 2ch, 4 more for 4ch
|
|
|
q->incrAttempt(q->iv->channels); // 2 more attempts for 2ch, 4 more for 4ch
|
|
|
|
|
|
|
|
|
mState = (NULL == q->iv->radio) ? States::RESET : States::START; |
|
|
if(NULL != q->iv->radio) |
|
|
|
|
|
mState = States::START; |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case States::START: |
|
|
case States::START: |
|
@ -293,7 +298,7 @@ class Communication : public CommQueue<> { |
|
|
q->iv->radioStatistics.txCnt--; |
|
|
q->iv->radioStatistics.txCnt--; |
|
|
q->iv->radioStatistics.retransmits++; |
|
|
q->iv->radioStatistics.retransmits++; |
|
|
mCompleteRetry = true; |
|
|
mCompleteRetry = true; |
|
|
mState = States::RESET; |
|
|
mState = States::IDLE; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -537,7 +542,7 @@ class Communication : public CommQueue<> { |
|
|
} else |
|
|
} else |
|
|
DBGPRINTLN(F("-> complete retransmit")); |
|
|
DBGPRINTLN(F("-> complete retransmit")); |
|
|
mCompleteRetry = true; |
|
|
mCompleteRetry = true; |
|
|
mState = States::RESET; |
|
|
mState = States::IDLE; |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -650,7 +655,7 @@ class Communication : public CommQueue<> { |
|
|
q->iv->miMultiParts = 0; |
|
|
q->iv->miMultiParts = 0; |
|
|
mIsRetransmit = false; |
|
|
mIsRetransmit = false; |
|
|
mCompleteRetry = false; |
|
|
mCompleteRetry = false; |
|
|
mState = States::RESET; |
|
|
mState = States::IDLE; |
|
|
DBGPRINTLN(F("-----")); |
|
|
DBGPRINTLN(F("-----")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -797,7 +802,7 @@ class Communication : public CommQueue<> { |
|
|
inline void miDataDecode(packet_t *p, QueueElement *q) { |
|
|
inline void miDataDecode(packet_t *p, QueueElement *q) { |
|
|
record_t<> *rec = q->iv->getRecordStruct(RealTimeRunData_Debug); // choose the parser
|
|
|
record_t<> *rec = q->iv->getRecordStruct(RealTimeRunData_Debug); // choose the parser
|
|
|
rec->ts = q->ts; |
|
|
rec->ts = q->ts; |
|
|
//mState = States::RESET;
|
|
|
//mState = States::IDLE;
|
|
|
if(q->iv->miMultiParts < 6) |
|
|
if(q->iv->miMultiParts < 6) |
|
|
q->iv->miMultiParts += 6; |
|
|
q->iv->miMultiParts += 6; |
|
|
|
|
|
|
|
@ -1031,7 +1036,7 @@ class Communication : public CommQueue<> { |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
enum class States : uint8_t { |
|
|
enum class States : uint8_t { |
|
|
RESET, START, WAIT, CHECK_FRAMES, CHECK_PACKAGE |
|
|
IDLE, INIT, START, WAIT, CHECK_FRAMES, CHECK_PACKAGE |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
typedef struct { |
|
|
typedef struct { |
|
@ -1041,7 +1046,7 @@ class Communication : public CommQueue<> { |
|
|
} frame_t; |
|
|
} frame_t; |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
States mState = States::RESET; |
|
|
States mState = States::IDLE; |
|
|
uint32_t *mTimestamp = nullptr; |
|
|
uint32_t *mTimestamp = nullptr; |
|
|
QueueElement el; |
|
|
QueueElement el; |
|
|
bool *mPrivacyMode = nullptr, *mSerialDebug = nullptr, *mPrintWholeTrace = nullptr; |
|
|
bool *mPrivacyMode = nullptr, *mSerialDebug = nullptr, *mPrintWholeTrace = nullptr; |
|
|