JEK changes enabling proper recording of IMU/GPS datastrams - 02-APR-2013
Fork of GPS_Incremental by
Diff: OEM615.h
- Revision:
- 6:2a8486283198
- Parent:
- 4:68268737ff89
- Child:
- 9:b45feb91ba38
--- a/OEM615.h Fri Mar 29 20:52:54 2013 +0000 +++ b/OEM615.h Tue Apr 02 15:22:37 2013 +0000 @@ -40,6 +40,26 @@ unsigned long CRC; }; +/* Solution Status descritpion from OEMV manual +0 SOL_COMPUTED Solution computed +1 INSUFFICIENT_OBS Insufficient observations +2 NO_CONVERGENCE No convergence +3 SINGULARITY Singularity at parameters matrix +4 COV_TRACE Covariance trace exceeds maximum (trace > 1000 m) +5 TEST_DIST Test distance exceeded (maximum of 3 rejections if distance >10 km) +6 COLD_START Not yet converged from cold start +7 V_H_LIMIT Height or velocity limits exceeded +8 VARIANCE Variance exceeds limits +9 RESIDUALS Residuals are too large +10 DELTA_POS Delta position is too large +11 NEGATIVE_VAR Negative variance +12 Reserved +13 INTEGRITY_WARNING Large residuals make position unreliable +18 PENDING +19 INVALID_FIX The fixed position, entered using the FIX POSITION command, is not valid +20 UNAUTHORIZED Position type is unauthorized - HP or XP +*/ + #pragma pack(1) //structure for BESTPOS message struct OEM615BESTPOS @@ -72,6 +92,26 @@ unsigned long CRC; }; +//GPS-specific pins +DigitalOut GPS_Reset(p18); //GPS RESET line +InterruptIn PPSInt(p15); // GPS 1PPS (timemark) from the OEM615 +InterruptIn IMUClock(p17); + +Timer timeFromPPS; +unsigned long GPSTimemsecs = 0; +double GPSTime = 0; +int PPSTimeOffset = 0; + +//mbed tx/rx interface to the GPS COM1 port +MODSERIAL GPS_COM1(p9,p10); //this serial port communicates with the GPS receiver serial port (COM1) + +int test = 0; +unsigned short messageCounter = 0; +unsigned short savedMessageCounter = 0; +const unsigned short maxGPSbytesPerSec = 1536; +unsigned char msgBuffer[maxGPSbytesPerSec]; //array to contain one full second of GPS bytes +const unsigned char maxGPSMessagesPerSec = 12; +unsigned short messageLocation[maxGPSMessagesPerSec] = {0}; //stores the message location start within the message buffer //this code was taken from the Novatel Firmware document page 35 #define CRC32_POLYNOMIAL 0xEDB88320L @@ -113,18 +153,54 @@ return( ulCRC ); } -//GPS-specific pins -DigitalOut GPS_Reset(p18); //GPS RESET line -InterruptIn PPSInt(p15); // GPS 1PPS (timemark) from the OEM615 -InterruptIn IMUClock(p17); + +void sendASCII(char* ASCI_message, int numChars) +{ + ///////////////////////////////////////////////// + //send an ASCII command to the GPS receiver + ///////////////////////////////////////////////// + + //char ASCI_message[] = "unlogall COM1"; + int as = numChars - 1; + unsigned char CR = 0x0d; //ASCII Carriage Return + unsigned char LF = 0x0a; //ASCII Line Feed + + //printf("%s", ch); + //printf("\n"); + + for (int i=0; i<as; i++) GPS_COM1.putc(ASCI_message[i]); + GPS_COM1.putc(CR); //carriage return at end + GPS_COM1.putc(LF); //line feed at end +}; + -Timer timeFromPPS; -unsigned long GPSTimemsecs = 0; -double GPSTime = 0; -int PPSTimeOffset = 0; +//see the mbed COOKBOOK for MODSERIAL +//MODSERIAL is an easy to use library that extends Serial to add fully buffered input and output. +void readSerialByte(MODSERIAL_IRQ_INFO *q) +{ + MODSERIAL *serial = q->serial; + unsigned char synch0 = serial->getc(); + msgBuffer[byteCounter % maxGPSbytesPerSec] = synch0; -//mbed tx/rx interface to the GPS COM1 port -MODSERIAL GPS_COM1(p9,p10); //this serial port communicates with the GPS receiver serial port (COM1) + //we need to trap the GPS message header byte-string 0xAA44121C + //generate a 4-byte sliding-window sequence from the input bytes + //shift last 4-byte value left 8 bits & push recently read byte (synch0) into low-order byte + test = (test<<8) | synch0; // + + if (test == 0xAA44121C) //test for the Receiver message header signature + { + messageLocation[perSecMessageCounter % maxGPSMessagesPerSec] = byteCounter-3; //store the location of this message (with 4 synch words) + perSecMessageCounter++; + messageDetected = true; + } + //byteCounter reset to zero in main after the 1PPS is detected -- its NOT reset in the 1PPS ISR + byteCounter++; //total per-sec byte counter (reset to zero in main when 1PPS detected) + +}; + + + +