Skip to content

Commit

Permalink
Merge pull request #4302 from iNavFlight/jh_extend_bbl_logging_rates
Browse files Browse the repository at this point in the history
increase blackbox denom range (cleanup)
  • Loading branch information
digitalentity authored Feb 7, 2019
2 parents d2c60a6 + 9d19ec5 commit 939b206
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 32 deletions.
18 changes: 9 additions & 9 deletions src/main/blackbox/blackbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
#define BLACKBOX_INTERVED_CARD_DETECTION 0
#endif

PG_REGISTER_WITH_RESET_TEMPLATE(blackboxConfig_t, blackboxConfig, PG_BLACKBOX_CONFIG, 0);
PG_REGISTER_WITH_RESET_TEMPLATE(blackboxConfig_t, blackboxConfig, PG_BLACKBOX_CONFIG, 1);

PG_RESET_TEMPLATE(blackboxConfig_t, blackboxConfig,
.device = DEFAULT_BLACKBOX_DEVICE,
Expand Down Expand Up @@ -1540,7 +1540,7 @@ static bool blackboxWriteSysinfo(void)
BLACKBOX_PRINT_HEADER_LINE("Firmware date", "%s %s", buildDate, buildTime);
BLACKBOX_PRINT_HEADER_LINE("Log start datetime", "%s", blackboxGetStartDateTime(buf));
BLACKBOX_PRINT_HEADER_LINE("Craft name", "%s", systemConfig()->name);
BLACKBOX_PRINT_HEADER_LINE("P interval", "%d/%d", blackboxConfig()->rate_num, blackboxConfig()->rate_denom);
BLACKBOX_PRINT_HEADER_LINE("P interval", "%u/%u", blackboxConfig()->rate_num, blackboxConfig()->rate_denom);
BLACKBOX_PRINT_HEADER_LINE("minthrottle", "%d", motorConfig()->minthrottle);
BLACKBOX_PRINT_HEADER_LINE("maxthrottle", "%d", motorConfig()->maxthrottle);
BLACKBOX_PRINT_HEADER_LINE("gyro_scale", "0x%x", castFloatBytesToInt(1.0f));
Expand Down Expand Up @@ -1949,18 +1949,18 @@ void blackboxInit(void)
blackboxSetState(BLACKBOX_STATE_DISABLED);
}

/* FIXME is this really necessary ? Why? */
int max_denom = 4096*1000 / gyroConfig()->looptime;
if (blackboxConfig()->rate_denom > max_denom) {
blackboxConfigMutable()->rate_denom = max_denom;
}
/* Decide on how ofter are we going to log I-frames*/
if (blackboxConfig()->rate_denom <= 32) {
blackboxIFrameInterval = 32;
}
else if (blackboxConfig()->rate_denom <= 64) {
blackboxIFrameInterval = 64;
}
else if (blackboxConfig()->rate_denom <= 128) {
blackboxIFrameInterval = 128;
}
else {
blackboxIFrameInterval = 256;
// Use next higher power of two via GCC builtin
blackboxIFrameInterval = 1 << (32 - __builtin_clz (blackboxConfig()->rate_denom - 1));
}
}
#endif
4 changes: 2 additions & 2 deletions src/main/blackbox/blackbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include "config/parameter_group.h"

typedef struct blackboxConfig_s {
uint8_t rate_num;
uint8_t rate_denom;
uint16_t rate_num;
uint16_t rate_denom;
uint8_t device;
uint8_t invertedCardDetection;
} blackboxConfig_t;
Expand Down
23 changes: 15 additions & 8 deletions src/main/fc/fc_msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,16 +956,23 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
break;

case MSP_BLACKBOX_CONFIG:
sbufWriteU8(dst, 0); // API no longer supported
sbufWriteU8(dst, 0);
sbufWriteU8(dst, 0);
sbufWriteU8(dst, 0);
break;

case MSP2_BLACKBOX_CONFIG:
#ifdef USE_BLACKBOX
sbufWriteU8(dst, 1); //Blackbox supported
sbufWriteU8(dst, blackboxConfig()->device);
sbufWriteU8(dst, blackboxConfig()->rate_num);
sbufWriteU8(dst, blackboxConfig()->rate_denom);
sbufWriteU16(dst, blackboxConfig()->rate_num);
sbufWriteU16(dst, blackboxConfig()->rate_denom);
#else
sbufWriteU8(dst, 0); // Blackbox not supported
sbufWriteU8(dst, 0);
sbufWriteU8(dst, 0);
sbufWriteU8(dst, 0);
sbufWriteU16(dst, 0);
sbufWriteU16(dst, 0);
#endif
break;

