DataFlash: pull out common mission logging code

This commit is contained in:
Peter Barker 2015-06-30 14:33:50 +10:00 committed by Andrew Tridgell
parent b0c6a1fde7
commit cabea266e7
2 changed files with 26 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include <AP_Baro.h>
#include <AP_AHRS.h>
#include <AP_Vehicle.h>
#include <AP_Mission.h>
#include "../AP_Airspeed/AP_Airspeed.h"
#include "../AP_BattMonitor/AP_BattMonitor.h"
#include <stdint.h>
@ -91,6 +92,10 @@ public:
void Log_Write_Mode(uint8_t mode);
void Log_Write_Parameters(void);
void Log_Write_EntireMission(const AP_Mission &mission);
void Log_Write_Mission_Cmd(const AP_Mission &mission,
const AP_Mission::Mission_Command &cmd);
// This structure provides information on the internal member data of a PID for logging purposes
struct PID_Info {
float desired;

View File

@ -995,6 +995,27 @@ void DataFlash_Class::Log_Write_SysInfo(const prog_char_t *firmware_string)
Log_Write_Parameters();
}
// Write a mission command. Total length : 36 bytes
void DataFlash_Class::Log_Write_Mission_Cmd(const AP_Mission &mission,
const AP_Mission::Mission_Command &cmd)
{
mavlink_mission_item_t mav_cmd = {};
AP_Mission::mission_cmd_to_mavlink(cmd,mav_cmd);
Log_Write_MavCmd(mission.num_commands(),mav_cmd);
}
void DataFlash_Class::Log_Write_EntireMission(const AP_Mission &mission)
{
Log_Write_Message_P(PSTR("New mission"));
AP_Mission::Mission_Command cmd;
for (uint16_t i = 0; i < mission.num_commands(); i++) {
if (mission.read_cmd_from_storage(i,cmd)) {
Log_Write_Mission_Cmd(mission, cmd);
}
}
}
// Write a text message to the log
void DataFlash_Class::Log_Write_Message(const char *message)
{