From e1077019a5ff970b98c934af9a170547d9d55e5d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 7 Sep 2019 12:43:51 -0700 Subject: Decode Kimax weight sensor data --- .../org/traccar/protocol/TeltonikaProtocolDecoder.java | 14 +++++++++++++- .../org/traccar/protocol/TeltonikaProtocolDecoderTest.java | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) 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 @@ -15,6 +15,9 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "000F313233343536373839303132333435")); + verifyPositions(decoder, false, binary( + "000000000000004f0c01060000004755555555777730362e343b30342e323b30302e303b30302e303b30302e303b30302e303b30302e303b30302e303b30312e333b30302e303b31302e373b30302e303b5353530d0a010000e371")); + verifyPositions(decoder, false, binary( "00000000000000100C010600000008010300010015D5C5010000D988")); -- cgit v1.2.3