Expand Down Expand Up @@ -2089,12 +2096,12 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
break;

#ifdef USE_BLACKBOX
case MSP_SET_BLACKBOX_CONFIG:
case MSP2_SET_BLACKBOX_CONFIG:
// Don't allow config to be updated while Blackbox is logging
if ((dataSize >= 3) && blackboxMayEditConfig()) {
if ((dataSize >= 5) && blackboxMayEditConfig()) {
blackboxConfigMutable()->device = sbufReadU8(src);
blackboxConfigMutable()->rate_num = sbufReadU8(src);
blackboxConfigMutable()->rate_denom = sbufReadU8(src);
blackboxConfigMutable()->rate_num = sbufReadU16(src);
blackboxConfigMutable()->rate_denom = sbufReadU16(src);
} else
return MSP_RESULT_ERROR;
break;
Expand Down
21 changes: 10 additions & 11 deletions src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ groups:
field: gyro_soft_notch_cutoff_2
condition: USE_GYRO_NOTCH_2
min: 1
max: 500
max: 500
- name: gyro_stage2_lowpass_hz
field: gyro_stage2_lowpass_hz
condition: USE_GYRO_BIQUAD_RC_FIR2
Expand Down Expand Up @@ -396,11 +396,11 @@ groups:
- name: blackbox_rate_num
field: rate_num
min: 1
max: 255
max: 65535
- name: blackbox_rate_denom
field: rate_denom
min: 1
max: 255
max: 65535
- name: blackbox_device
field: device
table: blackbox_device
Expand Down Expand Up @@ -1323,32 +1323,32 @@ groups:
field: mc.braking_speed_threshold
condition: USE_MR_BRAKING_MODE
min: 0
max: 1000
max: 1000
- name: nav_mc_braking_disengage_speed
field: mc.braking_disengage_speed
condition: USE_MR_BRAKING_MODE
min: 0
max: 1000
max: 1000
- name: nav_mc_braking_timeout
field: mc.braking_timeout
condition: USE_MR_BRAKING_MODE
min: 100
max: 5000
max: 5000
- name: nav_mc_braking_boost_factor
field: mc.braking_boost_factor
condition: USE_MR_BRAKING_MODE
min: 0
max: 200
max: 200
- name: nav_mc_braking_boost_timeout
field: mc.braking_boost_timeout
condition: USE_MR_BRAKING_MODE
min: 0
max: 5000
max: 5000
- name: nav_mc_braking_boost_speed_threshold
field: mc.braking_boost_speed_threshold
condition: USE_MR_BRAKING_MODE
min: 100
max: 1000
max: 1000
- name: nav_mc_braking_boost_disengage_speed
field: mc.braking_boost_disengage_speed
condition: USE_MR_BRAKING_MODE
Expand All @@ -1358,7 +1358,7 @@ groups:
field: mc.braking_bank_angle
condition: USE_MR_BRAKING_MODE
min: 15
max: 60
max: 60
- name: nav_fw_cruise_thr
field: fw.cruise_throttle
min: 1000
Expand Down Expand Up @@ -1768,4 +1768,3 @@ groups:
min: 0
max: 255
type: uint8_t

4 changes: 2 additions & 2 deletions src/main/msp/msp_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#define MSP_PROTOCOL_VERSION 0 // Same version over MSPv1 & MSPv2 - message format didn't change and it backward compatible

#define API_VERSION_MAJOR 2 // increment when major changes are made
#define API_VERSION_MINOR 2 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR
#define API_VERSION_MINOR 3 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR

#define API_VERSION_LENGTH 2

Expand Down Expand Up @@ -328,4 +328,4 @@
// MSPv2 includes
#include "msp_protocol_v2_common.h"
#include "msp_protocol_v2_sensor.h"
#include "msp_protocol_v2_inav.h"
#include "msp_protocol_v2_inav.h"
3 changes: 3 additions & 0 deletions src/main/msp/msp_protocol_v2_inav.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@
#define MSP2_INAV_SELECT_BATTERY_PROFILE 0x2018

#define MSP2_INAV_DEBUG 0x2019

#define MSP2_BLACKBOX_CONFIG 0x201A
#define MSP2_SET_BLACKBOX_CONFIG 0x201B

0 comments on commit 939b206

Please sign in to comment.