close #1
This commit is contained in:
10
crossbow.ino
10
crossbow.ino
@@ -307,6 +307,16 @@ void loop(void)
|
||||
uint32_t currentMillis = millis();
|
||||
bool transmitPayload = false;
|
||||
|
||||
/*
|
||||
* Watchdog for frame decoding stuck somewhere in the middle of a process
|
||||
*/
|
||||
if (
|
||||
qsp.protocolState != QSP_STATE_IDLE &&
|
||||
abs(millis() - qsp.frameDecodingStartedAt) > QSP_MAX_FRAME_DECODE_TIME
|
||||
) {
|
||||
qsp.protocolState = QSP_STATE_IDLE;
|
||||
}
|
||||
|
||||
if (
|
||||
qsp.forcePongFrame &&
|
||||
!transmitPayload &&
|
||||
|
||||
1
qsp.cpp
1
qsp.cpp
@@ -154,6 +154,7 @@ void qspDecodeIncomingFrame(QspConfiguration_t *qsp, uint8_t incomingByte, int p
|
||||
//If in IDLE and correct preamble comes, start to decode frame
|
||||
qsp->protocolState = QSP_STATE_PREAMBLE_RECEIVED;
|
||||
qsp->crc = 0 ^ incomingByte;
|
||||
qsp->frameDecodingStartedAt = millis();
|
||||
}
|
||||
else if (qsp->protocolState == QSP_STATE_PREAMBLE_RECEIVED)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#define QSP_PREAMBLE 0x51
|
||||
#define QSP_PAYLOAD_LENGTH 32
|
||||
|
||||
#define QSP_MAX_FRAME_DECODE_TIME 50 //max time that frame can be decoded in ms
|
||||
|
||||
#define QSP_FRAME_RC_DATA 0x0
|
||||
#define QSP_FRAME_RX_HEALTH 0x1
|
||||
#define QSP_FRAME_GET_RX_CONFIG 0x2
|
||||
@@ -72,6 +74,7 @@ struct QspConfiguration_t {
|
||||
bool canTransmit = false;
|
||||
bool forcePongFrame = false;
|
||||
uint8_t debugConfig = 0;
|
||||
uint32_t frameDecodingStartedAt = 0;
|
||||
};
|
||||
|
||||
struct RxDeviceState_t {
|
||||
|
||||
Reference in New Issue
Block a user