mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +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_TIME",
|
||||||
"FFT_FREQ",
|
"FFT_FREQ",
|
||||||
"RX_FRSKY_SPI",
|
"RX_FRSKY_SPI",
|
||||||
|
"RX_SIGNAL_LOSS",
|
||||||
"GYRO_RAW",
|
"GYRO_RAW",
|
||||||
"DUAL_GYRO",
|
"DUAL_GYRO",
|
||||||
"DUAL_GYRO_RAW",
|
"DUAL_GYRO_RAW",
|
||||||
|
|
|
@ -68,6 +68,7 @@ typedef enum {
|
||||||
DEBUG_FFT_TIME,
|
DEBUG_FFT_TIME,
|
||||||
DEBUG_FFT_FREQ,
|
DEBUG_FFT_FREQ,
|
||||||
DEBUG_RX_FRSKY_SPI,
|
DEBUG_RX_FRSKY_SPI,
|
||||||
|
DEBUG_RX_SIGNAL_LOSS,
|
||||||
DEBUG_GYRO_RAW,
|
DEBUG_GYRO_RAW,
|
||||||
DEBUG_DUAL_GYRO,
|
DEBUG_DUAL_GYRO,
|
||||||
DEBUG_DUAL_GYRO_RAW,
|
DEBUG_DUAL_GYRO_RAW,
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
#define MAX_MISSING_PKT 100
|
#define MAX_MISSING_PKT 100
|
||||||
|
|
||||||
#define DEBUG_DATA_ERROR_COUNT 0
|
#define DEBUG_DATA_ERROR_COUNT 0
|
||||||
|
#define DEBUG_DATA_MISSING_PACKETS 1
|
||||||
|
#define DEBUG_DATA_BAD_FRAME 2
|
||||||
|
|
||||||
|
|
||||||
#define SYNC_DELAY_MAX 9000
|
#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)
|
void frSkyXSetRcData(uint16_t *rcData, const uint8_t *packet)
|
||||||
{
|
{
|
||||||
|
static uint32_t rangeErrors = 0;
|
||||||
uint16_t c[8];
|
uint16_t c[8];
|
||||||
|
|
||||||
c[0] = (uint16_t)((packet[10] << 8) & 0xF00) | packet[9];
|
c[0] = (uint16_t)((packet[10] << 8) & 0xF00) | packet[9];
|
||||||
|
@ -289,9 +290,17 @@ void frSkyXSetRcData(uint16_t *rcData, const uint8_t *packet)
|
||||||
} else {
|
} else {
|
||||||
j = 0;
|
j = 0;
|
||||||
}
|
}
|
||||||
|
if (c[i] == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int16_t temp = (((c[i] - 64) << 1) / 3 + 860);
|
int16_t temp = (((c[i] - 64) << 1) / 3 + 860);
|
||||||
if ((temp > 800) && (temp < 2200)) {
|
if ((temp > 800) && (temp < 2200)) {
|
||||||
rcData[i+j] = temp;
|
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 bool frameReceived;
|
||||||
static timeDelta_t receiveDelayUs;
|
static timeDelta_t receiveDelayUs;
|
||||||
static uint8_t channelsToSkip = 1;
|
static uint8_t channelsToSkip = 1;
|
||||||
|
static uint32_t packetErrors = 0;
|
||||||
static telemetryBuffer_t telemetryRxBuffer[TELEMETRY_SEQUENCE_LENGTH];
|
static telemetryBuffer_t telemetryRxBuffer[TELEMETRY_SEQUENCE_LENGTH];
|
||||||
|
|
||||||
#if defined(USE_RX_FRSKY_SPI_TELEMETRY)
|
#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.
|
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);
|
processSmartPortTelemetry(payload, &clearToSend, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (frameReceived == true) {
|
||||||
|
ret = RX_SPI_RECEIVED_DATA;
|
||||||
|
}
|
||||||
*protocolState = STATE_RESUME;
|
*protocolState = STATE_RESUME;
|
||||||
ret = RX_SPI_RECEIVED_DATA;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -528,6 +544,8 @@ rx_spi_received_e frSkyXHandlePacket(uint8_t * const packet, uint8_t * const pro
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
missingPackets++;
|
missingPackets++;
|
||||||
|
DEBUG_SET(DEBUG_RX_FRSKY_SPI, DEBUG_DATA_MISSING_PACKETS, missingPackets);
|
||||||
|
|
||||||
*protocolState = STATE_DATA;
|
*protocolState = STATE_DATA;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -68,8 +68,6 @@
|
||||||
#include "rx/targetcustomserial.h"
|
#include "rx/targetcustomserial.h"
|
||||||
|
|
||||||
|
|
||||||
//#define DEBUG_RX_SIGNAL_LOSS
|
|
||||||
|
|
||||||
const char rcChannelLetters[] = "AERT12345678abcdefgh";
|
const char rcChannelLetters[] = "AERT12345678abcdefgh";
|
||||||
|
|
||||||
static uint16_t rssi = 0; // range: [0;1023]
|
static uint16_t rssi = 0; // range: [0;1023]
|
||||||
|
@ -85,6 +83,7 @@ rssiSource_e rssiSource;
|
||||||
static bool rxDataProcessingRequired = false;
|
static bool rxDataProcessingRequired = false;
|
||||||
static bool auxiliaryProcessingRequired = false;
|
static bool auxiliaryProcessingRequired = false;
|
||||||
|
|
||||||
|
static uint32_t rxMissedPackets = 0;
|
||||||
static bool rxSignalReceived = false;
|
static bool rxSignalReceived = false;
|
||||||
static bool rxFlightChannelsValid = false;
|
static bool rxFlightChannelsValid = false;
|
||||||
static bool rxIsInFailsafeMode = true;
|
static bool rxIsInFailsafeMode = true;
|
||||||
|
@ -391,6 +390,8 @@ bool rxUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTime)
|
||||||
rxSignalReceived = true;
|
rxSignalReceived = true;
|
||||||
} else if (currentTimeUs >= needRxSignalBefore) {
|
} else if (currentTimeUs >= needRxSignalBefore) {
|
||||||
rxSignalReceived = false;
|
rxSignalReceived = false;
|
||||||
|
rxMissedPackets++;
|
||||||
|
needRxSignalBefore = currentTimeUs + needRxSignalMaxDelayUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((signalReceived && useDataDrivenProcessing) || cmpTimeUs(currentTimeUs, rxNextUpdateAtUs) > 0) {
|
if ((signalReceived && useDataDrivenProcessing) || cmpTimeUs(currentTimeUs, rxNextUpdateAtUs) > 0) {
|
||||||
|
@ -492,11 +493,9 @@ static void detectAndApplySignalLossBehaviour(void)
|
||||||
|
|
||||||
const bool useValueFromRx = rxSignalReceived && !rxIsInFailsafeMode;
|
const bool useValueFromRx = rxSignalReceived && !rxIsInFailsafeMode;
|
||||||
|
|
||||||
#ifdef DEBUG_RX_SIGNAL_LOSS
|
DEBUG_SET(DEBUG_RX_SIGNAL_LOSS, 0, rxSignalReceived);
|
||||||
debug[0] = rxSignalReceived;
|
DEBUG_SET(DEBUG_RX_SIGNAL_LOSS, 1, rxIsInFailsafeMode);
|
||||||
debug[1] = rxIsInFailsafeMode;
|
DEBUG_SET(DEBUG_RX_SIGNAL_LOSS, 2, rxMissedPackets);
|
||||||
debug[2] = rxRuntimeConfig.rcReadRawFn(&rxRuntimeConfig, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rxFlightChannelsValid = true;
|
rxFlightChannelsValid = true;
|
||||||
for (int channel = 0; channel < rxChannelCount; channel++) {
|
for (int channel = 0; channel < rxChannelCount; channel++) {
|
||||||
|
@ -533,10 +532,7 @@ static void detectAndApplySignalLossBehaviour(void)
|
||||||
rcData[channel] = getRxfailValue(channel);
|
rcData[channel] = getRxfailValue(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DEBUG_SET(DEBUG_RX_SIGNAL_LOSS, 3, rcData[THROTTLE]);
|
||||||
#ifdef DEBUG_RX_SIGNAL_LOSS
|
|
||||||
debug[3] = rcData[THROTTLE];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool calculateRxChannelsAndUpdateFailsafe(timeUs_t currentTimeUs)
|
bool calculateRxChannelsAndUpdateFailsafe(timeUs_t currentTimeUs)
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "build/debug.h"
|
||||||
#include "drivers/io.h"
|
#include "drivers/io.h"
|
||||||
#include "common/maths.h"
|
#include "common/maths.h"
|
||||||
#include "pg/pg.h"
|
#include "pg/pg.h"
|
||||||
|
@ -38,6 +38,8 @@ extern "C" {
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
boxBitmask_t rcModeActivationMask;
|
boxBitmask_t rcModeActivationMask;
|
||||||
|
int16_t debug[DEBUG16_VALUE_COUNT];
|
||||||
|
uint8_t debugMode = 0;
|
||||||
|
|
||||||
extern uint16_t applyRxChannelRangeConfiguraton(int sample, const rxChannelRangeConfig_t *range);
|
extern uint16_t applyRxChannelRangeConfiguraton(int sample, const rxChannelRangeConfig_t *range);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ extern "C" {
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
#include "pg/rx.h"
|
#include "pg/rx.h"
|
||||||
|
#include "build/debug.h"
|
||||||
#include "drivers/io.h"
|
#include "drivers/io.h"
|
||||||
#include "rx/rx.h"
|
#include "rx/rx.h"
|
||||||
#include "fc/rc_modes.h"
|
#include "fc/rc_modes.h"
|
||||||
|
@ -35,6 +36,8 @@ extern "C" {
|
||||||
#include "io/beeper.h"
|
#include "io/beeper.h"
|
||||||
|
|
||||||
boxBitmask_t rcModeActivationMask;
|
boxBitmask_t rcModeActivationMask;
|
||||||
|
int16_t debug[DEBUG16_VALUE_COUNT];
|
||||||
|
uint8_t debugMode = 0;
|
||||||
|
|
||||||
bool isPulseValid(uint16_t pulseDuration);
|
bool isPulseValid(uint16_t pulseDuration);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue