From 98162399456d9386797f7b2cce48e4d93299ad82 Mon Sep 17 00:00:00 2001 From: Vitaly Litvak Date: Thu, 29 Oct 2015 00:19:36 +0300 Subject: For #1484 - updated GlobalSat alternative decoder to support EusPro SF-400 device, fixed validity detection which was broken during refactoring --- src/org/traccar/protocol/GlobalSatProtocolDecoder.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java index 049bb2f7f..918f17348 100644 --- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java +++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java @@ -180,7 +180,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { .text("$") .number("(d+),") // imei .number("d+,") // mode - .number("(d),") // fix + .number("(d+),") // fix .number("(dd)(dd)(dd),") // date (ddmmyy) .number("(dd)(dd)(dd),") // time (hhmmss) .expression("([EW])") @@ -189,8 +189,8 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { .number("(dd)(dd.d+),") // latitude (ddmm.mmmm) .number("(d+.?d*),") // altitude .number("(d+.?d*),") // speed - .number("(d+.?d*),") // course - .number("(d+),") // satellites + .number("(d*.?d*),") // course + .number("(d+)[,\\\\*]") // satellites .number("(d+.?d*)") // hdop .compile(); @@ -209,7 +209,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(getDeviceId()); - position.setValid(parser.next().equals("1")); + position.setValid(!parser.next().equals("1")); DateBuilder dateBuilder = new DateBuilder() .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()) @@ -220,7 +220,8 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN)); position.setAltitude(parser.nextDouble()); position.setSpeed(parser.nextDouble()); - position.setCourse(parser.nextDouble()); + String course = parser.next(); + position.setCourse(course.isEmpty() ? 0d : Double.parseDouble(course)); position.set(Event.KEY_SATELLITES, parser.nextInt()); position.set(Event.KEY_HDOP, parser.next()); -- cgit v1.2.3 From 4293e68b893098a34317e8c6adfd4027130a3796 Mon Sep 17 00:00:00 2001 From: Vitaly Litvak Date: Thu, 29 Oct 2015 00:44:36 +0300 Subject: Updated pattern per pull request comments --- src/org/traccar/protocol/GlobalSatProtocolDecoder.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java index 918f17348..3bc626838 100644 --- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java +++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java @@ -180,7 +180,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { .text("$") .number("(d+),") // imei .number("d+,") // mode - .number("(d+),") // fix + .number("(d+),") // fix .number("(dd)(dd)(dd),") // date (ddmmyy) .number("(dd)(dd)(dd),") // time (hhmmss) .expression("([EW])") @@ -189,8 +189,8 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { .number("(dd)(dd.d+),") // latitude (ddmm.mmmm) .number("(d+.?d*),") // altitude .number("(d+.?d*),") // speed - .number("(d*.?d*),") // course - .number("(d+)[,\\\\*]") // satellites + .number("(d+.?d*)?,") // course + .number("(d+)[,\\*]") // satellites .number("(d+.?d*)") // hdop .compile(); @@ -220,8 +220,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.HEM_DEG_MIN)); position.setAltitude(parser.nextDouble()); position.setSpeed(parser.nextDouble()); - String course = parser.next(); - position.setCourse(course.isEmpty() ? 0d : Double.parseDouble(course)); + position.setCourse(parser.nextDouble()); position.set(Event.KEY_SATELLITES, parser.nextInt()); position.set(Event.KEY_HDOP, parser.next()); -- cgit v1.2.3 From e134adb5f7518c6e38782166666d3de71e0a5f69 Mon Sep 17 00:00:00 2001 From: Vitaly Litvak Date: Thu, 29 Oct 2015 00:49:44 +0300 Subject: Removed backslash from last field in pattern --- src/org/traccar/protocol/GlobalSatProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java index 3bc626838..b4c64f750 100644 --- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java +++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java @@ -190,7 +190,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { .number("(d+.?d*),") // altitude .number("(d+.?d*),") // speed .number("(d+.?d*)?,") // course - .number("(d+)[,\\*]") // satellites + .number("(d+)[,*]") // satellites .number("(d+.?d*)") // hdop .compile(); -- cgit v1.2.3