ACM: run mavlink loop while erasing logs
This commit is contained in:
parent
ce035fc324
commit
1807585b98
@ -138,8 +138,8 @@ dump_log(uint8_t argc, const Menu::arg *argv)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int8_t
|
static void
|
||||||
erase_logs(uint8_t argc, const Menu::arg *argv)
|
do_erase_logs(void (*delay_cb)(unsigned long))
|
||||||
{
|
{
|
||||||
Serial.printf_P(PSTR("\nErasing log...\n"));
|
Serial.printf_P(PSTR("\nErasing log...\n"));
|
||||||
DataFlash.SetFileNumber(0xFFFF);
|
DataFlash.SetFileNumber(0xFFFF);
|
||||||
@ -147,10 +147,17 @@ erase_logs(uint8_t argc, const Menu::arg *argv)
|
|||||||
DataFlash.PageErase(j);
|
DataFlash.PageErase(j);
|
||||||
DataFlash.StartWrite(j); // We need this step to clean FileNumbers
|
DataFlash.StartWrite(j); // We need this step to clean FileNumbers
|
||||||
if(j%128 == 0) Serial.printf_P(PSTR("+"));
|
if(j%128 == 0) Serial.printf_P(PSTR("+"));
|
||||||
|
delay_cb(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.printf_P(PSTR("\nLog erased.\n"));
|
Serial.printf_P(PSTR("\nLog erased.\n"));
|
||||||
DataFlash.FinishWrite();
|
DataFlash.FinishWrite();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int8_t
|
||||||
|
erase_logs(uint8_t argc, const Menu::arg *argv)
|
||||||
|
{
|
||||||
|
do_erase_logs(delay);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,8 @@ static void run_cli(void)
|
|||||||
|
|
||||||
static void init_ardupilot()
|
static void init_ardupilot()
|
||||||
{
|
{
|
||||||
|
bool need_log_erase = false;
|
||||||
|
|
||||||
#if USB_MUX_PIN > 0
|
#if USB_MUX_PIN > 0
|
||||||
// on the APM2 board we have a mux thet switches UART0 between
|
// on the APM2 board we have a mux thet switches UART0 between
|
||||||
// USB and the board header. If the right ArduPPM firmware is
|
// USB and the board header. If the right ArduPPM firmware is
|
||||||
@ -175,30 +177,15 @@ static void init_ardupilot()
|
|||||||
// erase DataFlash on format version change
|
// erase DataFlash on format version change
|
||||||
#if LOGGING_ENABLED == ENABLED
|
#if LOGGING_ENABLED == ENABLED
|
||||||
DataFlash.Init();
|
DataFlash.Init();
|
||||||
erase_logs(NULL, NULL);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
need_log_erase = true;
|
||||||
|
|
||||||
// save the new format version
|
// save the new format version
|
||||||
g.format_version.set_and_save(Parameters::k_format_version);
|
g.format_version.set_and_save(Parameters::k_format_version);
|
||||||
|
|
||||||
// save default radio values
|
// save default radio values
|
||||||
default_dead_zones();
|
default_dead_zones();
|
||||||
|
|
||||||
Serial.printf_P(PSTR("Please Run Setup...\n"));
|
|
||||||
while (true) {
|
|
||||||
delay(1000);
|
|
||||||
if(motor_light){
|
|
||||||
digitalWrite(A_LED_PIN, LED_ON);
|
|
||||||
digitalWrite(B_LED_PIN, LED_ON);
|
|
||||||
digitalWrite(C_LED_PIN, LED_ON);
|
|
||||||
}else{
|
|
||||||
digitalWrite(A_LED_PIN, LED_OFF);
|
|
||||||
digitalWrite(B_LED_PIN, LED_OFF);
|
|
||||||
digitalWrite(C_LED_PIN, LED_OFF);
|
|
||||||
}
|
|
||||||
motor_light = !motor_light;
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
// save default radio values
|
// save default radio values
|
||||||
//default_dead_zones();
|
//default_dead_zones();
|
||||||
@ -225,6 +212,28 @@ static void init_ardupilot()
|
|||||||
// identify ourselves correctly with the ground station
|
// identify ourselves correctly with the ground station
|
||||||
mavlink_system.sysid = g.sysid_this_mav;
|
mavlink_system.sysid = g.sysid_this_mav;
|
||||||
|
|
||||||
|
if (need_log_erase) {
|
||||||
|
uint8_t count = 0;
|
||||||
|
gcs_send_text_P(SEVERITY_LOW, PSTR("ERASING LOGS"));
|
||||||
|
do_erase_logs(mavlink_delay);
|
||||||
|
while (true) {
|
||||||
|
if (count++ % 20 == 0) {
|
||||||
|
Serial.printf_P(PSTR("Please Run Setup...\n"));
|
||||||
|
}
|
||||||
|
mavlink_delay(100);
|
||||||
|
if(motor_light){
|
||||||
|
digitalWrite(A_LED_PIN, LED_ON);
|
||||||
|
digitalWrite(B_LED_PIN, LED_ON);
|
||||||
|
digitalWrite(C_LED_PIN, LED_ON);
|
||||||
|
}else{
|
||||||
|
digitalWrite(A_LED_PIN, LED_OFF);
|
||||||
|
digitalWrite(B_LED_PIN, LED_OFF);
|
||||||
|
digitalWrite(C_LED_PIN, LED_OFF);
|
||||||
|
}
|
||||||
|
motor_light = !motor_light;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef RADIO_OVERRIDE_DEFAULTS
|
#ifdef RADIO_OVERRIDE_DEFAULTS
|
||||||
{
|
{
|
||||||
int16_t rc_override[8] = RADIO_OVERRIDE_DEFAULTS;
|
int16_t rc_override[8] = RADIO_OVERRIDE_DEFAULTS;
|
||||||
|
Loading…
Reference in New Issue
Block a user