diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-06-19 17:44:37 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-06-19 17:44:37 -0700 |
commit | 29c560027dc3ecdf59d13cd11a6423047d9ed95a (patch) | |
tree | 88ef309b93e4ddbb9de8d0a06cafb273e2016742 | |
parent | 0497f1da3dd4f7a2bc94cd9418ea6fe896615f97 (diff) | |
download | traccar-server-29c560027dc3ecdf59d13cd11a6423047d9ed95a.tar.gz traccar-server-29c560027dc3ecdf59d13cd11a6423047d9ed95a.tar.bz2 traccar-server-29c560027dc3ecdf59d13cd11a6423047d9ed95a.zip |
Fix driver id decoding
-rw-r--r-- | src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java | 6 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/FifotrackProtocolDecoderTest.java | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java index 2e728a918..cc4eaa790 100644 --- a/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/FifotrackProtocolDecoder.java @@ -69,7 +69,7 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder { .number("(x+),") // cid .number("([x|]+)") // adc .expression(",([^,]+)") // rfid - .expression(",([^*]+)").optional(2) // sensors + .expression(",([^*]*)").optional(2) // sensors .any() .compile(); @@ -149,7 +149,9 @@ public class FifotrackProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + (i + 1), Integer.parseInt(adc[i], 16)); } - position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); + if (parser.hasNext()) { + position.set(Position.KEY_DRIVER_UNIQUE_ID, String.valueOf(parser.nextHexInt())); + } if (parser.hasNext()) { String[] sensors = parser.next().split("\\|"); diff --git a/src/test/java/org/traccar/protocol/FifotrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FifotrackProtocolDecoderTest.java index 11492fb6f..16572fb47 100644 --- a/src/test/java/org/traccar/protocol/FifotrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FifotrackProtocolDecoderTest.java @@ -2,6 +2,7 @@ package org.traccar.protocol; import org.junit.Test; import org.traccar.ProtocolTest; +import org.traccar.model.Position; public class FifotrackProtocolDecoderTest extends ProtocolTest { @@ -10,6 +11,10 @@ public class FifotrackProtocolDecoderTest extends ProtocolTest { FifotrackProtocolDecoder decoder = new FifotrackProtocolDecoder(null); + verifyAttribute(decoder, buffer( + "$$125,869467049296388,548,A01,38,190619025856,A,22.333905,113.590261,0,12,60,16666,0,0000,00,0,460|0|2694|13F8,1A2|4C1|0|0,B4A067,*7A"), + Position.KEY_DRIVER_UNIQUE_ID, "11837543"); + verifyNull(decoder, buffer( "$$79,868345037864709,382,D05,190220085833,22.643210,114.018176,1,1,1,13152,23FFD339*25")); |