diff --git a/src/main/telemetry/smartport.c b/src/main/telemetry/smartport.c index cdcd21e571..091946019f 100644 --- a/src/main/telemetry/smartport.c +++ b/src/main/telemetry/smartport.c @@ -374,14 +374,6 @@ void checkSmartPortTelemetryState(void) freeSmartPortTelemetryPort(); } -static void resetMspPacket(mspPacket_t* packet) -{ - packet->buf.ptr = NULL; - packet->buf.end = NULL; - packet->cmd = -1; - packet->result = 0; -} - static void initSmartPortMspReply(int16_t cmd) { smartPortMspReply.buf.ptr = smartPortMspTxBuffer; @@ -544,7 +536,7 @@ void handleSmartPortMspFrame(smartPortFrame_t* sp_frame) } else if (((lastSeq + 1) & SMARTPORT_MSP_SEQ_MASK) != seq) { // packet loss detected! - resetMspPacket(&cmd); + mspStarted = 0; return; } diff --git a/src/test/SpMsp.lua b/src/test/SpMsp.lua index 07ceff1993..056fc9ea8e 100644 --- a/src/test/SpMsp.lua +++ b/src/test/SpMsp.lua @@ -71,7 +71,7 @@ local function mspReceivedReply(payload) -- return error -- CRC checking missing - --return bit32.band(payload[idx],0xFF) + --return payload[idx] return nil end @@ -93,8 +93,10 @@ local function mspReceivedReply(payload) elseif not mspStarted then mspReceivedReply_cnt3 = mspReceivedReply_cnt3 + 1 return nil - -- TODO: add sequence number checking - -- elseif ... + + elseif bit32.band(lastSeq+1,0x0F) ~= seq then + mspStarted = false + return nil end while (idx <= 6) and (mspRxIdx <= mspRxSize) do