aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-01-24 21:29:46 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-01-24 21:29:46 -0800
commitf4134fb1a1749e4556b6fdcfd539d4e8a78a2e93 (patch)
tree0b034ae5a359f4015994c0408ad9d420f7c14699 /src/main/java/org/traccar/protocol
parente7866cd4bd5a4552f0d562671ce6a713d18824b8 (diff)
downloadtraccar-server-f4134fb1a1749e4556b6fdcfd539d4e8a78a2e93.tar.gz
traccar-server-f4134fb1a1749e4556b6fdcfd539d4e8a78a2e93.tar.bz2
traccar-server-f4134fb1a1749e4556b6fdcfd539d4e8a78a2e93.zip
Support engine data
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/PacificTrackProtocolDecoder.java54
1 files changed, 51 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/PacificTrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/PacificTrackProtocolDecoder.java
index 15e08d7b1..d49a73a86 100644
--- a/src/main/java/org/traccar/protocol/PacificTrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/PacificTrackProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 - 2020 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.
@@ -63,7 +63,7 @@ public class PacificTrackProtocolDecoder extends BaseProtocolDecoder {
while (buf.isReadable()) {
int segmentId = readBitExt(buf);
- int segmentLength = readBitExt(buf);
+ int segmentEnd = readBitExt(buf) + buf.readerIndex();
switch (segmentId) {
case 0x01:
@@ -83,12 +83,60 @@ public class PacificTrackProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(BitUtil.to(speedAndCourse, 12) * 0.1));
position.set(Position.KEY_INDEX, buf.readUnsignedShort());
break;
+ case 0x92:
+ while (buf.readerIndex() < segmentEnd) {
+ int field = buf.readUnsignedByte();
+ int fieldPrefix = BitUtil.from(field, 5);
+ if (fieldPrefix < 0b100) {
+ switch (BitUtil.between(field, 2, 5)) {
+ case 0b000:
+ position.set("bus", BitUtil.to(field, 2));
+ case 0b001:
+ position.set("currentGear", BitUtil.to(field, 2));
+ break;
+ default:
+ break;
+ }
+ } else if (fieldPrefix < 0b101) {
+ switch (BitUtil.to(field, 5)) {
+ case 0b00000:
+ position.set(Position.KEY_OBD_SPEED, buf.readUnsignedByte());
+ break;
+ case 0b00001:
+ position.set(Position.KEY_RPM, buf.readUnsignedByte() * 32);
+ break;
+ default:
+ buf.readUnsignedByte();
+ break;
+ }
+ } else if (fieldPrefix < 0b110) {
+ buf.readUnsignedShort();
+ } else if (fieldPrefix < 0b111) {
+ switch (BitUtil.to(field, 5)) {
+ case 0b00000:
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 100);
+ break;
+ case 0b00001:
+ position.set(Position.KEY_HOURS, buf.readUnsignedInt() * 180);
+ break;
+ case 0b00010:
+ position.set("idleHours", buf.readUnsignedInt() * 180);
+ break;
+ default:
+ buf.readUnsignedInt();
+ break;
+ }
+ } else {
+ buf.skipBytes(buf.readUnsignedByte());
+ }
+ }
+ break;
case 0x100:
String imei = ByteBufUtil.hexDump(buf.readSlice(8)).substring(0, 15);
deviceSession = getDeviceSession(channel, remoteAddress, imei);
break;
default:
- buf.skipBytes(segmentLength);
+ buf.readerIndex(segmentEnd);
break;
}
}