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 611dbb18f4
commit 24487d6b0d
2 changed files with 9 additions and 2 deletions

View File

@ -1012,12 +1012,18 @@ bool DataFlash_Backend::Log_Write_Message(const char *message)
void DataFlash_Class::Log_Write_Power(void)
{
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
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

@ -223,6 +223,7 @@ struct PACKED log_POWR {
float Vcc;
float Vservo;
uint16_t flags;
uint8_t safety_and_arm;
};
struct PACKED log_EKF1 {
@ -905,7 +906,7 @@ Format characters in the format string for binary log messages
{ LOG_BARO_MSG, sizeof(log_BARO), \
"BARO", BARO_FMT, BARO_LABELS }, \
{ LOG_POWR_MSG, sizeof(log_POWR), \
"POWR","QffH","TimeUS,Vcc,VServo,Flags" }, \
"POWR","QffHB","TimeUS,Vcc,VServo,Flags,Safety" }, \
{ LOG_CMD_MSG, sizeof(log_Cmd), \
"CMD", "QHHHfffffff","TimeUS,CTot,CNum,CId,Prm1,Prm2,Prm3,Prm4,Lat,Lng,Alt" }, \
{ LOG_RADIO_MSG, sizeof(log_Radio), \