GPS Forums


Reply
Thread Tools Display Modes

problem in NMEA parser

 
 
Junior Member
Join Date: Feb 2011
Posts: 1
 
      02-19-2011, 06:20 AM
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Scottish contour maps Moonraker Garmin GPS 2 04-23-2012 12:39 PM
Reading the mail -- New Problem with GPS IIF-1? HIPAR Global Navigation Satellite Systems 5 01-01-2011 07:59 PM


All times are GMT. The time now is 11:59 AM.

1 2 3 4 5 6 7 8 9