diff options
author | Anton Tananaev <anton@traccar.org> | 2023-08-06 07:41:21 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-08-06 07:41:21 -0700 |
commit | 3a5edf787fc4dc3fdb7caa30602dee1e5fab8157 (patch) | |
tree | 8a5d80b4f829638a5706db3e653f9fe819d564e4 /src/main/java/org/traccar/helper | |
parent | 8ab9cd75aad4a0940936304f055e155d87b03760 (diff) | |
download | trackermap-server-3a5edf787fc4dc3fdb7caa30602dee1e5fab8157.tar.gz trackermap-server-3a5edf787fc4dc3fdb7caa30602dee1e5fab8157.tar.bz2 trackermap-server-3a5edf787fc4dc3fdb7caa30602dee1e5fab8157.zip |
Additional CB212-C1005 data
Diffstat (limited to 'src/main/java/org/traccar/helper')
-rw-r--r-- | src/main/java/org/traccar/helper/ObdDecoder.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/main/java/org/traccar/helper/ObdDecoder.java b/src/main/java/org/traccar/helper/ObdDecoder.java index b22065f4e..3cbae334a 100644 --- a/src/main/java/org/traccar/helper/ObdDecoder.java +++ b/src/main/java/org/traccar/helper/ObdDecoder.java @@ -51,22 +51,7 @@ public final class ObdDecoder { 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); - codes.append(' '); - switch (numValue >> 14) { - case 1: - codes.append('C'); - break; - case 2: - codes.append('B'); - break; - case 3: - codes.append('U'); - break; - default: - codes.append('P'); - break; - } - codes.append(String.format("%04X", numValue & 0x3FFF)); + codes.append(' ').append(decodeCode(numValue)); } if (codes.length() > 0) { return createEntry(Position.KEY_DTCS, codes.toString().trim()); @@ -75,6 +60,25 @@ public final class ObdDecoder { } } + public static String decodeCode(int value) { + char prefix; + switch (value >> 14) { + case 1: + prefix = 'C'; + break; + case 2: + prefix = 'B'; + break; + case 3: + prefix = 'U'; + break; + default: + prefix = 'P'; + break; + } + return String.format("%c%04X", prefix, value & 0x3FFF); + } + public static Map.Entry<String, Object> decodeData(int pid, long value, boolean convert) { switch (pid) { case 0x04: |