problem in NMEA parser

Joined
Feb 19, 2011
Messages
1
Reaction score
0
hello everybody, i am having difficulty to calculate speed from bluetooth GPS
i am using the following codes,
public void readNMEASentences() {
try {
if (!isConnected) {
return;
}
// check characters available
int size = in.available();
if (size <= 0) {
return;
}
// read data
for (int j = 0; j < size; j++) {
int i = in.read();
if (i != -1) {
char l = (char) i;
switch (mode) {
case (STATE_SEARCH_SENTENCE_BEGIN): {
// search for the sentence begin
if (l == '$') {
// found begin of sentence
mode = 1;
sb.setLength(0);
}
}
break;
case (STATE_READ_DATA_TYPE): {
// check what kind of sentence we have
sb.append(l);
if (sb.length() == 6) {
if (sb.toString().startsWith("GPGGA")) {
mode = STATE_READ_SENTENCE;
sb.setLength(0);
} else {
mode = STATE_SEARCH_SENTENCE_BEGIN;
sb.setLength(0);
}
}
}
break;
case (STATE_READ_SENTENCE): {
// read data from sentence
sb.append(l);
if ((l == 13) || (l == 10) || (l == '$')) {
mode = STATE_SEARCH_SENTENCE_BEGIN;
currentInfo = new String(sb.toString());
}
}
break;
}

} else {
close();
}
}

} catch (Exception e) {
close();
}
}


and can't figure out where to place GPRMC exactly, am always having errors, plz help
Thank u
 

Members online

No members online now.
Back
Top