diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-07-20 07:35:52 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-07-20 07:35:52 +1200 |
commit | d7d66e3b724cde1a681e5e7f24e930d2bddfe703 (patch) | |
tree | 66cd15df8bf675b9774aa930df62a306af9bdd6f /src/org/traccar/protocol/AplicomProtocolDecoder.java | |
parent | 00ca2ad8bc38258199b8891a537ac54f4c3d3741 (diff) | |
download | trackermap-server-d7d66e3b724cde1a681e5e7f24e930d2bddfe703.tar.gz trackermap-server-d7d66e3b724cde1a681e5e7f24e930d2bddfe703.tar.bz2 trackermap-server-d7d66e3b724cde1a681e5e7f24e930d2bddfe703.zip |
Fix Aplicom E driver decoding
Diffstat (limited to 'src/org/traccar/protocol/AplicomProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/AplicomProtocolDecoder.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index 6f63d0c17..ef02cda7e 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -352,15 +352,28 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_VIN, buf.readBytes(18).toString(StandardCharsets.US_ASCII).trim()); } + if ((selector & 0x2000) != 0) { + buf.readUnsignedByte(); // card 1 type + buf.readUnsignedByte(); // card 1 country code + String card = buf.readBytes(20).toString(StandardCharsets.US_ASCII).trim(); + if (!card.isEmpty()) { + position.set("card1", card); + } + } + + if ((selector & 0x4000) != 0) { + buf.readUnsignedByte(); // card 2 type + buf.readUnsignedByte(); // card 2 country code + String card = buf.readBytes(20).toString(StandardCharsets.US_ASCII).trim(); + if (!card.isEmpty()) { + position.set("card2", card); + } + } + if ((selector & 0x10000) != 0) { int count = buf.readUnsignedByte(); for (int i = 1; i <= count; i++) { - ChannelBuffer driver = buf.readBytes(22); - int endIndex = driver.indexOf(0, driver.writerIndex(), (byte) 0); - if (endIndex < 0) { - endIndex = driver.writerIndex(); - } - position.set("driver" + i, driver.toString(0, endIndex, StandardCharsets.US_ASCII).trim()); + position.set("driver" + i, buf.readBytes(22).toString(StandardCharsets.US_ASCII).trim()); position.set("driverTime" + i, buf.readUnsignedInt()); } } |