Skip to content

Commit

Permalink
bug correction in NMEA checksum management
Browse files Browse the repository at this point in the history
When NMEA sentences had no checksum the paser failed to match the sentences because it was expecting a "*" at the end of the sentences which was wrong.
  • Loading branch information
HvB committed Nov 4, 2012
1 parent 06eea88 commit 58675bf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ private void notifyStatusChanged(int status, Bundle extras, long updateTime){
public String parseNmeaSentence(String gpsSentence) throws SecurityException {
String nmeaSentence = null;
Log.v(LOG_TAG, "data: "+System.currentTimeMillis()+" "+gpsSentence);
Pattern xx = Pattern.compile("\\$([^*$]*)\\*([0-9A-F][0-9A-F])?\r\n");
Pattern xx = Pattern.compile("\\$([^*$]*)(?:\\*([0-9A-F][0-9A-F]))?\r\n");
Matcher m = xx.matcher(gpsSentence);
if (m.matches()){
nmeaSentence = m.group(0);
String sentence = m.group(1);
String checkSum = m.group(2);
Log.v(LOG_TAG, "data: "+System.currentTimeMillis()+" "+sentence+" cheksum; "+checkSum +" control: "+String.format("%02X",computeChecksum(sentence)));
Log.v(LOG_TAG, "data: "+System.currentTimeMillis()+" "+sentence+" cheksum: "+checkSum +" control: "+String.format("%02X",computeChecksum(sentence)));
SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
splitter.setString(sentence);
String command = splitter.next();
Expand Down

0 comments on commit 58675bf

Please sign in to comment.