Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MODSERIAL SDFileSystem mbed SDShell CRC CommHandler FP LinkedList LogUtil
Revision 2:7039be3daf6e, committed 2013-05-03
- Comitter:
- jekain314
- Date:
- Fri May 03 19:27:56 2013 +0000
- Parent:
- 1:8e24e633f8d8
- Child:
- 3:e1a884e5325a
- Commit message:
- Added an auto file-open when POSVEL message is received. Added auto-close when the elapsed time between POSVEL messages is > 60sec This reduces the necessary startup procedures on the PC side. Also prevents loss of data if the PC fails.
Changed in this revision
| PCMessaging.h | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/PCMessaging.h Tue Apr 30 19:59:43 2013 +0000
+++ b/PCMessaging.h Fri May 03 19:27:56 2013 +0000
@@ -96,6 +96,7 @@
validMessage = true;
serBufChars = 0; //reset the character count to reset for next message
+
//set programmatic action flags based on the message
switch(m)
@@ -105,6 +106,7 @@
break;
case POSVEL_MSG:
sendPosVel = true; //send a posvel message back to PC
+ timeFromPosVelMessageReceipt.reset(); //start time and close SD card file if too long
break;
case STARTDATA_MSG: //start the data recording to the SD card
recordData = true;
@@ -228,6 +230,15 @@
//perform the activities as a response to the commands
if (sendPosVel) //true if we want to return a position solution
{
+ //if we are receiving POSVEL requests -- always open the file for storage and store the data
+ //th file is closed(in main) if we dont receive POSVAL messages for 60 secs
+ if (fpNav == NULL)
+ {
+ toPC.printf(" opening the SD card file \n");
+ fpNav = fopen("/sd/Data/NAV.bin", "wb");
+ wait_ms(10);
+ recordData = true;
+ }
sendPosVel=false; //set to true if a POSVEL is requested from the PC
sendPosVelMessageToPC(posMsg, velMsg);
}
@@ -261,7 +272,7 @@
{
toPC.printf(" opening the SD card file \n");
fpNav = fopen("/sd/Data/NAV.bin", "wb");
- wait_ms(1000);
+ wait_ms(10);
}
if (fpNav != NULL) //if the fie was already opened we will respond to the PC with a Y
{
--- a/main.cpp Tue Apr 30 19:59:43 2013 +0000
+++ b/main.cpp Fri May 03 19:27:56 2013 +0000
@@ -26,6 +26,7 @@
Serial toPC(USBTX, USBRX); //connect the GPS TX, RX to p9 and p10
Timer timeFromStart;
+Timer timeFromPosVelMessageReceipt;
bool detectedGPS1PPS = false; //flag set in the ISR and reset after processing the 1PPS event
int PPSCounter = 0; //counts the 1PPS occurrences
@@ -232,6 +233,15 @@
//read the USB serial data from the PC to check for commands
//in the primary real-time portion, there are no bytes from the PC so this has no impact
readFromPC();
+
+ //this will close the fpNav file on the SD card if the file is open
+ //and the elapsed time from PosVel messages is > 60 secs
+ //this prevents loosing the fpNav file if the PC goes down
+ if (fpNav && (timeFromPosVelMessageReceipt.read() < 60) )
+ {
+ sendRecData = true;
+ recordData = false;
+ }
processPCmessages(fpNav, posMsg, velMsg);
@@ -241,7 +251,7 @@
pre_fire = 0; //pin30 (midbody of connector) set to zero
wait(.01f); //wait for 0.25 secs
fire = 0; //fire the trigger using the tip connection
- wait(1.0);
+ wait(0.10);
fire = 1;
pre_fire = 1;
unsigned long triggerTime = GPSTimemsecs + PPSTimeOffset*1000 + timeFromPPS.read_us()/1000.0;
