Maker Pro
Maker Pro

Serial port synchronization(Buffer threshold or time interval?)

S

Suraj

Jan 1, 1970
0
Hi All,
I am trying to read a *variable length* string (from a Garmin GPS, @1Hz) on
my PC serial port using the MSCOMM Control in VB. Now, I'm stumped by this:
The COMM control can generates a "recieve Event" when the specified
"Threshold" of characters in the buffer is met. Now my string is variable
length, If I specify a threshold that's less (I can't know!) I get multiple
"Recieve Events" and my string is cut into many pieces. While I know that
the GPS sends the string at 1 sec Intervals, but how do I syncronize with
this? I get half-cut strings if I start reading from program loadup.

I know there must be a simple handshaking technique that I don't know about.

Many thanks
 
P

Peter Bennett

Jan 1, 1970
0
Hi All,
I am trying to read a *variable length* string (from a Garmin GPS, @1Hz) on
my PC serial port using the MSCOMM Control in VB. Now, I'm stumped by this:
The COMM control can generates a "recieve Event" when the specified
"Threshold" of characters in the buffer is met. Now my string is variable
length, If I specify a threshold that's less (I can't know!) I get multiple
"Recieve Events" and my string is cut into many pieces. While I know that
the GPS sends the string at 1 sec Intervals, but how do I syncronize with
this? I get half-cut strings if I start reading from program loadup.

I know there must be a simple handshaking technique that I don't know about.

Many thanks

I assume you are receiving NMEA-0183 data from the GPS.

You need to read the incomming data a character at a time, and look
for the "$" that identifies the start of an NMEA-0183 sentence,
discarding characters til you find it. You can then discard the next
two characters (talker ID), and look at the next three (sentence ID)
to decide what to do with the remainder of the sentence.
 
Top