DataFlash: log both airspeed sensors

This commit is contained in:
Andrew Tridgell 2017-11-03 17:37:40 +11:00
parent 58b0ac07ec
commit bbcda11afe
2 changed files with 23 additions and 14 deletions

View File

@ -1704,21 +1704,27 @@ void DataFlash_Class::Log_Write_ESC(void)
// Write a AIRSPEED packet
void DataFlash_Class::Log_Write_Airspeed(AP_Airspeed &airspeed)
{
float temperature;
if (!airspeed.get_temperature(temperature)) {
temperature = 0;
uint64_t now = AP_HAL::micros64();
for (uint8_t i=0; i<AIRSPEED_MAX_SENSORS; i++) {
if (!airspeed.enabled(i)) {
continue;
}
float temperature;
if (!airspeed.get_temperature(i, temperature)) {
temperature = 0;
}
struct log_AIRSPEED pkt = {
LOG_PACKET_HEADER_INIT(i==0?LOG_ARSP_MSG:LOG_ASP2_MSG),
time_us : now,
airspeed : airspeed.get_raw_airspeed(i),
diffpressure : airspeed.get_differential_pressure(i),
temperature : (int16_t)(temperature * 100.0f),
rawpressure : airspeed.get_corrected_pressure(i),
offset : airspeed.get_offset(i),
use : airspeed.use(i)
};
WriteBlock(&pkt, sizeof(pkt));
}
struct log_AIRSPEED pkt = {
LOG_PACKET_HEADER_INIT(LOG_ARSP_MSG),
time_us : AP_HAL::micros64(),
airspeed : airspeed.get_raw_airspeed(),
diffpressure : airspeed.get_differential_pressure(),
temperature : (int16_t)(temperature * 100.0f),
rawpressure : airspeed.get_corrected_pressure(),
offset : airspeed.get_offset(),
use : airspeed.use()
};
WriteBlock(&pkt, sizeof(pkt));
}
// Write a Yaw PID packet

View File

@ -1188,6 +1188,8 @@ Format characters in the format string for binary log messages
"TRIG", "QIHLLeeeccC","TimeUS,GPSTime,GPSWeek,Lat,Lng,Alt,RelAlt,GPSAlt,Roll,Pitch,Yaw", "s--DUmmmddd", "F--GGBBBBBB" }, \
{ LOG_ARSP_MSG, sizeof(log_AIRSPEED), \
"ARSP", "QffcffB", "TimeUS,Airspeed,DiffPress,Temp,RawPress,Offset,U", "snPOPP-", "F00B00-" }, \
{ LOG_ASP2_MSG, sizeof(log_AIRSPEED), \
"ASP2", "QffcffB", "TimeUS,Airspeed,DiffPress,Temp,RawPress,Offset,U", "snPOPP-", "F00B00-" }, \
{ LOG_CURRENT_MSG, sizeof(log_Current), \
"BAT", CURR_FMT,CURR_LABELS,CURR_UNITS,CURR_MULTS }, \
{ LOG_CURRENT2_MSG, sizeof(log_Current), \
@ -1517,6 +1519,7 @@ enum LogMessages {
LOG_SRTL_MSG,
LOG_ISBH_MSG,
LOG_ISBD_MSG,
LOG_ASP2_MSG,
};