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:17:19 +0100
commit3446253f72f556ecb52d34f8223597081959d004 (patch)
tree798273667a2011f8d389714c42ec9231853dfed4
parent03185b306b27184bc67da06e11234542d032fde2 (diff)
downloadBlueGPS-3446253f72f556ecb52d34f8223597081959d004.zip
BlueGPS-3446253f72f556ecb52d34f8223597081959d004.tar.gz
BlueGPS-3446253f72f556ecb52d34f8223597081959d004.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();