aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-20 15:10:35 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-20 15:10:35 +1300
commit42c16920b42938c2e9e978b34f0ef015b6b22a7a (patch)
tree53aed722bb07a5bac9e7932576d4a60c00fcd737 /src/org/traccar
parent57d9d42a8a6e84a7af2c75a17c3df55850c52288 (diff)
downloadtraccar-server-42c16920b42938c2e9e978b34f0ef015b6b22a7a.tar.gz
traccar-server-42c16920b42938c2e9e978b34f0ef015b6b22a7a.tar.bz2
traccar-server-42c16920b42938c2e9e978b34f0ef015b6b22a7a.zip
Decode OBD data from Ulbotech
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
index b7a00e3b5..a81c02ce1 100644
--- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java
+++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
@@ -54,10 +54,21 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
private static final short DATA_RFID = 0x0E;
private static final short DATA_EVENT = 0x10;
+ private void decodeObd(Position position, ChannelBuffer buf, short length) {
+
+ int end = buf.readerIndex() + length;
+
+ while (buf.readerIndex() < end) {
+ int parameterLength = buf.readUnsignedByte() >> 4;
+ String key = String.format("pid%02X", buf.readUnsignedByte());
+ String value = ChannelBuffers.hexDump(buf.readBytes(parameterLength - 2));
+ position.set(key, value);
+ }
+ }
+
@Override
protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg)
- throws Exception {
+ Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ChannelBuffer buf = (ChannelBuffer) msg;
@@ -133,7 +144,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
break;
case DATA_OBD2:
- position.set("obd", ChannelBuffers.hexDump(buf.readBytes(length)));
+ decodeObd(position, buf, length);
break;
case DATA_FUEL:
@@ -141,7 +152,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
break;
case DATA_OBD2_ALARM:
- position.set("obd-alarm", ChannelBuffers.hexDump(buf.readBytes(length)));
+ decodeObd(position, buf, length);
break;
case DATA_HARSH_DRIVER: