Basic GPS message parser
Fork of GPS by
Diff: GPS.cpp
- Revision:
- 2:8c97b7918a94
- Parent:
- 1:1f849dbf3b8b
- Child:
- 3:ac28455d8e5a
diff -r 1f849dbf3b8b -r 8c97b7918a94 GPS.cpp --- a/GPS.cpp Wed Aug 19 06:58:44 2015 +0000 +++ b/GPS.cpp Mon Feb 15 20:56:20 2016 +0000 @@ -22,8 +22,8 @@ #include "GPS.h" -GPS::GPS(PinName tx, PinName rx) : _gps(tx, rx) { - _gps.baud(38400); +GPS::GPS(PinName tx, PinName rx, int baudrate) : _gps(tx, rx) { + _gps.baud(baudrate); longitude = 0.0; latitude = 0.0; } @@ -66,10 +66,10 @@ } float GPS::trunc(float v) { - if(v < 0.0) { - v*= -1.0; + if(v < 0.0f) { + v*= -1.0f; v = floor(v); - v*=-1.0; + v*=-1.0f; } else { v = floor(v); } @@ -78,13 +78,14 @@ void GPS::getline() { while(_gps.getc() != '$'); // wait for the start of a line - for(int i=0; i<256; i++) { + for(int i=0; i<255; i++) { msg[i] = _gps.getc(); +// printf("%c",msg[i]); if(msg[i] == '\r') { msg[i] = 0; return; } } - error("Overflowed message limit"); +// error("Overflowed message limit"); // printf("Overflow"); }