Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/main/blackbox/blackbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
#include "sensors/esc_sensor.h"
#include "flight/wind_estimator.h"
#include "sensors/temperature.h"

#ifdef USE_DRONECAN
#include "drivers/dronecan/dronecan.h"
#endif

#if defined(ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT)
#define DEFAULT_BLACKBOX_DEVICE BLACKBOX_DEVICE_FLASH
Expand Down Expand Up @@ -470,6 +472,9 @@ static const blackboxSimpleFieldDefinition_t blackboxSlowFields[] = {
{"escRPM", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"escTemperature", -1, SIGNED, PREDICT(PREVIOUS), ENCODING(SIGNED_VB)},
#endif
#ifdef USE_DRONECAN
{"droneCANBusOffCount", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
Comment thread
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
#endif
};

#define BLACKBOX_FIRST_HEADER_SENDING_STATE BLACKBOX_STATE_SEND_HEADER
Expand Down Expand Up @@ -579,6 +584,9 @@ typedef struct blackboxSlowState_s {
#endif
uint16_t rxUpdateRate;
uint8_t activeWpNumber;
#ifdef USE_DRONECAN
uint32_t droneCANBusOffCount;
#endif
} __attribute__((__packed__)) blackboxSlowState_t; // We pack this struct so that padding doesn't interfere with memcmp()

//From rc_controls.c
Expand Down Expand Up @@ -1365,6 +1373,10 @@ static void writeSlowFrame(void)
blackboxWriteSignedVB(slowHistory.escTemperature);
#endif

#ifdef USE_DRONECAN
blackboxWriteUnsignedVB(slowHistory.droneCANBusOffCount);
#endif

blackboxSlowFrameIterationTimer = 0;
}

Expand Down Expand Up @@ -1439,6 +1451,10 @@ static void loadSlowState(blackboxSlowState_t *slow)
slow->escRPM = escSensor->rpm;
slow->escTemperature = escSensor->temperature;
#endif

#ifdef USE_DRONECAN
slow->droneCANBusOffCount = dronecanGetBusOffCount();
#endif
}

/**
Expand Down
Loading