DataFlash: added logging of safety state in POWR message

This commit is contained in:
Andrew Tridgell 2018-04-13 09:49:48 +10:00
parent ecf2c51a8b
commit cf4ca29dbb
2 changed files with 9 additions and 2 deletions

View File

@ -436,12 +436,18 @@ bool DataFlash_Backend::Log_Write_Message(const char *message)
void DataFlash_Class::Log_Write_Power(void)
{
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
uint8_t safety_and_armed = uint8_t(hal.util->safety_switch_state());
if (hal.util->get_soft_armed()) {
// encode armed state in bit 3
safety_and_armed |= 1U<<2;
}
struct log_POWR pkt = {
LOG_PACKET_HEADER_INIT(LOG_POWR_MSG),
time_us : AP_HAL::micros64(),
Vcc : hal.analogin->board_voltage(),
Vservo : hal.analogin->servorail_voltage(),
flags : hal.analogin->power_status_flags()
flags : hal.analogin->power_status_flags(),
safety_and_arm : safety_and_armed
};
WriteBlock(&pkt, sizeof(pkt));
#endif

View File

@ -357,6 +357,7 @@ struct PACKED log_POWR {
float Vcc;
float Vservo;
uint16_t flags;
uint8_t safety_and_arm;
};
struct PACKED log_EKF1 {
@ -1202,7 +1203,7 @@ Format characters in the format string for binary log messages
{ LOG_BARO_MSG, sizeof(log_BARO), \
"BARO", BARO_FMT, BARO_LABELS, BARO_UNITS, BARO_MULTS }, \
{ LOG_POWR_MSG, sizeof(log_POWR), \
"POWR","QffH","TimeUS,Vcc,VServo,Flags", "svv-", "FBB-" }, \
"POWR","QffHB","TimeUS,Vcc,VServo,Flags,Safety", "svv--", "FBB--" }, \
{ LOG_CMD_MSG, sizeof(log_Cmd), \
"CMD", "QHHHfffffffB","TimeUS,CTot,CNum,CId,Prm1,Prm2,Prm3,Prm4,Lat,Lng,Alt,Frame", "s-------DUm-", "F-------GG0-" }, \
{ LOG_RADIO_MSG, sizeof(log_Radio), \