diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2014-09-12 00:16:36 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2014-09-12 00:16:36 +1200 |
commit | 2f7e6af55b1a4d65abe3187ca34b4d1d587c833b (patch) | |
tree | 3af7e22f000d5846471e866c3349082a96020dab | |
parent | 0bf776895d82bf70a0e29c67a064024cd24a8927 (diff) | |
download | trackermap-server-2f7e6af55b1a4d65abe3187ca34b4d1d587c833b.tar.gz trackermap-server-2f7e6af55b1a4d65abe3187ca34b4d1d587c833b.tar.bz2 trackermap-server-2f7e6af55b1a4d65abe3187ca34b4d1d587c833b.zip |
Update Wialon regex
-rw-r--r-- | src/org/traccar/protocol/WialonProtocolDecoder.java | 14 | ||||
-rw-r--r-- | test/org/traccar/protocol/WialonProtocolDecoderTest.java | 3 | ||||
-rwxr-xr-x | tools/hex.sh | 2 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java index 6ed597d2f..db9f7b1f6 100644 --- a/src/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/org/traccar/protocol/WialonProtocolDecoder.java @@ -47,7 +47,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { "(\\d+\\.?\\d*);" + // Speed "(\\d+\\.?\\d*);" + // Course "(?:(\\d+\\.?\\d*)|NA);" + // Altitude - "(\\d+)" + // Satellites + "(?:(\\d+)|NA)" + // Satellites ".*"); // Full format private void sendResponse(Channel channel, String prefix, Integer number) { @@ -62,7 +62,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { } private Position decodePosition(String substring) { - + // Parse message Matcher parser = pattern.matcher(substring); if (deviceId == null || !parser.matches()) { @@ -114,9 +114,13 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { } // Satellites - int satellites = Integer.valueOf(parser.group(index++)); - position.setValid(satellites >= 3); - extendedInfo.set("satellites", satellites); + String satellites = parser.group(index++); + if (satellites != null) { + position.setValid(Integer.valueOf(satellites) >= 3); + extendedInfo.set("satellites", satellites); + } else { + position.setValid(false); + } // Extended info position.setExtendedInfo(extendedInfo.toString()); diff --git a/test/org/traccar/protocol/WialonProtocolDecoderTest.java b/test/org/traccar/protocol/WialonProtocolDecoderTest.java index 678126df0..a8a369bfc 100644 --- a/test/org/traccar/protocol/WialonProtocolDecoderTest.java +++ b/test/org/traccar/protocol/WialonProtocolDecoderTest.java @@ -30,6 +30,9 @@ public class WialonProtocolDecoderTest { verify(decoder.decode(null, null, "#B#080914;073235;5027.50625;N;03026.19321;E;0.700;0.000;NA;4;NA;NA;NA;;NA;Батарея:3:100 %|080914;073420;5027.50845;N;03026.18854;E;1.996;292.540;NA;4;NA;NA;NA;;NA;Батарея:3:100 %")); + + verify(decoder.decode(null, null, + "#B#110914;102132;5027.50728;N;03026.20369;E;1.979;288.170;NA;NA;NA;NA;NA;;NA;Батарея:3:100 %")); } diff --git a/tools/hex.sh b/tools/hex.sh index 2c3faa1ab..16a34b0d8 100755 --- a/tools/hex.sh +++ b/tools/hex.sh @@ -1,2 +1,2 @@ -echo 2342233038303931343b3037333233353b353032372e35303632353b4e3b30333032362e31393332313b453b302e3730303b302e3030303b4e413b343b4e413b4e413b4e413b3b4e413bd091d0b0d182d0b0d180d0b5d18f3a333a31303020257c3038303931343b3037333432303b353032372e35303834353b4e3b30333032362e31383835343b453b312e3939363b3239322e3534303b4e413b343b4e413b4e413b4e413b3b4e413bd091d0b0d182d0b0d180d0b5d18f3a333a31303020250d0a | perl -ne 's/([0-9a-f]{2})/print chr hex $1/gie' | nc -v -w 10 localhost 5039 +echo 234c233335323936343035313930383636343b4e410d0a2342233131303931343b3130323133323b353032372e35303732383b4e3b30333032362e32303336393b453b312e3937393b3238382e3137303b4e413b4e413b4e413b4e413b4e413b3b4e413bd091d0b0d182d0b0d180d0b5d18f3a333a31303020250d0a | perl -ne 's/([0-9a-f]{2})/print chr hex $1/gie' | nc -v -w 10 localhost 5039 #echo -n -e "\x0f\x00\x00\x00\x4e\x52\x30\x39\x46\x30\x34\x31\x35\x35\x00" >/dev/udp/localhost/5053 |