diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-09-26 06:12:18 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-09-26 06:12:18 +1300 |
commit | 14d317b6173badced85335bf8ef2ad478006a404 (patch) | |
tree | 3c3714df59d3ede8b335bd86db007a12809f17b4 /src/org | |
parent | 7deebcef53759e0e11702af97462b821bfad5f5d (diff) | |
download | traccar-server-14d317b6173badced85335bf8ef2ad478006a404.tar.gz traccar-server-14d317b6173badced85335bf8ef2ad478006a404.tar.bz2 traccar-server-14d317b6173badced85335bf8ef2ad478006a404.zip |
Implement Aplicom EB protocol
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/AplicomProtocolDecoder.java | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index fa512d8b1..d1f92ea0a 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -81,7 +81,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { private static final int EVENT_DATA = 119; - private void decodeEventData(int event, ChannelBuffer buf) { + private void decodeEventData(Position position, ChannelBuffer buf, int event) { switch (event) { case 2: case 40: @@ -108,6 +108,9 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { case 130: buf.readUnsignedInt(); // incorrect break; + case 188: + decodeEB(position, buf); + break; default: break; } @@ -283,7 +286,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } if ((selector & 0x1000) != 0) { - decodeEventData(event, buf); + decodeEventData(position, buf, event); } if (Context.getConfig().getBoolean(getProtocolName() + ".can") @@ -426,6 +429,72 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } } + private void decodeEB(Position position, ChannelBuffer buf) { + + if (buf.readByte() != (byte) 'E' || buf.readByte() != (byte) 'B') { + return; + } + + buf.readUnsignedByte(); // version + buf.readUnsignedShort(); // event + buf.readUnsignedByte(); // data validity + buf.readUnsignedByte(); // towed + buf.readUnsignedShort(); // length + + while (buf.readableBytes() > 0) { + buf.readUnsignedByte(); // towed position + int type = buf.readUnsignedByte(); + int length = buf.readUnsignedByte(); + + if (type == 0x01) { + position.set("brakeFlags", ChannelBuffers.hexDump(buf.readBytes(length))); + } else if (type == 0x02) { + position.set("wheelSpeed", buf.readUnsignedShort() / 256.0); + position.set("wheelSpeedDifference", buf.readUnsignedShort() / 256.0 - 125.0); + position.set("lateralAcceleration", buf.readUnsignedByte() / 10.0 - 12.5); + position.set("vehicleSpeed", buf.readUnsignedShort() / 256.0); + } else if (type == 0x03) { + position.set("axleLoadSum", buf.readUnsignedShort() * 2); + } else if (type == 0x04) { + position.set("tyrePressure", buf.readUnsignedByte() * 10); + position.set("pneumaticPressure", buf.readUnsignedByte() * 5); + } else if (type == 0x05) { + position.set("brakeLining", buf.readUnsignedByte() * 0.4); + position.set("brakeTemperature", buf.readUnsignedByte() * 10); + } else if (type == 0x06) { + position.set("totalDistance", buf.readUnsignedInt() * 5); + position.set("tripDistance", buf.readUnsignedInt() * 5); + position.set("serviceDistance", (buf.readUnsignedInt() - 2105540607) * 5); + } else if (type == 0x0A) { + position.set("brakeData", ChannelBuffers.hexDump(buf.readBytes(length))); + } else if (type == 0x0B) { + position.set("brakeMinMaxData", ChannelBuffers.hexDump(buf.readBytes(length))); + } else if (type == 0x0C) { + position.set("missingPgn", ChannelBuffers.hexDump(buf.readBytes(length))); + } else if (type == 0x0D) { + switch (buf.readUnsignedByte()) { + case 1: + position.set("brakeManufacturer", "Wabco"); + break; + case 2: + position.set("brakeManufacturer", "Knorr"); + break; + case 3: + position.set("brakeManufacturer", "Haldex"); + break; + default: + position.set("brakeManufacturer", "Unknown"); + break; + } + buf.readUnsignedByte(); + buf.readBytes(17); // vin + position.set("towedDetectionStatus", buf.readUnsignedByte()); + } else if (type == 0x0E) { + buf.skipBytes(length); + } + } + } + @Override protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { |