1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 00:35:39 +03:00

Add Blackbox logging of rx loss state flags

Closes #1266
This commit is contained in:
Nicholas Sherlock 2015-08-28 17:26:45 +12:00
parent c49bd407bf
commit b6a75cb3f1
2 changed files with 25 additions and 7 deletions

View file

@ -244,7 +244,10 @@ static const blackboxSimpleFieldDefinition_t blackboxGpsHFields[] = {
static const blackboxSimpleFieldDefinition_t blackboxSlowFields[] = {
{"flightModeFlags", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"stateFlags", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"failsafePhase", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)}
{"failsafePhase", -1, UNSIGNED, PREDICT(0), ENCODING(TAG2_3S32)},
{"rxSignalReceived", -1, UNSIGNED, PREDICT(0), ENCODING(TAG2_3S32)},
{"rxFlightChannelsValid", -1, UNSIGNED, PREDICT(0), ENCODING(TAG2_3S32)}
};
typedef enum BlackboxState {
@ -297,6 +300,8 @@ typedef struct blackboxSlowState_t {
uint16_t flightModeFlags;
uint8_t stateFlags;
uint8_t failsafePhase;
bool rxSignalReceived;
bool rxFlightChannelsValid;
} __attribute__((__packed__)) blackboxSlowState_t; // We pack this struct so that padding doesn't interfere with memcmp()
//From mixer.c:
@ -307,6 +312,8 @@ extern uint32_t currentTime;
//From rx.c:
extern uint16_t rssi;
bool rxSignalReceived;
bool rxFlightChannelsValid;
static BlackboxState blackboxState = BLACKBOX_STATE_DISABLED;
@ -679,11 +686,20 @@ static void writeInterframe(void)
* infrequently, delta updates are not reasonable, so we log independent frames. */
static void writeSlowFrame(void)
{
int32_t values[3];
blackboxWrite('S');
blackboxWriteUnsignedVB(slowHistory.flightModeFlags);
blackboxWriteUnsignedVB(slowHistory.stateFlags);
blackboxWriteUnsignedVB(slowHistory.failsafePhase);
/*
* Most of the time these three values will be able to pack into one byte for us:
*/
values[0] = slowHistory.failsafePhase;
values[1] = slowHistory.rxSignalReceived ? 1 : 0;
values[2] = slowHistory.rxFlightChannelsValid ? 1 : 0;
blackboxWriteTag2_3S32(values);
blackboxSlowFrameIterationTimer = 0;
}
@ -696,6 +712,8 @@ static void loadSlowState(blackboxSlowState_t *slow)
slow->flightModeFlags = flightModeFlags;
slow->stateFlags = stateFlags;
slow->failsafePhase = failsafePhase();
slow->rxSignalReceived = rxSignalReceived;
slow->rxFlightChannelsValid = rxFlightChannelsValid;
}
/**

View file

@ -66,8 +66,8 @@ const char rcChannelLetters[] = "AERT12345678abcdefgh";
uint16_t rssi = 0; // range: [0;1023]
static bool rxDataReceived = false;
static bool rxSignalReceived = false;
static bool rxFlightChannelsValid = false;
bool rxSignalReceived = false;
bool rxFlightChannelsValid = false;
static uint32_t rxUpdateAt = 0;
static uint32_t needRxSignalBefore = 0;