mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-19 16:29:05 +08:00
Proper data manager restart handling
Introduce SYS_RESTART_TYPE parameter having one of 3 values: boot restart, inflight restart, or unknown restart, and defaulting to unknown restart. px4io.cpp sets this parameter according to the type of restart detected. dataman.c retrieves this parameter and clears data entries according to their persistence level. Does nothing if unknown restart.
This commit is contained in:
parent
ad77ba2642
commit
ab257ebcce
@ -91,6 +91,8 @@
|
||||
|
||||
#include "uploader.h"
|
||||
|
||||
#include "modules/dataman/dataman.h"
|
||||
|
||||
extern device::Device *PX4IO_i2c_interface() weak_function;
|
||||
extern device::Device *PX4IO_serial_interface() weak_function;
|
||||
|
||||
@ -568,9 +570,15 @@ int
|
||||
PX4IO::init()
|
||||
{
|
||||
int ret;
|
||||
param_t sys_restart_param;
|
||||
int sys_restart_val = DM_INIT_REASON_VOLATILE;
|
||||
|
||||
ASSERT(_task == -1);
|
||||
|
||||
sys_restart_param = param_find("SYS_RESTART_TYPE");
|
||||
/* Indicate restart type is unknown */
|
||||
param_set(sys_restart_param, &sys_restart_val);
|
||||
|
||||
/* do regular cdev init */
|
||||
ret = CDev::init();
|
||||
|
||||
@ -720,6 +728,11 @@ PX4IO::init()
|
||||
/* keep waiting for state change for 2 s */
|
||||
} while (!safety.armed);
|
||||
|
||||
/* Indicate restart type is in-flight */
|
||||
sys_restart_val = DM_INIT_REASON_IN_FLIGHT;
|
||||
param_set(sys_restart_param, &sys_restart_val);
|
||||
|
||||
|
||||
/* regular boot, no in-air restart, init IO */
|
||||
|
||||
} else {
|
||||
@ -745,6 +758,10 @@ PX4IO::init()
|
||||
}
|
||||
}
|
||||
|
||||
/* Indicate restart type is power on */
|
||||
sys_restart_val = DM_INIT_REASON_POWER_ON;
|
||||
param_set(sys_restart_param, &sys_restart_val);
|
||||
|
||||
}
|
||||
|
||||
/* try to claim the generic PWM output device node as well - it's OK if we fail at this */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user