1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 20:10:18 +03:00

Merge pull request #10389 from ImmersionRC/irc-ghst-driver-debug

This commit is contained in:
Michael Keller 2020-12-16 01:05:54 +01:00 committed by GitHub
commit d89a5c8713
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View file

@ -98,4 +98,5 @@ const char * const debugModeNames[DEBUG_COUNT] = {
"RX_TIMING",
"D_LPF",
"VTX_TRAMP",
"GHST",
};

View file

@ -114,6 +114,7 @@ typedef enum {
DEBUG_RX_TIMING,
DEBUG_D_LPF,
DEBUG_VTX_TRAMP,
DEBUG_GHST,
DEBUG_COUNT
} debugType_e;

View file

@ -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)