diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-09-07 12:43:51 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-09-07 12:43:51 -0700 |
commit | e1077019a5ff970b98c934af9a170547d9d55e5d (patch) | |
tree | 95e4f82d5b630d1f0b068cbb56d755759a738c4e /src | |
parent | 7a4f5abd6c0ce56032f8e095e94ff4acf170aef6 (diff) | |
download | trackermap-server-e1077019a5ff970b98c934af9a170547d9d55e5d.tar.gz trackermap-server-e1077019a5ff970b98c934af9a170547d9d55e5d.tar.bz2 trackermap-server-e1077019a5ff970b98c934af9a170547d9d55e5d.zip |
Decode Kimax weight sensor data
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java | 14 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java | 3 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java index 485df833a..c634d2438 100644 --- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -157,7 +157,19 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { } if (readable) { - position.set(Position.KEY_RESULT, buf.readSlice(length).toString(StandardCharsets.US_ASCII)); + String data = buf.readSlice(length).toString(StandardCharsets.US_ASCII).trim(); + if (data.startsWith("UUUUww") && data.endsWith("SSS")) { + String[] values = data.substring(6, data.length() - 4).split(";"); + for (int i = 0; i < 8; i++) { + position.set("axle" + (i + 1), Double.parseDouble(values[i])); + } + position.set("loadTruck", Double.parseDouble(values[8])); + position.set("loadTrailer", Double.parseDouble(values[9])); + position.set("totalTruck", Double.parseDouble(values[10])); + position.set("totalTrailer", Double.parseDouble(values[11])); + } else { + position.set(Position.KEY_RESULT, data); + } } else { position.set(Position.KEY_RESULT, ByteBufUtil.hexDump(buf.readSlice(length))); } diff --git a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java index b515fbdc6..827e12a96 100644 --- a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java @@ -16,6 +16,9 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest { "000F313233343536373839303132333435")); verifyPositions(decoder, false, binary( + "000000000000004f0c01060000004755555555777730362e343b30342e323b30302e303b30302e303b30302e303b30302e303b30302e303b30302e303b30312e333b30302e303b31302e373b30302e303b5353530d0a010000e371")); + + verifyPositions(decoder, false, binary( "00000000000000100C010600000008010300010015D5C5010000D988")); verifyPositions(decoder, binary( |