mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-21 16:18:29 -04:00
Copter: support logging while disarmed
This commit is contained in:
parent
7e1c975c54
commit
c093160ea9
@ -206,6 +206,9 @@ static AP_Notify notify;
|
||||
// used to detect MAVLink acks from GCS to stop compassmot
|
||||
static uint8_t command_ack_counter;
|
||||
|
||||
// has a log download started?
|
||||
static bool in_log_download;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// prototypes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -944,7 +947,7 @@ static void barometer_accumulate(void)
|
||||
|
||||
static void perf_update(void)
|
||||
{
|
||||
if (g.log_bitmask & MASK_LOG_PM)
|
||||
if (should_log(MASK_LOG_PM))
|
||||
Log_Write_Performance();
|
||||
if (scheduler.debug()) {
|
||||
cliSerial->printf_P(PSTR("PERF: %u/%u %lu\n"),
|
||||
@ -1091,7 +1094,7 @@ static void update_batt_compass(void)
|
||||
compass.set_throttle((float)g.rc_3.servo_out/1000.0f);
|
||||
compass.read();
|
||||
// log compass information
|
||||
if (g.log_bitmask & MASK_LOG_COMPASS) {
|
||||
if (should_log(MASK_LOG_COMPASS)) {
|
||||
Log_Write_Compass();
|
||||
}
|
||||
}
|
||||
@ -1104,16 +1107,16 @@ static void update_batt_compass(void)
|
||||
// should be run at 10hz
|
||||
static void ten_hz_logging_loop()
|
||||
{
|
||||
if (g.log_bitmask & MASK_LOG_ATTITUDE_MED) {
|
||||
if (should_log(MASK_LOG_ATTITUDE_MED)) {
|
||||
Log_Write_Attitude();
|
||||
}
|
||||
if (g.log_bitmask & MASK_LOG_RCIN) {
|
||||
if (should_log(MASK_LOG_RCIN)) {
|
||||
DataFlash.Log_Write_RCIN();
|
||||
}
|
||||
if (g.log_bitmask & MASK_LOG_RCOUT) {
|
||||
if (should_log(MASK_LOG_RCOUT)) {
|
||||
DataFlash.Log_Write_RCOUT();
|
||||
}
|
||||
if ((g.log_bitmask & MASK_LOG_NTUN) && (mode_requires_GPS(control_mode) || landing_with_GPS())) {
|
||||
if (should_log(MASK_LOG_NTUN) && (mode_requires_GPS(control_mode) || landing_with_GPS())) {
|
||||
Log_Write_Nav_Tuning();
|
||||
}
|
||||
}
|
||||
@ -1128,11 +1131,11 @@ static void fifty_hz_logging_loop()
|
||||
#endif
|
||||
|
||||
#if HIL_MODE == HIL_MODE_DISABLED
|
||||
if (g.log_bitmask & MASK_LOG_ATTITUDE_FAST) {
|
||||
if (should_log(MASK_LOG_ATTITUDE_FAST)) {
|
||||
Log_Write_Attitude();
|
||||
}
|
||||
|
||||
if (g.log_bitmask & MASK_LOG_IMU) {
|
||||
if (should_log(MASK_LOG_IMU)) {
|
||||
DataFlash.Log_Write_IMU(ins);
|
||||
}
|
||||
#endif
|
||||
@ -1162,12 +1165,12 @@ static void three_hz_loop()
|
||||
// one_hz_loop - runs at 1Hz
|
||||
static void one_hz_loop()
|
||||
{
|
||||
if (g.log_bitmask != 0) {
|
||||
if (should_log(MASK_LOG_ANY)) {
|
||||
Log_Write_Data(DATA_AP_STATE, ap.value);
|
||||
}
|
||||
|
||||
// log battery info to the dataflash
|
||||
if (g.log_bitmask & MASK_LOG_CURRENT) {
|
||||
if (should_log(MASK_LOG_CURRENT)) {
|
||||
Log_Write_Current();
|
||||
}
|
||||
|
||||
@ -1226,7 +1229,7 @@ static void update_optical_flow(void)
|
||||
of_log_counter++;
|
||||
if( of_log_counter >= 4 ) {
|
||||
of_log_counter = 0;
|
||||
if (g.log_bitmask & MASK_LOG_OPTFLOW) {
|
||||
if (should_log(MASK_LOG_OPTFLOW)) {
|
||||
Log_Write_Optflow();
|
||||
}
|
||||
}
|
||||
@ -1250,7 +1253,7 @@ static void update_GPS(void)
|
||||
last_gps_reading[i] = gps.last_message_time_ms(i);
|
||||
|
||||
// log GPS message
|
||||
if (g.log_bitmask & MASK_LOG_GPS) {
|
||||
if (should_log(MASK_LOG_GPS)) {
|
||||
DataFlash.Log_Write_GPS(gps, i, current_loc.alt);
|
||||
}
|
||||
|
||||
@ -1336,7 +1339,7 @@ init_simple_bearing()
|
||||
super_simple_sin_yaw = simple_sin_yaw;
|
||||
|
||||
// log the simple bearing to dataflash
|
||||
if (g.log_bitmask != 0) {
|
||||
if (should_log(MASK_LOG_ANY)) {
|
||||
Log_Write_Data(DATA_INIT_SIMPLE_BEARING, ahrs.yaw_sensor);
|
||||
}
|
||||
}
|
||||
@ -1407,7 +1410,7 @@ static void update_altitude()
|
||||
sonar_alt = read_sonar();
|
||||
|
||||
// write altitude info to dataflash logs
|
||||
if (g.log_bitmask & MASK_LOG_CTUN) {
|
||||
if (should_log(MASK_LOG_CTUN)) {
|
||||
Log_Write_Control_Tuning();
|
||||
}
|
||||
}
|
||||
|
@ -1291,11 +1291,21 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg)
|
||||
case MAVLINK_MSG_ID_RADIO:
|
||||
case MAVLINK_MSG_ID_RADIO_STATUS: // MAV ID: 109
|
||||
{
|
||||
handle_radio_status(msg, DataFlash, (g.log_bitmask & MASK_LOG_PM) != 0);
|
||||
handle_radio_status(msg, DataFlash, should_log(MASK_LOG_PM));
|
||||
break;
|
||||
}
|
||||
|
||||
case MAVLINK_MSG_ID_LOG_REQUEST_LIST ... MAVLINK_MSG_ID_LOG_REQUEST_END: // MAV ID: 117 ... 122
|
||||
case MAVLINK_MSG_ID_LOG_REQUEST_DATA:
|
||||
case MAVLINK_MSG_ID_LOG_ERASE:
|
||||
in_log_download = true;
|
||||
// fallthru
|
||||
case MAVLINK_MSG_ID_LOG_REQUEST_LIST:
|
||||
if (!in_mavlink_delay && !motors.armed()) {
|
||||
handle_log_message(msg, DataFlash);
|
||||
}
|
||||
break;
|
||||
case MAVLINK_MSG_ID_LOG_REQUEST_END:
|
||||
in_log_download = false;
|
||||
if (!in_mavlink_delay && !motors.armed()) {
|
||||
handle_log_message(msg, DataFlash);
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ struct PACKED log_Event {
|
||||
// Wrote an event packet
|
||||
static void Log_Write_Event(uint8_t id)
|
||||
{
|
||||
if (g.log_bitmask != 0) {
|
||||
if (should_log(MASK_LOG_ANY)) {
|
||||
struct log_Event pkt = {
|
||||
LOG_PACKET_HEADER_INIT(LOG_EVENT_MSG),
|
||||
id : id
|
||||
@ -547,7 +547,7 @@ struct PACKED log_Data_Int16t {
|
||||
// Write an int16_t data packet
|
||||
static void Log_Write_Data(uint8_t id, int16_t value)
|
||||
{
|
||||
if (g.log_bitmask != 0) {
|
||||
if (should_log(MASK_LOG_ANY)) {
|
||||
struct log_Data_Int16t pkt = {
|
||||
LOG_PACKET_HEADER_INIT(LOG_DATA_INT16_MSG),
|
||||
id : id,
|
||||
@ -566,7 +566,7 @@ struct PACKED log_Data_UInt16t {
|
||||
// Write an uint16_t data packet
|
||||
static void Log_Write_Data(uint8_t id, uint16_t value)
|
||||
{
|
||||
if (g.log_bitmask != 0) {
|
||||
if (should_log(MASK_LOG_ANY)) {
|
||||
struct log_Data_UInt16t pkt = {
|
||||
LOG_PACKET_HEADER_INIT(LOG_DATA_UINT16_MSG),
|
||||
id : id,
|
||||
@ -585,7 +585,7 @@ struct PACKED log_Data_Int32t {
|
||||
// Write an int32_t data packet
|
||||
static void Log_Write_Data(uint8_t id, int32_t value)
|
||||
{
|
||||
if (g.log_bitmask != 0) {
|
||||
if (should_log(MASK_LOG_ANY)) {
|
||||
struct log_Data_Int32t pkt = {
|
||||
LOG_PACKET_HEADER_INIT(LOG_DATA_INT32_MSG),
|
||||
id : id,
|
||||
@ -604,7 +604,7 @@ struct PACKED log_Data_UInt32t {
|
||||
// Write a uint32_t data packet
|
||||
static void Log_Write_Data(uint8_t id, uint32_t value)
|
||||
{
|
||||
if (g.log_bitmask != 0) {
|
||||
if (should_log(MASK_LOG_ANY)) {
|
||||
struct log_Data_UInt32t pkt = {
|
||||
LOG_PACKET_HEADER_INIT(LOG_DATA_UINT32_MSG),
|
||||
id : id,
|
||||
@ -623,7 +623,7 @@ struct PACKED log_Data_Float {
|
||||
// Write a float data packet
|
||||
static void Log_Write_Data(uint8_t id, float value)
|
||||
{
|
||||
if (g.log_bitmask != 0) {
|
||||
if (should_log(MASK_LOG_ANY)) {
|
||||
struct log_Data_Float pkt = {
|
||||
LOG_PACKET_HEADER_INIT(LOG_DATA_FLOAT_MSG),
|
||||
id : id,
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
|
||||
// Misc
|
||||
//
|
||||
k_param_log_bitmask = 20,
|
||||
k_param_log_bitmask_old = 20, // Deprecated
|
||||
k_param_log_last_filenumber, // *** Deprecated - remove
|
||||
// with next eeprom number
|
||||
// change
|
||||
@ -123,6 +123,7 @@ public:
|
||||
k_param_throttle_deadzone,
|
||||
k_param_optflow,
|
||||
k_param_dcmcheck_thresh, // 59
|
||||
k_param_log_bitmask,
|
||||
|
||||
// 65: AP_Limits Library
|
||||
k_param_limits = 65, // deprecated - remove
|
||||
@ -382,7 +383,7 @@ public:
|
||||
|
||||
// Misc
|
||||
//
|
||||
AP_Int16 log_bitmask;
|
||||
AP_Int32 log_bitmask;
|
||||
AP_Int8 esc_calibrate;
|
||||
AP_Int8 radio_tuning;
|
||||
AP_Int16 radio_tuning_high;
|
||||
|
@ -354,8 +354,8 @@ const AP_Param::Info var_info[] PROGMEM = {
|
||||
|
||||
// @Param: LOG_BITMASK
|
||||
// @DisplayName: Log bitmask
|
||||
// @Description: 2 byte bitmap of log types to enable
|
||||
// @Values: 830:Default,894:Default+RCIN,958:Default+IMU,1854:Default+Motors,-6146:NearlyAll,0:Disabled
|
||||
// @Description: 4 byte bitmap of log types to enable
|
||||
// @Values: 830:Default,894:Default+RCIN,958:Default+IMU,1854:Default+Motors,59390:NearlyAll,131071:All+DisarmedLogging,0:Disabled
|
||||
// @User: Standard
|
||||
GSCALAR(log_bitmask, "LOG_BITMASK", DEFAULT_LOG_BITMASK),
|
||||
|
||||
@ -1142,6 +1142,7 @@ const AP_Param::ConversionInfo conversion_table[] PROGMEM = {
|
||||
{ Parameters::k_param_volt_div_ratio, 0, AP_PARAM_FLOAT, "BATT_VOLT_MULT" },
|
||||
{ Parameters::k_param_curr_amp_per_volt, 0, AP_PARAM_FLOAT, "BATT_AMP_PERVOLT" },
|
||||
{ Parameters::k_param_pack_capacity, 0, AP_PARAM_INT32, "BATT_CAPACITY" },
|
||||
{ Parameters::k_param_log_bitmask_old, 0, AP_PARAM_INT16, "LOG_BITMASK" },
|
||||
};
|
||||
|
||||
static void load_parameters(void)
|
||||
|
@ -14,7 +14,7 @@ static void init_home()
|
||||
inertial_nav.setup_home_position();
|
||||
|
||||
// log new home position which mission library will pull from ahrs
|
||||
if (g.log_bitmask & MASK_LOG_CMD) {
|
||||
if (should_log(MASK_LOG_CMD)) {
|
||||
AP_Mission::Mission_Command temp_cmd;
|
||||
if (mission.read_cmd_from_storage(0, temp_cmd)) {
|
||||
Log_Write_Cmd(temp_cmd);
|
||||
|
@ -33,7 +33,7 @@ static void auto_spline_start(const Vector3f& destination, bool stopped_at_start
|
||||
static bool start_command(const AP_Mission::Mission_Command& cmd)
|
||||
{
|
||||
// To-Do: logging when new commands start/end
|
||||
if (g.log_bitmask & MASK_LOG_CMD) {
|
||||
if (should_log(MASK_LOG_CMD)) {
|
||||
Log_Write_Cmd(cmd);
|
||||
}
|
||||
|
||||
@ -914,7 +914,7 @@ static void do_take_picture()
|
||||
{
|
||||
#if CAMERA == ENABLED
|
||||
camera.trigger_pic();
|
||||
if (g.log_bitmask & MASK_LOG_CAMERA) {
|
||||
if (should_log(MASK_LOG_CAMERA)) {
|
||||
DataFlash.Log_Write_Camera(ahrs, gps, current_loc);
|
||||
}
|
||||
#endif
|
||||
|
@ -263,6 +263,8 @@ enum FlipState {
|
||||
#define MASK_LOG_COMPASS (1<<13)
|
||||
#define MASK_LOG_INAV (1<<14) // deprecated
|
||||
#define MASK_LOG_CAMERA (1<<15)
|
||||
#define MASK_LOG_WHEN_DISARMED (1UL<<16)
|
||||
#define MASK_LOG_ANY 0xFFFF
|
||||
|
||||
// DATA - event logging
|
||||
#define DATA_MAVLINK_FLOAT 1
|
||||
|
@ -22,7 +22,7 @@ static void init_barometer(bool full_calibration)
|
||||
static int32_t read_barometer(void)
|
||||
{
|
||||
barometer.read();
|
||||
if (g.log_bitmask & MASK_LOG_IMU) {
|
||||
if (should_log(MASK_LOG_IMU)) {
|
||||
Log_Write_Baro();
|
||||
}
|
||||
int32_t balt = barometer.get_altitude() * 100.0f;
|
||||
|
@ -404,3 +404,22 @@ static void telemetry_send(void)
|
||||
(AP_Frsky_Telem::FrSkyProtocol)g.serial2_protocol.get());
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
should we log a message type now?
|
||||
*/
|
||||
static bool should_log(uint32_t mask)
|
||||
{
|
||||
if (!(mask & g.log_bitmask) || in_mavlink_delay) {
|
||||
return false;
|
||||
}
|
||||
bool ret = motors.armed() || (g.log_bitmask & MASK_LOG_WHEN_DISARMED) != 0;
|
||||
if (ret && !DataFlash.logging_started() && !in_log_download) {
|
||||
// we have to set in_mavlink_delay to prevent logging while
|
||||
// writing headers
|
||||
in_mavlink_delay = true;
|
||||
start_logging();
|
||||
in_mavlink_delay = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user