ACM: run mavlink loop while erasing logs

This commit is contained in:
Andrew Tridgell 2011-12-18 10:19:41 +11:00
parent ce035fc324
commit 1807585b98
2 changed files with 35 additions and 19 deletions

View File

@ -138,8 +138,8 @@ dump_log(uint8_t argc, const Menu::arg *argv)
return (0);
}
static int8_t
erase_logs(uint8_t argc, const Menu::arg *argv)
static void
do_erase_logs(void (*delay_cb)(unsigned long))
{
Serial.printf_P(PSTR("\nErasing log...\n"));
DataFlash.SetFileNumber(0xFFFF);
@ -147,10 +147,17 @@ erase_logs(uint8_t argc, const Menu::arg *argv)
DataFlash.PageErase(j);
DataFlash.StartWrite(j); // We need this step to clean FileNumbers
if(j%128 == 0) Serial.printf_P(PSTR("+"));
delay_cb(1);
}
Serial.printf_P(PSTR("\nLog erased.\n"));
DataFlash.FinishWrite();
}
static int8_t
erase_logs(uint8_t argc, const Menu::arg *argv)
{
do_erase_logs(delay);
return 0;
}

View File

@ -55,6 +55,8 @@ static void run_cli(void)
static void init_ardupilot()
{
bool need_log_erase = false;
#if USB_MUX_PIN > 0
// on the APM2 board we have a mux thet switches UART0 between
// 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
#if LOGGING_ENABLED == ENABLED
DataFlash.Init();
erase_logs(NULL, NULL);
#endif
need_log_erase = true;
// save the new format version
g.format_version.set_and_save(Parameters::k_format_version);
// save default radio values
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{
// save default radio values
//default_dead_zones();
@ -225,6 +212,28 @@ static void init_ardupilot()
// identify ourselves correctly with the ground station
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
{
int16_t rc_override[8] = RADIO_OVERRIDE_DEFAULTS;