diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-05-16 11:38:09 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-05-16 11:38:09 -0700 |
commit | 58dc2de1f80e3279c17405edf28c4deac231e7d9 (patch) | |
tree | 13d60ad53fb8959668bb8e378864912fb67de8bf /src | |
parent | d16743300e424ed96b31bca98047f8e3e877162e (diff) | |
download | trackermap-server-58dc2de1f80e3279c17405edf28c4deac231e7d9.tar.gz trackermap-server-58dc2de1f80e3279c17405edf28c4deac231e7d9.tar.bz2 trackermap-server-58dc2de1f80e3279c17405edf28c4deac231e7d9.zip |
Decode EGTS liquid sensor data
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/traccar/protocol/EgtsProtocolDecoder.java | 31 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/EgtsProtocolDecoderTest.java | 12 |
2 files changed, 40 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/EgtsProtocolDecoder.java b/src/main/java/org/traccar/protocol/EgtsProtocolDecoder.java index 9f0baf6b2..e65ddb0ef 100644 --- a/src/main/java/org/traccar/protocol/EgtsProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/EgtsProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 - 2019 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2020 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.traccar.protocol; import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; @@ -253,11 +254,35 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { } else if (type == MSG_AD_SENSORS_DATA) { - buf.readUnsignedByte(); // inputs flags + int inputMask = buf.readUnsignedByte(); position.set(Position.KEY_OUTPUT, buf.readUnsignedByte()); - buf.readUnsignedByte(); // adc flags + int adcMask = buf.readUnsignedByte(); + + for (int i = 0; i < 8; i++) { + if (BitUtil.check(inputMask, i)) { + buf.readUnsignedByte(); // input + } + } + + for (int i = 0; i < 8; i++) { + if (BitUtil.check(adcMask, i)) { + position.set(Position.PREFIX_ADC + (i + 1), buf.readUnsignedMediumLE()); + } + } + + } else if (type == MSG_LIQUID_LEVEL_SENSOR) { + + int flags = buf.readUnsignedByte(); + + buf.readUnsignedShortLE(); // address + + if (BitUtil.check(flags, 3)) { + position.set("liquidRaw", ByteBufUtil.hexDump(buf.readSlice(end - buf.readerIndex()))); + } else { + position.set("liquid", buf.readUnsignedIntLE()); + } } diff --git a/src/test/java/org/traccar/protocol/EgtsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EgtsProtocolDecoderTest.java index 2afb72e08..cdf27ee63 100644 --- a/src/test/java/org/traccar/protocol/EgtsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/EgtsProtocolDecoderTest.java @@ -40,6 +40,18 @@ public class EgtsProtocolDecoderTest extends ProtocolTest { "0100000b002400a0d601f01900030081030000000101011600030000004238363434393530333436343333373600014cdc")); verifyPositions(decoder, binary( + "0100020b009e00892401504400ed539135de0100020210180051917613009194a00028db7893bd814700000001008c00001106001a3f00130300140500001d0000041207000f000000000000130100001b0700010000ae0e00004400ee539135de010002021018005491761300c094a00011db789353814700000001008c00001106001a3f00130300140500001c0000041207000f000010000000130100001b0700010000ca0e00004b47")); + + verifyPositions(decoder, binary( + "0100020b004f00ae1101d24400ae1191af8304000202101800d9238213008dcea08070ec789338003c00000001008200001106001a740007020014050000180000041207000f000010000000130100001b0700010000af0f0000312a")); + + verifyPositions(decoder, binary( + "0100020b009e004b8801b04400512091473502000202101800052582130026e5a080e04979937202f20000000100cd00001106001a470010030014050000190000041207000f000010000000130100001b0700010000e80b000044005220914735020002021018000b25821300d2e4a080524979937802f20000000100ce00001106001a4100110300140500001a0000041207000f000010000000130100001b0700010000eb0b0000c776")); + + verifyPositions(decoder, binary( + "0100020b008b01550001dc4400580291ce5006000202101800fe248213002351a000072879934d810c0000000100af00001106001a5d000c030014050000000000041207000f000000000000130100001b07000100002a0a00004400590291ce500600020210180001258213002651a000e02779934481160000000100ad00001106001a49000e030014050000000000041207000f000000000000130100001b07000100003a0a000044005a0291ce500600020210180004258213002b51a000c2277993da80160000000100ab00001106001a4b000d030014050000000000041207000f000000000000130100001b0700010000d50a000044005b0291ce500600020210180014258213004e51a00033277993dd80210000000100ab00001106001a48000f030014050000000000041207000f000000000000130100001b0700010000b30a000044005c0291ce50060002021018001f258213007a51a080c4267993fa802f0000000100ac00001106001a48000f030014050000000000041207000f000000000000130100001b0700010000390a0000c664")); + + verifyPositions(decoder, binary( "0100000b002700030e01211800030e8573890100845e980f0202101500f85d980fb37f50aae9653c2b193708317b00000001c51b")); verifyPositions(decoder, binary( |