aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-09-16 17:36:45 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-09-16 17:36:45 +1200
commitd18e293a891c3ef1f3ab2ff9a3b663320a7f4f0b (patch)
treea2d04818c74fec3b8e2e213d3dd9947552c4629b /src/org/traccar/helper
parent17f9739cf7f9db0ac974598b76eee1d3082174f4 (diff)
downloadtrackermap-server-d18e293a891c3ef1f3ab2ff9a3b663320a7f4f0b.tar.gz
trackermap-server-d18e293a891c3ef1f3ab2ff9a3b663320a7f4f0b.tar.bz2
trackermap-server-d18e293a891c3ef1f3ab2ff9a3b663320a7f4f0b.zip
Implement SinoCastel OBD decoding
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r--src/org/traccar/helper/ObdDecoder.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/org/traccar/helper/ObdDecoder.java b/src/org/traccar/helper/ObdDecoder.java
index 6ffe39662..8383a2b1a 100644
--- a/src/org/traccar/helper/ObdDecoder.java
+++ b/src/org/traccar/helper/ObdDecoder.java
@@ -42,7 +42,9 @@ public final class ObdDecoder {
switch (mode) {
case MODE_CURRENT:
case MODE_FREEZE_FRAME:
- return decodeData(Integer.parseInt(value.substring(0, 2), 16), value.substring(2));
+ return decodeData(
+ Integer.parseInt(value.substring(0, 2), 16),
+ Integer.parseInt(value.substring(2), 16));
case MODE_CODES:
return decodeCodes(value);
default:
@@ -82,25 +84,24 @@ public final class ObdDecoder {
}
}
- private static Map.Entry<String, Object> decodeData(int pid, String value) {
- int intValue = Integer.parseInt(value, 16);
+ public static Map.Entry<String, Object> decodeData(int pid, int value) {
switch (pid) {
case PID_ENGINE_LOAD:
- return createEntry("engineLoad", intValue * 100 / 255);
+ return createEntry("engineLoad", value * 100 / 255);
case PID_COOLANT_TEMPERATURE:
- return createEntry("coolantTemperature", intValue - 40);
+ return createEntry("coolantTemperature", value - 40);
case PID_ENGINE_RPM:
- return createEntry(Position.KEY_RPM, intValue / 4);
+ return createEntry(Position.KEY_RPM, value / 4);
case PID_VEHICLE_SPEED:
- return createEntry(Position.KEY_OBD_SPEED, intValue);
+ return createEntry(Position.KEY_OBD_SPEED, value);
case PID_THROTTLE_POSITION:
- return createEntry("throttle", intValue * 100 / 255);
+ return createEntry("throttle", value * 100 / 255);
case PID_MIL_DISTANCE:
- return createEntry("milDistance", intValue);
+ return createEntry("milDistance", value);
case PID_FUEL_LEVEL:
- return createEntry(Position.KEY_FUEL, intValue * 100 / 255);
+ return createEntry(Position.KEY_FUEL, value * 100 / 255);
case PID_DISTANCE_CLEARED:
- return createEntry("clearedDistance", intValue);
+ return createEntry("clearedDistance", value);
default:
return null;
}