aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-03-02 07:53:16 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-03-02 07:53:16 +1300
commit341ef3590a7114e6ab93a5d4b52176105dd71856 (patch)
treee32b6f3a2bc668fef07488999489debcb2c61805
parent8c099a4fb79d45cbab37a175f42597ec5772814b (diff)
downloadtraccar-server-341ef3590a7114e6ab93a5d4b52176105dd71856.tar.gz
traccar-server-341ef3590a7114e6ab93a5d4b52176105dd71856.tar.bz2
traccar-server-341ef3590a7114e6ab93a5d4b52176105dd71856.zip
Implement Aplicom F protocol
-rw-r--r--src/org/traccar/protocol/AplicomProtocolDecoder.java64
-rw-r--r--test/org/traccar/protocol/AplicomProtocolDecoderTest.java3
2 files changed, 66 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java
index daa8844b4..fbd868b86 100644
--- a/src/org/traccar/protocol/AplicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2017 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.
@@ -78,6 +78,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
private static final int DEFAULT_SELECTOR_D = 0x0002fC;
private static final int DEFAULT_SELECTOR_E = 0x007ffc;
+ private static final int DEFAULT_SELECTOR_F = 0x0007fd;
private static final int EVENT_DATA = 119;
@@ -498,6 +499,63 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private void decodeF(Position position, ChannelBuffer buf, int selector) {
+
+ getLastLocation(position, null);
+
+ buf.readUnsignedShort(); // event
+
+ if ((selector & 0x0004) != 0) {
+ buf.skipBytes(4); // snapshot time
+ }
+
+ buf.readUnsignedByte(); // data validity
+
+ if ((selector & 0x0008) != 0) {
+ position.set(Position.KEY_RPM, buf.readUnsignedShort());
+ position.set("rpmMax", buf.readUnsignedShort());
+ position.set("rpmMin", buf.readUnsignedShort());
+ }
+
+ if ((selector & 0x0010) != 0) {
+ position.set("engineTemp", buf.readShort());
+ position.set("engineTempMax", buf.readShort());
+ position.set("engineTempMin", buf.readShort());
+ }
+
+ if ((selector & 0x0020) != 0) {
+ position.set(Position.KEY_HOURS, buf.readUnsignedInt());
+ position.set("serviceDistance", buf.readInt());
+ buf.readUnsignedByte(); // driver activity
+ position.set(Position.KEY_THROTTLE, buf.readUnsignedByte());
+ position.set(Position.KEY_FUEL, buf.readUnsignedByte());
+ }
+
+ if ((selector & 0x0040) != 0) {
+ position.set("totalFuelUsed", buf.readUnsignedInt());
+ }
+
+ if ((selector & 0x0080) != 0) {
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ }
+
+ if ((selector & 0x0100) != 0) {
+ position.set(Position.KEY_OBD_SPEED, buf.readUnsignedByte());
+ position.set("speedMax", buf.readUnsignedByte());
+ position.set("speedMin", buf.readUnsignedByte());
+ position.set("hardBreaking", buf.readUnsignedByte());
+ }
+
+ if ((selector & 0x0200) != 0) {
+ buf.readUnsignedByte(); // tachograph based speed
+ buf.readUnsignedByte(); // driver 1 state
+ buf.readUnsignedByte(); // driver 2 state
+ buf.readUnsignedByte(); // tachograph status
+ position.set("overspeedCount", buf.readUnsignedByte());
+ }
+
+ }
+
@Override
protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -518,6 +576,8 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
int selector = DEFAULT_SELECTOR_D;
if (protocol == 'E') {
selector = DEFAULT_SELECTOR_E;
+ } else if (protocol == 'F') {
+ selector = DEFAULT_SELECTOR_F;
}
if ((version & 0x40) != 0) {
selector = buf.readUnsignedMedium();
@@ -541,6 +601,8 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
decodeE(position, buf, selector);
} else if (protocol == 'H') {
decodeH(position, buf, selector);
+ } else if (protocol == 'F') {
+ decodeF(position, buf, selector);
} else {
return null;
}
diff --git a/test/org/traccar/protocol/AplicomProtocolDecoderTest.java b/test/org/traccar/protocol/AplicomProtocolDecoderTest.java
index cb39b5d2e..38ac1c43f 100644
--- a/test/org/traccar/protocol/AplicomProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/AplicomProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class AplicomProtocolDecoderTest extends ProtocolTest {
AplicomProtocolDecoder decoder = new AplicomProtocolDecoder(new AplicomProtocol());
verifyAttributes(decoder, binary(
+ "46c30144f667c1711f00340007ff75005891601401025707b50236003b003b003500000a9300006bd50100640000a5250167d2f9034c01010107020400021a901004"));
+
+ verifyAttributes(decoder, binary(
"48C1014143B4493145004900203F6D014B5557C20003000015060110FF00C800000000000000003D01141E283C500100260404010200000000000000000000000000C8000000000000010200110019001E0064019003E8"));
verifyAttributes(decoder, binary(