diff options
author | Herbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com> | 2012-11-04 20:45:14 +0100 |
---|---|---|
committer | Herbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com> | 2012-11-05 00:17:19 +0100 |
commit | 3446253f72f556ecb52d34f8223597081959d004 (patch) | |
tree | 798273667a2011f8d389714c42ec9231853dfed4 | |
parent | 03185b306b27184bc67da06e11234542d032fde2 (diff) | |
download | BlueGPS-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.java | 4 |
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();
|