mirror of https://github.com/ArduPilot/ardupilot
Replay: added support for EV message for copter arming
This commit is contained in:
parent
4e3d18bee4
commit
9f05e54d90
|
@ -27,6 +27,7 @@
|
||||||
#include "MsgHandler_SIM.h"
|
#include "MsgHandler_SIM.h"
|
||||||
#include "MsgHandler_BARO.h"
|
#include "MsgHandler_BARO.h"
|
||||||
#include "MsgHandler_ARM.h"
|
#include "MsgHandler_ARM.h"
|
||||||
|
#include "MsgHandler_Event.h"
|
||||||
#include "MsgHandler_AHR2.h"
|
#include "MsgHandler_AHR2.h"
|
||||||
#include "MsgHandler_ATT.h"
|
#include "MsgHandler_ATT.h"
|
||||||
#include "MsgHandler_MAG.h"
|
#include "MsgHandler_MAG.h"
|
||||||
|
@ -165,6 +166,9 @@ bool LogReader::update(char type[5])
|
||||||
} else if (streq(name, "ARM")) {
|
} else if (streq(name, "ARM")) {
|
||||||
msgparser[f.type] = new MsgHandler_ARM(formats[f.type], dataflash,
|
msgparser[f.type] = new MsgHandler_ARM(formats[f.type], dataflash,
|
||||||
last_timestamp_usec);
|
last_timestamp_usec);
|
||||||
|
} else if (streq(name, "EV")) {
|
||||||
|
msgparser[f.type] = new MsgHandler_Event(formats[f.type], dataflash,
|
||||||
|
last_timestamp_usec);
|
||||||
} else if (streq(name, "AHR2")) {
|
} else if (streq(name, "AHR2")) {
|
||||||
msgparser[f.type] = new MsgHandler_AHR2(formats[f.type], dataflash,
|
msgparser[f.type] = new MsgHandler_AHR2(formats[f.type], dataflash,
|
||||||
last_timestamp_usec,
|
last_timestamp_usec,
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include "MsgHandler_Event.h"
|
||||||
|
|
||||||
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
|
#define DATA_ARMED 10
|
||||||
|
#define DATA_DISARMED 11
|
||||||
|
|
||||||
|
void MsgHandler_Event::process_message(uint8_t *msg)
|
||||||
|
{
|
||||||
|
uint8_t id = require_field_uint8_t(msg, "Id");
|
||||||
|
if (id == DATA_ARMED) {
|
||||||
|
hal.util->set_soft_armed(true);
|
||||||
|
printf("Armed at %lu\n",
|
||||||
|
(unsigned long)hal.scheduler->millis());
|
||||||
|
} else if (id == DATA_DISARMED) {
|
||||||
|
hal.util->set_soft_armed(false);
|
||||||
|
printf("Disarmed at %lu\n",
|
||||||
|
(unsigned long)hal.scheduler->millis());
|
||||||
|
}
|
||||||
|
dataflash.WriteBlock(msg, f.length);
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "MsgHandler.h"
|
||||||
|
|
||||||
|
class MsgHandler_Event : public MsgHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MsgHandler_Event(log_Format &_f, DataFlash_Class &_dataflash,
|
||||||
|
uint64_t &_last_timestamp_usec)
|
||||||
|
: MsgHandler(_f, _dataflash, _last_timestamp_usec) { };
|
||||||
|
|
||||||
|
virtual void process_message(uint8_t *msg);
|
||||||
|
};
|
|
@ -213,11 +213,8 @@ void setup()
|
||||||
ahrs.set_wind_estimation(true);
|
ahrs.set_wind_estimation(true);
|
||||||
ahrs.set_correct_centrifugal(true);
|
ahrs.set_correct_centrifugal(true);
|
||||||
|
|
||||||
if (arm_time_ms != 0) {
|
printf("Starting disarmed\n");
|
||||||
hal.util->set_soft_armed(false);
|
hal.util->set_soft_armed(false);
|
||||||
} else {
|
|
||||||
hal.util->set_soft_armed(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
barometer.init();
|
barometer.init();
|
||||||
barometer.setHIL(0);
|
barometer.setHIL(0);
|
||||||
|
|
Loading…
Reference in New Issue