diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-13 10:09:06 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-13 10:09:25 +1300 |
commit | a789d3992ec5c5918a122c284fe46e4f1e26b746 (patch) | |
tree | fd1fd60b42b87e9344e4244284dba3a7e98d63b7 | |
parent | 8abf4f011eef72e06dd24720e00ce27350b0b047 (diff) | |
download | trackermap-server-a789d3992ec5c5918a122c284fe46e4f1e26b746.tar.gz trackermap-server-a789d3992ec5c5918a122c284fe46e4f1e26b746.tar.bz2 trackermap-server-a789d3992ec5c5918a122c284fe46e4f1e26b746.zip |
Handle ST600 empty values
-rw-r--r-- | src/org/traccar/protocol/SuntechProtocolDecoder.java | 8 | ||||
-rw-r--r-- | test/org/traccar/protocol/SuntechProtocolDecoderTest.java | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java index 48eb3a71d..ad1da537b 100644 --- a/src/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java @@ -317,9 +317,11 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { } if (includeAdc) { - position.set(Position.PREFIX_ADC + 1, Double.parseDouble(values[index++])); - position.set(Position.PREFIX_ADC + 2, Double.parseDouble(values[index++])); - position.set(Position.PREFIX_ADC + 3, Double.parseDouble(values[index++])); + for (int i = 1; i <= 3; i++) { + if (!values[index++].isEmpty()) { + position.set(Position.PREFIX_ADC + i, Double.parseDouble(values[index - 1])); + } + } } if (values.length - index >= 2) { diff --git a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java index 7e4de91d6..daf011206 100644 --- a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java +++ b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java @@ -20,6 +20,9 @@ public class SuntechProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, text( "ST300EVT;205173382;07;564;20160322;23:23:18;232e19;+19.288278;-099.128750;000.122;000.00;9;1;478391;11.53;000100;2;1;9498;079324;4.3;1;0.00;0.00;0.00;00000000000000;0;2898E16006000058:-20.8;2861626006000039:+2.5;:")); + verifyPosition(decoder, text( + "ST600STT;008349958;35;523;20181112;00:49:30;0bf10d4e;334;20;2f19;22;+20.552718;-100.824478;050.021;095.41;12;1;1303603;14.30;10000000;4;8911;001987;4.1;0;0.00;;;;00000000000000;0;2826C8A70800000C:+26.6;:;:")); + } @Test |