Slightly modified version of the SerialGPS library (https://os.mbed.com/teams/components/code/SerialGPS/) to support the BufferedSerial class
Diff: SerialGPS.cpp
- Revision:
- 5:cc8f9d7f9bdb
- Parent:
- 4:2c76f1ec13a9
--- a/SerialGPS.cpp Thu Apr 01 21:18:48 2021 +0200 +++ b/SerialGPS.cpp Fri Apr 23 09:38:08 2021 +0200 @@ -134,27 +134,17 @@ void SerialGPS::getline() { char ch; - int idx = -1; + uint8_t idx = 0; - if(!this->_gps_p->readable()) { return; } + //MBED_ASSERT(this->_gps->readable()); // Wait for start of sentence while(read_char() != '$'); - // Read from serial one char at a time until max length or read terminal - while(idx++ <= MAX_LINELENGTH) + // Read character until EOL + while((ch = read_char()) != '\r') { - ch = read_char(); - - if(ch == '\r') { break; } - this->_nmea[idx] = ch; + idx++; } -} - -char SerialGPS::read_char() -{ - char ch; - _gps_p->read(&ch, 1); - return ch; } \ No newline at end of file