From 2a690606569f042b845da1f61b308698645ad3fc Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 28 Sep 2015 11:53:04 +1300 Subject: Decode OBD odometer value --- src/org/traccar/model/Event.java | 4 +++- src/org/traccar/protocol/Gl200ProtocolDecoder.java | 4 ++-- src/org/traccar/protocol/IntellitracProtocolDecoder.java | 2 +- src/org/traccar/protocol/TytanProtocolDecoder.java | 5 ++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java index 2f78dd0f4..cadca767b 100644 --- a/src/org/traccar/model/Event.java +++ b/src/org/traccar/model/Event.java @@ -81,7 +81,9 @@ public abstract class Event { public static final String KEY_DISTANCE = "distance"; public static final String KEY_DOOR = "door"; public static final String KEY_RPM = "rpm"; - public static final String KEY_SPEED = "speed"; // OBD speed + + public static final String KEY_OBD_SPEED = "speed"; + public static final String KEY_OBD_ODOMETER = "odometer"; // Starts with 1 not 0 public static final String PREFIX_TEMP = "temp"; diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index a7cf1121b..61a0aed39 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -121,7 +121,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { // OBD position.set(Event.KEY_RPM, parser.group(index++)); - position.set(Event.KEY_SPEED, parser.group(index++)); + position.set(Event.KEY_OBD_SPEED, parser.group(index++)); position.set(Event.PREFIX_TEMP + 1, parser.group(index++)); position.set("fuel-consumption", parser.group(index++)); position.set("dtcs-cleared-distance", parser.group(index++)); @@ -130,7 +130,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { position.set("dtcs-codes", parser.group(index++)); position.set("throttle-position", parser.group(index++)); position.set(Event.KEY_FUEL, parser.group(index++)); - position.set("odb-odometer", parser.group(index++)); + position.set(Event.KEY_OBD_ODOMETER, parser.group(index++)); // Validity position.setValid(Integer.valueOf(parser.group(index++)) < 20); diff --git a/src/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/org/traccar/protocol/IntellitracProtocolDecoder.java index a2c16e915..6c8d5bdf9 100644 --- a/src/org/traccar/protocol/IntellitracProtocolDecoder.java +++ b/src/org/traccar/protocol/IntellitracProtocolDecoder.java @@ -122,7 +122,7 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { position.set(Event.PREFIX_ADC + 2, parser.group(index++)); // J1939 data - position.set(Event.KEY_SPEED, parser.group(index++)); + position.set(Event.KEY_OBD_SPEED, parser.group(index++)); position.set(Event.KEY_RPM, parser.group(index++)); position.set("coolant", parser.group(index++)); position.set(Event.KEY_FUEL, parser.group(index++)); diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index bcab7ed21..0936732c5 100644 --- a/src/org/traccar/protocol/TytanProtocolDecoder.java +++ b/src/org/traccar/protocol/TytanProtocolDecoder.java @@ -171,7 +171,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { position.set(Event.KEY_POWER, readSwappedFloat(buf)); break; case 101: - position.set(Event.KEY_SPEED, buf.readUnsignedByte()); + position.set(Event.KEY_OBD_SPEED, buf.readUnsignedByte()); break; case 102: position.set(Event.KEY_RPM, buf.readUnsignedByte() * 50); @@ -179,6 +179,9 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { case 107: position.set(Event.KEY_FUEL, (buf.readUnsignedShort() & 0x3fff) * 0.5); break; + case 108: + position.set(Event.KEY_OBD_ODOMETER, buf.readUnsignedInt() * 5); + break; case 150: position.set("door", buf.readUnsignedByte()); break; -- cgit v1.2.3