mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
frsky-spi-D16 was counting every telemetry state as a good packet. If it was garbage packet it would go straight into the rcData
Add some debugging
This commit is contained in:
parent
26a4f762a1
commit
a86e0bc41c
7 changed files with 38 additions and 14 deletions
|
@ -50,6 +50,7 @@ const char * const debugModeNames[DEBUG_COUNT] = {
|
|||
"FFT_TIME",
|
||||
"FFT_FREQ",
|
||||
"RX_FRSKY_SPI",
|
||||
"RX_SIGNAL_LOSS",
|
||||
"GYRO_RAW",
|
||||
"DUAL_GYRO",
|
||||
"DUAL_GYRO_RAW",
|
||||
|
|
|
@ -68,6 +68,7 @@ typedef enum {
|
|||
DEBUG_FFT_TIME,
|
||||
DEBUG_FFT_FREQ,
|
||||
DEBUG_RX_FRSKY_SPI,
|
||||
DEBUG_RX_SIGNAL_LOSS,
|
||||
DEBUG_GYRO_RAW,
|
||||
DEBUG_DUAL_GYRO,
|
||||
DEBUG_DUAL_GYRO_RAW,
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#define MAX_MISSING_PKT 100
|
||||
|
||||
#define DEBUG_DATA_ERROR_COUNT 0
|
||||
#define DEBUG_DATA_MISSING_PACKETS 1
|
||||
#define DEBUG_DATA_BAD_FRAME 2
|
||||
|
||||
|
||||
#define SYNC_DELAY_MAX 9000
|
||||
|
||||
|
|
|
@ -270,6 +270,7 @@ static void frSkyXTelemetryWriteFrame(const smartPortPayload_t *payload)
|
|||
|
||||
void frSkyXSetRcData(uint16_t *rcData, const uint8_t *packet)
|
||||
{
|
||||
static uint32_t rangeErrors = 0;
|
||||
uint16_t c[8];
|
||||
|
||||
c[0] = (uint16_t)((packet[10] << 8) & 0xF00) | packet[9];
|
||||
|
@ -289,9 +290,17 @@ void frSkyXSetRcData(uint16_t *rcData, const uint8_t *packet)
|
|||
} else {
|
||||
j = 0;
|
||||
}
|
||||
if (c[i] == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int16_t temp = (((c[i] - 64) << 1) / 3 + 860);
|
||||
if ((temp > 800) && (temp < 2200)) {
|
||||
rcData[i+j] = temp;
|
||||
} else {
|
||||
rangeErrors++;
|
||||
DEBUG_SET(DEBUG_RX_FRSKY_SPI, DEBUG_DATA_ERROR_COUNT, rangeErrors);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +322,7 @@ rx_spi_received_e frSkyXHandlePacket(uint8_t * const packet, uint8_t * const pro
|
|||
static bool frameReceived;
|
||||
static timeDelta_t receiveDelayUs;
|
||||
static uint8_t channelsToSkip = 1;
|
||||
|
||||
static uint32_t packetErrors = 0;
|
||||
static telemetryBuffer_t telemetryRxBuffer[TELEMETRY_SEQUENCE_LENGTH];
|
||||
|
||||
#if defined(USE_RX_FRSKY_SPI_TELEMETRY)
|
||||
|
@ -433,6 +442,11 @@ rx_spi_received_e frSkyXHandlePacket(uint8_t * const packet, uint8_t * const pro
|
|||
frameReceived = true; // no need to process frame again.
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!frameReceived)
|
||||
{
|
||||
packetErrors++;
|
||||
DEBUG_SET(DEBUG_RX_FRSKY_SPI, DEBUG_DATA_BAD_FRAME, packetErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -499,8 +513,10 @@ rx_spi_received_e frSkyXHandlePacket(uint8_t * const packet, uint8_t * const pro
|
|||
processSmartPortTelemetry(payload, &clearToSend, NULL);
|
||||
}
|
||||
#endif
|
||||
if (frameReceived == true) {
|
||||
ret = RX_SPI_RECEIVED_DATA;
|
||||
}
|
||||
*protocolState = STATE_RESUME;
|
||||
ret = RX_SPI_RECEIVED_DATA;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -528,6 +544,8 @@ rx_spi_received_e frSkyXHandlePacket(uint8_t * const packet, uint8_t * const pro
|
|||
break;
|
||||
}
|
||||
missingPackets++;
|
||||
DEBUG_SET(DEBUG_RX_FRSKY_SPI, DEBUG_DATA_MISSING_PACKETS, missingPackets);
|
||||
|
||||
*protocolState = STATE_DATA;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -68,8 +68,6 @@
|
|||
#include "rx/targetcustomserial.h"
|
||||
|
||||
|
||||
//#define DEBUG_RX_SIGNAL_LOSS
|
||||
|
||||
const char rcChannelLetters[] = "AERT12345678abcdefgh";
|
||||
|
||||
static uint16_t rssi = 0; // range: [0;1023]
|
||||
|
@ -85,6 +83,7 @@ rssiSource_e rssiSource;
|
|||
static bool rxDataProcessingRequired = false;
|
||||
static bool auxiliaryProcessingRequired = false;
|
||||
|
||||
static uint32_t rxMissedPackets = 0;
|
||||
static bool rxSignalReceived = false;
|
||||
static bool rxFlightChannelsValid = false;
|
||||
static bool rxIsInFailsafeMode = true;
|
||||
|
@ -391,6 +390,8 @@ bool rxUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTime)
|
|||
rxSignalReceived = true;
|
||||
} else if (currentTimeUs >= needRxSignalBefore) {
|
||||
rxSignalReceived = false;
|
||||
rxMissedPackets++;
|
||||
needRxSignalBefore = currentTimeUs + needRxSignalMaxDelayUs;
|
||||
}
|
||||
|
||||
if ((signalReceived && useDataDrivenProcessing) || cmpTimeUs(currentTimeUs, rxNextUpdateAtUs) > 0) {
|
||||
|
@ -492,11 +493,9 @@ static void detectAndApplySignalLossBehaviour(void)
|
|||
|
||||
const bool useValueFromRx = rxSignalReceived && !rxIsInFailsafeMode;
|
||||
|
||||
#ifdef DEBUG_RX_SIGNAL_LOSS
|
||||
debug[0] = rxSignalReceived;
|
||||
debug[1] = rxIsInFailsafeMode;
|
||||
debug[2] = rxRuntimeConfig.rcReadRawFn(&rxRuntimeConfig, 0);
|
||||
#endif
|
||||
DEBUG_SET(DEBUG_RX_SIGNAL_LOSS, 0, rxSignalReceived);
|
||||
DEBUG_SET(DEBUG_RX_SIGNAL_LOSS, 1, rxIsInFailsafeMode);
|
||||
DEBUG_SET(DEBUG_RX_SIGNAL_LOSS, 2, rxMissedPackets);
|
||||
|
||||
rxFlightChannelsValid = true;
|
||||
for (int channel = 0; channel < rxChannelCount; channel++) {
|
||||
|
@ -533,10 +532,7 @@ static void detectAndApplySignalLossBehaviour(void)
|
|||
rcData[channel] = getRxfailValue(channel);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_RX_SIGNAL_LOSS
|
||||
debug[3] = rcData[THROTTLE];
|
||||
#endif
|
||||
DEBUG_SET(DEBUG_RX_SIGNAL_LOSS, 3, rcData[THROTTLE]);
|
||||
}
|
||||
|
||||
bool calculateRxChannelsAndUpdateFailsafe(timeUs_t currentTimeUs)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
extern "C" {
|
||||
#include "platform.h"
|
||||
|
||||
#include "build/debug.h"
|
||||
#include "drivers/io.h"
|
||||
#include "common/maths.h"
|
||||
#include "pg/pg.h"
|
||||
|
@ -38,6 +38,8 @@ extern "C" {
|
|||
|
||||
extern "C" {
|
||||
boxBitmask_t rcModeActivationMask;
|
||||
int16_t debug[DEBUG16_VALUE_COUNT];
|
||||
uint8_t debugMode = 0;
|
||||
|
||||
extern uint16_t applyRxChannelRangeConfiguraton(int sample, const rxChannelRangeConfig_t *range);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ extern "C" {
|
|||
#include "platform.h"
|
||||
|
||||
#include "pg/rx.h"
|
||||
#include "build/debug.h"
|
||||
#include "drivers/io.h"
|
||||
#include "rx/rx.h"
|
||||
#include "fc/rc_modes.h"
|
||||
|
@ -35,6 +36,8 @@ extern "C" {
|
|||
#include "io/beeper.h"
|
||||
|
||||
boxBitmask_t rcModeActivationMask;
|
||||
int16_t debug[DEBUG16_VALUE_COUNT];
|
||||
uint8_t debugMode = 0;
|
||||
|
||||
bool isPulseValid(uint16_t pulseDuration);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue