diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-09-14 07:53:15 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-09-14 07:53:15 +1200 |
commit | 5a3cad30d5b2fa5a4be6cba0eed6df135f496165 (patch) | |
tree | bcc8191c0029266b33b5502b04097c11b658ef48 /src/org/traccar/helper | |
parent | 38bbab77b848989b1065a41666518bef64d147e5 (diff) | |
download | trackermap-server-5a3cad30d5b2fa5a4be6cba0eed6df135f496165.tar.gz trackermap-server-5a3cad30d5b2fa5a4be6cba0eed6df135f496165.tar.bz2 trackermap-server-5a3cad30d5b2fa5a4be6cba0eed6df135f496165.zip |
Implement more Castel message types
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r-- | src/org/traccar/helper/ObdDecoder.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/org/traccar/helper/ObdDecoder.java b/src/org/traccar/helper/ObdDecoder.java index 4686aa682..6ffe39662 100644 --- a/src/org/traccar/helper/ObdDecoder.java +++ b/src/org/traccar/helper/ObdDecoder.java @@ -25,9 +25,9 @@ public final class ObdDecoder { private ObdDecoder() { } - public static final int MODE_CURRENT = 0x01; - public static final int MODE_FREEZE_FRAME = 0x02; - public static final int MODE_CODES = 0x03; + private static final int MODE_CURRENT = 0x01; + private static final int MODE_FREEZE_FRAME = 0x02; + private static final int MODE_CODES = 0x03; private static final int PID_ENGINE_LOAD = 0x04; private static final int PID_COOLANT_TEMPERATURE = 0x05; @@ -54,7 +54,7 @@ public final class ObdDecoder { return new AbstractMap.SimpleEntry<>(key, value); } - private static Map.Entry<String, Object> decodeCodes(String value) { + public static Map.Entry<String, Object> decodeCodes(String value) { StringBuilder codes = new StringBuilder(); for (int i = 0; i < value.length() / 4; i++) { int numValue = Integer.parseInt(value.substring(i * 4, (i + 1) * 4), 16); @@ -75,7 +75,11 @@ public final class ObdDecoder { } codes.append(String.format("%04X", numValue & 0x3FFF)); } - return createEntry("dtcs", codes.toString().replaceFirst(",", "")); + if (codes.length() > 0) { + return createEntry("dtcs", codes.toString().replaceFirst(",", "")); + } else { + return null; + } } private static Map.Entry<String, Object> decodeData(int pid, String value) { |