diff --git a/src/main/build/debug.c b/src/main/build/debug.c index 417b7f2a8e..1a752db76c 100644 --- a/src/main/build/debug.c +++ b/src/main/build/debug.c @@ -98,4 +98,5 @@ const char * const debugModeNames[DEBUG_COUNT] = { "RX_TIMING", "D_LPF", "VTX_TRAMP", + "GHST", }; diff --git a/src/main/build/debug.h b/src/main/build/debug.h index b240619371..285977efb4 100644 --- a/src/main/build/debug.h +++ b/src/main/build/debug.h @@ -114,6 +114,7 @@ typedef enum { DEBUG_RX_TIMING, DEBUG_D_LPF, DEBUG_VTX_TRAMP, + DEBUG_GHST, DEBUG_COUNT } debugType_e; diff --git a/src/main/rx/ghst.c b/src/main/rx/ghst.c index c8108ada76..0ac6a968ae 100644 --- a/src/main/rx/ghst.c +++ b/src/main/rx/ghst.c @@ -74,6 +74,13 @@ STATIC_UNIT_TESTED ghstFrame_t ghstValidatedFrame; // validated frame, CRC is o STATIC_UNIT_TESTED uint32_t ghstChannelData[GHST_MAX_NUM_CHANNELS]; +enum { + DEBUG_GHST_CRC_ERRORS = 0, + DEBUG_GHST_UNKNOWN_FRAMES, + DEBUG_GHST_RX_RSSI, + DEBUG_GHST_RX_LQ, +}; + static serialPort_t *serialPort; static timeUs_t ghstRxFrameStartAtUs = 0; static timeUs_t ghstRxFrameEndAtUs = 0; @@ -180,6 +187,7 @@ static bool shouldSendTelemetryFrame(void) STATIC_UNIT_TESTED uint8_t ghstFrameStatus(rxRuntimeState_t *rxRuntimeState) { UNUSED(rxRuntimeState); + static int16_t crcErrorCount = 0; if (ghstFrameAvailable) { ghstFrameAvailable = false; @@ -191,6 +199,10 @@ STATIC_UNIT_TESTED uint8_t ghstFrameStatus(rxRuntimeState_t *rxRuntimeState) return RX_FRAME_COMPLETE | RX_FRAME_PROCESSING_REQUIRED; // request callback through ghstProcessFrame to do the decoding work } + if (crc != ghstValidatedFrame.bytes[fullFrameLength - 1]) { + DEBUG_SET(DEBUG_GHST, DEBUG_GHST_CRC_ERRORS, ++crcErrorCount); + } + return RX_FRAME_DROPPED; // frame was invalid } @@ -208,6 +220,8 @@ static bool ghstProcessFrame(const rxRuntimeState_t *rxRuntimeState) UNUSED(rxRuntimeState); + static int16_t unknownFrameCount = 0; + // do we have a telemetry buffer to send? if (shouldSendTelemetryFrame()) { ghstTransmittingTelemetry = true; @@ -231,6 +245,9 @@ static bool ghstProcessFrame(const rxRuntimeState_t *rxRuntimeState) case GHST_UL_RC_CHANS_HS4_RSSI: { const ghstPayloadPulsesRssi_t* const rssiFrame = (ghstPayloadPulsesRssi_t*)&ghstValidatedFrame.frame.payload; + DEBUG_SET(DEBUG_GHST, DEBUG_GHST_RX_RSSI, -rssiFrame->rssi); + DEBUG_SET(DEBUG_GHST, DEBUG_GHST_RX_LQ, rssiFrame->lq); + if (rssiSource == RSSI_SOURCE_RX_PROTOCOL) { // rssi sent sign-inverted const uint16_t rssiPercentScaled = scaleRange(-rssiFrame->rssi, GHST_RSSI_DBM_MIN, 0, GHST_RSSI_DBM_MAX, RSSI_MAX_VALUE); @@ -252,6 +269,9 @@ static bool ghstProcessFrame(const rxRuntimeState_t *rxRuntimeState) case GHST_UL_RC_CHANS_HS4_5TO8: startIdx = 4; break; case GHST_UL_RC_CHANS_HS4_9TO12: startIdx = 8; break; case GHST_UL_RC_CHANS_HS4_13TO16: startIdx = 12; break; + default: + DEBUG_SET(DEBUG_GHST, DEBUG_GHST_UNKNOWN_FRAMES, ++unknownFrameCount); + break; } if (startIdx > 0)