From 2f8daf2fa9c1afaa062f0a70ea89c0556a961bd5 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Sun, 16 Mar 2014 17:41:59 +0900 Subject: [PATCH] Copter: integrate dataflash Log_Write_MavCmd --- ArduCopter/Log.pde | 9 +++++++++ ArduCopter/commands.pde | 2 +- ArduCopter/commands_logic.pde | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ArduCopter/Log.pde b/ArduCopter/Log.pde index abf13d6973..31a10b7a39 100644 --- a/ArduCopter/Log.pde +++ b/ArduCopter/Log.pde @@ -422,6 +422,14 @@ static void Log_Write_Performance() DataFlash.WriteBlock(&pkt, sizeof(pkt)); } +// Write a mission command. Total length : 36 bytes +static void Log_Write_Cmd(const AP_Mission::Mission_Command &cmd) +{ + mavlink_mission_item_t mav_cmd = {}; + AP_Mission::mission_cmd_to_mavlink(cmd,mav_cmd); + DataFlash.Log_Write_MavCmd(mission.num_commands(),mav_cmd); +} + struct PACKED log_Attitude { LOG_PACKET_HEADER; uint32_t time_ms; @@ -770,6 +778,7 @@ static void Log_Write_Optflow() {} static void Log_Write_Nav_Tuning() {} static void Log_Write_Control_Tuning() {} static void Log_Write_Performance() {} +static void Log_Write_Cmd(const AP_Mission::Mission_Command &cmd) {} static void Log_Write_Camera() {} static void Log_Write_Error(uint8_t sub_system, uint8_t error_code) {} static void Log_Write_Baro(void); diff --git a/ArduCopter/commands.pde b/ArduCopter/commands.pde index e3b7b3c788..82626ef8cd 100644 --- a/ArduCopter/commands.pde +++ b/ArduCopter/commands.pde @@ -24,7 +24,7 @@ static void init_home() if (g.log_bitmask & MASK_LOG_CMD) { AP_Mission::Mission_Command temp_cmd; if (mission.read_cmd_from_storage(0, temp_cmd)) { - DataFlash.Log_Write_Cmd(mission.num_commands(),temp_cmd); + Log_Write_Cmd(temp_cmd); } } diff --git a/ArduCopter/commands_logic.pde b/ArduCopter/commands_logic.pde index 21db8018e5..00d2e4f22c 100644 --- a/ArduCopter/commands_logic.pde +++ b/ArduCopter/commands_logic.pde @@ -21,7 +21,7 @@ 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) { - DataFlash.Log_Write_Cmd(mission.num_commands(),cmd); + Log_Write_Cmd(cmd); } switch(cmd.id) {