this version has all of Jim's fixes for reading the GPS and IMU data synchronously
Dependencies: MODSERIAL SDFileSystem mbed SDShell CRC CommHandler FP LinkedList LogUtil
Diff: main.cpp
- Revision:
- 20:3f04a0bde484
- Parent:
- 19:26c5298a7138
- Child:
- 22:1cbdbc856660
diff -r 26c5298a7138 -r 3f04a0bde484 main.cpp --- a/main.cpp Mon May 13 04:42:27 2013 +0000 +++ b/main.cpp Tue May 14 00:59:34 2013 +0000 @@ -270,7 +270,11 @@ processPCmessages(fpNav, posMsg, velMsg); - if (get_file_msg) break; //terminate the while loop when we receive this message from the PC + if (get_file_msg) + { + if (fpNav != NULL) fclose(fpNav); + break; //terminate the while loop when we receive this message from the PC + } if(fireTrigger) //comes from a PC request message { @@ -372,8 +376,8 @@ { //delTimeOfWrite = timeFromStart.read_us(); - if (fillingPingWritingPong) fwrite(&imuPong, 1, IMUrecArraySize*sizeof(IMUREC), fpNav); - else fwrite(&imuPing, 1, IMUrecArraySize*sizeof(IMUREC), fpNav); + if (fillingPingWritingPong) totalBytesWritten += fwrite(&imuPong, 1, IMUrecArraySize*sizeof(IMUREC), fpNav); + else totalBytesWritten += fwrite(&imuPing, 1, IMUrecArraySize*sizeof(IMUREC), fpNav); //delTimeOfWrite = (unsigned long)((unsigned long)timeFromStart.read_us() - delTimeOfWrite); //if (delTimeOfWrite > maxWriteTime) maxWriteTime = delTimeOfWrite; @@ -395,8 +399,9 @@ // totalBytesWritten, cyclesPerSec ); cyclesPerSec = 0; - totalBytesWritten = 0; + //totalBytesWritten = 0; GPSdataWritten = false; + toPC.printf(" bytesWritten = %5d \n", totalBytesWritten); IMURecordCounter = 0; detectedGPS1PPS = false; @@ -404,13 +409,22 @@ } - if (fpNav != NULL) fclose(fpNav); //insurance + if (fpNav != NULL) + { + fclose(fpNav); //insurance + toPC.printf(" closing fpNav before transfer \n"); + } + + toPC.printf(" totalBytesWritten = %5d \n", totalBytesWritten); + wait_ms(100); + transferFile(); //rxMsg = txMsg = 0; // just indicate that we're in here // to exit this function the HOST (ie: computer or PC app) must send "exit" otherwise the mbed will act // like a terminal and serve SD file data forever toPC.printf(" normal termination of single mission \n"); + wait_ms(100); NVIC_SystemReset();