most functionality to splashdwon, find neutral and start mission. short timeouts still in code for testing, will adjust to go directly to sit_idle after splashdown
Dependencies: mbed MODSERIAL FATFileSystem
Diff: main.cpp
- Revision:
- 85:dd8176285b6e
- Parent:
- 84:eccd8e837134
- Child:
- 86:ba3a118b0080
diff -r eccd8e837134 -r dd8176285b6e main.cpp --- a/main.cpp Tue Feb 19 20:11:43 2019 +0000 +++ b/main.cpp Mon Feb 25 21:26:34 2019 +0000 @@ -22,7 +22,8 @@ void log_loop_trigger() { log_loop = true;} // log loop trigger (used in while loop) static int current_state = 0; -static int have_legfile = 0; +static int have_legfile = 0; +static int upside_down = 0; static bool file_opened = false; void FSM() { // FSM loop runs at 10 hz @@ -216,7 +217,7 @@ //xbee().printf("\n\n\r 2018-08-14 FSG PCB XBee (setup complete) \n\n\r"); sprintf(buf, "\n\n\r in setup(): starting legController().loadleg() \n\n\r"); mbedLogger().appendDiagFile(buf,0); - have_legfile = legController().loadLeg(); + have_legfile = legController().loadLeg(); // this should be 1 if the legfile reader has found 1 or more legs //set time of logger (to current or close-to-current time) now set earlier at line 149 // mbedLogger().setLogTime(); @@ -281,7 +282,7 @@ sprintf(buf, "logfiles_struct values - direct LOG FILE VERSION ().logversion=%d diag file version().diagversion = %d\n", configFileIO().logFilesStruct.logversion, configFileIO().logFilesStruct.diagversion); mbedLogger().appendDiagFile(buf,3); - sprintf(buf, "try another messgae after closing file up and then will exit\n\n\r"); + sprintf(buf, "try another message after closing file up and then will exit\n\n\r"); mbedLogger().appendDiagFile(buf,0); @@ -299,6 +300,10 @@ //install the leg variables in a structure, and set the state there. stateMachine().getLegParams(); //should set up everything with proper LEG_POSITION_DIVE state } + if(upside_down ) { // should this be done inside the statemachine? + //turn right side up ; + upside_down =0; + } while (keeprunning) { if( read_ticker() ) { // read_ticker runs at the speed of 10 kHz (adc timing) ++tNow; @@ -326,20 +331,20 @@ if ( (tNow % 1000) == 0 ) { // 1.0 second intervals log_loop = true; log_function(); - sprintf(buf, "hit 1 second log interval in main loop tNow =%d \n\n\r", tNow); + sprintf(buf, "hit 1 second log interval in main loop tNow =%d imu.roll = %f not-unsampled \n\n\r", tNow, imu().getRoll()); mbedLogger().appendDiagFile(buf,0); } //update the log and diagnostics files - if ( (tNow % 4600) == 0 ) { // 1.0 hour intervals check for testing via 7 second intervals - sprintf(buf, "hit 4.6 second replace_logfiles interval in main loop tNow =%d \n\n\r", tNow); - mbedLogger().appendDiagFile(buf,0); + if ( (tNow % 31000) == 0 ) { // 1.0 hour intervals= 3600*1000 check for testing via 4 second intervals + sprintf(buf, "hit cycle seconds replace_logfiles interval in main loop tNow =%d \n\n\r", tNow); + mbedLogger().appendDiagFile(buf,3); vernum = configFileIO().logFilesStruct.logversion; diagnum = configFileIO().logFilesStruct.diagversion; - sprintf(buf, "cycle log file names at 7.6 seconds. This message should be in old diag file\n\n\r"); + sprintf(buf, "cycle log file names at tnow=%d at seconds. This message should be in old diag file\n\n\r", tNow); mbedLogger().appendDiagFile(buf,0); cycle_logfiles(vernum,diagnum); - sprintf(buf, "cycled log files at 7 seconds, This message should be in a NEW diag file\n\n\r"); - mbedLogger().appendDiagFile(buf,0); + sprintf(buf, "cycled log files at tNow = %d at seconds, This message should be in a NEW diag file\n\n\r", tNow); + mbedLogger().appendDiagFile(buf,3); // close the log and diagnostics files // increment the version numbers for each // save the new version numbers @@ -352,6 +357,7 @@ log_loop=true; log_function(); keeprunning=0; // and this will force exit to the main while() loop. + // switch state to EOL_WAIT, spit out xbee messages, wait 60 seconds or so. if keyboard comes back, do not exit sprintf(buf, "INSIDE main loop: BUT now called to exit out of it via FB_EXIT\n\n\r"); mbedLogger().appendDiagFile(buf,0); }