I think you are overthinking it. You have tons of time to process each sentence as it arrives.
Wait for $
Start accumulating sentence. Optionally update the CRC as you go.
When you have the asterisk, expect the checksum and CRLF. Verify the checksum then parse the sentence based on its type.
If you are only looking for a subset of sentences you can wait for the $ symbol, fetch the next five characters, and drop back to waiting for $ if this sentence is not one you are interested in. Basically ignore everything else that arrives until you get another $.
If you are doing this at a low level the most common way is to implement this as a state machine, where the first state is "wait for $" and the last state is "wait for CRLF". Every time you get an interrupt from the serial port (a character has been received) you update the state machine. If you get to the last state then you know the checksum is correct and it's a sentence you are interested in. Set a flag which lets the main loop know that a sentence is ready.
But, nobody does that these days. They read a line at a time with pyserial, check the checksum and sentence type, then act on it. This happens very fast compared to the glacial rate that the GPS sends characters. Or they use gpsd.
Anyway, to answer what I think is your question, the maximum length of an NMEA sentence is 82 characters, so a 255 byte buffer is not big enough for four sentences (if you collect them all at once, and they are all quite long). As to the "inter-character timer", you might have to read the documentation, although the comments do say it's unused. If you post the rest of the code it might be more helpful to untangle it.
Wait for $
Start accumulating sentence. Optionally update the CRC as you go.
When you have the asterisk, expect the checksum and CRLF. Verify the checksum then parse the sentence based on its type.
If you are only looking for a subset of sentences you can wait for the $ symbol, fetch the next five characters, and drop back to waiting for $ if this sentence is not one you are interested in. Basically ignore everything else that arrives until you get another $.
If you are doing this at a low level the most common way is to implement this as a state machine, where the first state is "wait for $" and the last state is "wait for CRLF". Every time you get an interrupt from the serial port (a character has been received) you update the state machine. If you get to the last state then you know the checksum is correct and it's a sentence you are interested in. Set a flag which lets the main loop know that a sentence is ready.
But, nobody does that these days. They read a line at a time with pyserial, check the checksum and sentence type, then act on it. This happens very fast compared to the glacial rate that the GPS sends characters. Or they use gpsd.
Anyway, to answer what I think is your question, the maximum length of an NMEA sentence is 82 characters, so a 255 byte buffer is not big enough for four sentences (if you collect them all at once, and they are all quite long). As to the "inter-character timer", you might have to read the documentation, although the comments do say it's unused. If you post the rest of the code it might be more helpful to untangle it.
Statistics: Posted by ame — Thu Jun 12, 2025 9:32 am