Skip to content

Commit

Permalink
Merge pull request iNavFlight#10068 from breadoven/abo_blackbox_move_…
Browse files Browse the repository at this point in the history
…activewp

Reorder blackbox fields
  • Loading branch information
breadoven authored May 23, 2024
2 parents 9ee93ce + 5a2b1ee commit 49008f4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main/blackbox/blackbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,15 @@ static const blackboxSimpleFieldDefinition_t blackboxGpsHFields[] = {

// Rarely-updated fields
static const blackboxSimpleFieldDefinition_t blackboxSlowFields[] = {
{"activeWpNumber", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"flightModeFlags", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"stateFlags", -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)},

{"rxUpdateRate", -1, UNSIGNED, PREDICT(PREVIOUS), ENCODING(UNSIGNED_VB)},

{"hwHealthStatus", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"powerSupplyImpedance", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"sagCompensatedVBat", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
Expand Down Expand Up @@ -436,8 +438,6 @@ static const blackboxSimpleFieldDefinition_t blackboxSlowFields[] = {
{"escRPM", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"escTemperature", -1, SIGNED, PREDICT(PREVIOUS), ENCODING(SIGNED_VB)},
#endif
{"rxUpdateRate", -1, UNSIGNED, PREDICT(PREVIOUS), ENCODING(UNSIGNED_VB)},
{"activeWpNumber", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
};

typedef enum BlackboxState {
Expand Down Expand Up @@ -1259,7 +1259,8 @@ static void writeSlowFrame(void)
int32_t values[3];

blackboxWrite('S');


blackboxWriteUnsignedVB(slowHistory.activeWpNumber);
blackboxWriteUnsignedVB(slowHistory.flightModeFlags);
blackboxWriteUnsignedVB(slowHistory.stateFlags);

Expand All @@ -1268,9 +1269,11 @@ static void writeSlowFrame(void)
*/
values[0] = slowHistory.failsafePhase;
values[1] = slowHistory.rxSignalReceived ? 1 : 0;
values[2] = slowHistory.rxFlightChannelsValid ? 1 : 0;
values[2] = slowHistory.rxFlightChannelsValid ? 1 : 0;
blackboxWriteTag2_3S32(values);

blackboxWriteUnsignedVB(slowHistory.rxUpdateRate);

blackboxWriteUnsignedVB(slowHistory.hwHealthStatus);

blackboxWriteUnsignedVB(slowHistory.powerSupplyImpedance);
Expand All @@ -1296,8 +1299,6 @@ static void writeSlowFrame(void)
blackboxWriteUnsignedVB(slowHistory.escRPM);
blackboxWriteSignedVB(slowHistory.escTemperature);
#endif
blackboxWriteUnsignedVB(slowHistory.rxUpdateRate);
blackboxWriteUnsignedVB(slowHistory.activeWpNumber);

blackboxSlowFrameIterationTimer = 0;
}
Expand All @@ -1307,6 +1308,7 @@ static void writeSlowFrame(void)
*/
static void loadSlowState(blackboxSlowState_t *slow)
{
slow->activeWpNumber = getActiveWpNumber();
memcpy(&slow->flightModeFlags, &rcModeActivationMask, sizeof(slow->flightModeFlags)); //was flightModeFlags;
// Also log Nav auto enabled flight modes rather than just those selected by boxmode
if (FLIGHT_MODE(ANGLE_MODE)) {
Expand All @@ -1328,6 +1330,7 @@ static void loadSlowState(blackboxSlowState_t *slow)
slow->failsafePhase = failsafePhase();
slow->rxSignalReceived = rxIsReceivingSignal();
slow->rxFlightChannelsValid = rxAreFlightChannelsValid();
slow->rxUpdateRate = getRcUpdateFrequency();
slow->hwHealthStatus = (getHwGyroStatus() << 2 * 0) | // Pack hardware health status into a bit field.
(getHwAccelerometerStatus() << 2 * 1) | // Use raw hardwareSensorStatus_e values and pack them using 2 bits per value
(getHwCompassStatus() << 2 * 2) | // Report GYRO in 2 lowest bits, then ACC, COMPASS, BARO, GPS, RANGEFINDER and PITOT
Expand Down Expand Up @@ -1379,9 +1382,6 @@ static void loadSlowState(blackboxSlowState_t *slow)
slow->escRPM = escSensor->rpm;
slow->escTemperature = escSensor->temperature;
#endif

slow->rxUpdateRate = getRcUpdateFrequency();
slow->activeWpNumber = getActiveWpNumber();
}

/**
Expand Down

0 comments on commit 49008f4

Please sign in to comment.