aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/AplicomProtocolDecoder.java98
1 files changed, 49 insertions, 49 deletions
diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java
index ef02cda7e..94d12c633 100644
--- a/src/org/traccar/protocol/AplicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java
@@ -470,59 +470,59 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // length
while (buf.readableBytes() > 0) {
- position.set("towedPosition", buf.readUnsignedByte());
+ buf.readUnsignedByte(); // towed position
int type = buf.readUnsignedByte();
int length = buf.readUnsignedByte();
+ int end = buf.readerIndex() + length;
- 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(Position.KEY_ODOMETER, buf.readUnsignedInt() * 5);
- position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt() * 5);
- position.set(Position.KEY_ODOMETER_SERVICE, (buf.readUnsignedInt() - 2105540607) * 5);
- } else if (type == 0x0A) {
- ChannelBuffer brakeData = buf.readBytes(length);
- position.set("absStatusCounter", brakeData.readUnsignedShort());
- position.set("atvbStatusCounter", brakeData.readUnsignedShort());
- position.set("vdcActiveCounter", brakeData.readUnsignedShort());
- } 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();
- position.set(Position.KEY_VIN, buf.readBytes(17).toString(StandardCharsets.US_ASCII));
- position.set("towedDetectionStatus", buf.readUnsignedByte());
- } else if (type == 0x0E) {
- buf.skipBytes(length);
+ switch (type) {
+ case 0x01:
+ position.set("brakeFlags", ChannelBuffers.hexDump(buf.readBytes(length)));
+ break;
+ case 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);
+ break;
+ case 0x03:
+ position.set("axleLoadSum", buf.readUnsignedShort() * 2);
+ break;
+ case 0x04:
+ position.set("tyrePressure", buf.readUnsignedByte() * 10);
+ position.set("pneumaticPressure", buf.readUnsignedByte() * 5);
+ break;
+ case 0x05:
+ position.set("brakeLining", buf.readUnsignedByte() * 0.4);
+ position.set("brakeTemperature", buf.readUnsignedByte() * 10);
+ break;
+ case 0x06:
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 5L);
+ position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt() * 5L);
+ position.set(Position.KEY_ODOMETER_SERVICE, (buf.readUnsignedInt() - 2105540607) * 5L);
+ break;
+ case 0x0A:
+ position.set("absStatusCounter", buf.readUnsignedShort());
+ position.set("atvbStatusCounter", buf.readUnsignedShort());
+ position.set("vdcActiveCounter", buf.readUnsignedShort());
+ break;
+ case 0x0B:
+ position.set("brakeMinMaxData", ChannelBuffers.hexDump(buf.readBytes(length)));
+ break;
+ case 0x0C:
+ position.set("missingPgn", ChannelBuffers.hexDump(buf.readBytes(length)));
+ break;
+ case 0x0D:
+ buf.readUnsignedByte();
+ position.set("towedDetectionStatus", buf.readUnsignedInt());
+ buf.skipBytes(17); // vin
+ break;
+ case 0x0E:
+ default:
+ break;
}
+
+ buf.readerIndex(end);
}
}