aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2012-11-04 20:45:14 +0100
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2012-11-05 00:26:47 +0100
commitf40e1ab9d1ee9f425e442898cc21775e1c516e88 (patch)
tree774c97cc24032ce37db6c38dede48b08d7fc424c
parent46d6ca48052429b6308600587abad0e0bd78368f (diff)
downloadBlueGPS-f40e1ab9d1ee9f425e442898cc21775e1c516e88.zip
BlueGPS-f40e1ab9d1ee9f425e442898cc21775e1c516e88.tar.gz
BlueGPS-f40e1ab9d1ee9f425e442898cc21775e1c516e88.tar.bz2
bug correction in NMEA checksum management
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.
-rw-r--r--src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java b/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
index fe2e70c..f56eee2 100644
--- a/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
+++ b/src/org/broeuschmeul/android/gps/nmea/util/NmeaParser.java
@@ -214,13 +214,13 @@ public class NmeaParser {
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();