diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-26 11:25:52 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-11-26 11:25:52 +1300 |
commit | e11d7edca8d25d8614034d023468102fcc9df563 (patch) | |
tree | 9f4fb5d6a481d65b08b7317da9cc4d9beed8a432 /src/org/traccar/protocol/AdmProtocolDecoder.java | |
parent | e21c10d3c11e62ab7310eef37cc7e83fd6b16baf (diff) | |
download | traccar-server-e11d7edca8d25d8614034d023468102fcc9df563.tar.gz traccar-server-e11d7edca8d25d8614034d023468102fcc9df563.tar.bz2 traccar-server-e11d7edca8d25d8614034d023468102fcc9df563.zip |
Decode ADM CAN data
Diffstat (limited to 'src/org/traccar/protocol/AdmProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/AdmProtocolDecoder.java | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/AdmProtocolDecoder.java b/src/org/traccar/protocol/AdmProtocolDecoder.java index 1dd2b64f1..52d1439ed 100644 --- a/src/org/traccar/protocol/AdmProtocolDecoder.java +++ b/src/org/traccar/protocol/AdmProtocolDecoder.java @@ -62,7 +62,7 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShortLE() * 0.1)); position.set(Position.KEY_ACCELERATION, buf.readUnsignedByte() * 0.1); - position.setAltitude(buf.readUnsignedShortLE()); + position.setAltitude(buf.readShortLE()); position.set(Position.KEY_HDOP, buf.readUnsignedByte() * 0.1); position.set(Position.KEY_SATELLITES, buf.readUnsignedByte() & 0x0f); @@ -105,7 +105,43 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder { } if (BitUtil.check(type, 6)) { - buf.skipBytes(buf.getUnsignedByte(buf.readerIndex())); + int endIndex = buf.readerIndex() + buf.readUnsignedByte(); + while (buf.readerIndex() < endIndex) { + int mask = buf.readUnsignedByte(); + long value; + switch (BitUtil.from(mask, 6)) { + case 3: + value = buf.readLongLE(); + break; + case 2: + value = buf.readUnsignedIntLE(); + break; + case 1: + value = buf.readUnsignedShortLE(); + break; + default: + value = buf.readUnsignedByte(); + break; + } + int index = BitUtil.to(mask, 6); + switch (index) { + case 1: + position.set(Position.PREFIX_TEMP + 1, value); + break; + case 2: + position.set("humidity", value); + break; + case 3: + position.set("illumination", value); + break; + case 4: + position.set(Position.KEY_BATTERY, value); + break; + default: + position.set("can" + index, value); + break; + } + } } if (BitUtil.check(type, 7)) { |