aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-05-04 16:07:52 -0700
committerAnton Tananaev <anton@traccar.org>2023-05-04 16:07:52 -0700
commit3dad196b882c031e4ed36536c3b2deeb1b3bbff6 (patch)
tree57dbfd54f3bd8c51fa93a46322166b92e1ccaf69
parente73f36db83b9dc00a5dfe0a9625f40bd2698c3fa (diff)
downloadtrackermap-server-3dad196b882c031e4ed36536c3b2deeb1b3bbff6.tar.gz
trackermap-server-3dad196b882c031e4ed36536c3b2deeb1b3bbff6.tar.bz2
trackermap-server-3dad196b882c031e4ed36536c3b2deeb1b3bbff6.zip
Extend HS-5000G OBD support
-rw-r--r--src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java5
-rw-r--r--src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java3
2 files changed, 8 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
index 2d952c759..2fb7c6e92 100644
--- a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -236,6 +236,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
while (buf.readableBytes() > 4) {
int subtype = buf.readUnsignedShort();
int length = buf.readUnsignedShort() - 4;
+ int endIndex = buf.readerIndex() + length;
switch (subtype) {
case 0x0001:
int coolantTemperature = buf.readUnsignedByte() - 40;
@@ -253,6 +254,9 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01);
position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedByte() * 0.4);
buf.readUnsignedInt(); // trip id
+ if (buf.readerIndex() < endIndex) {
+ position.set("adBlueLevel", buf.readUnsignedByte() * 0.4);
+ }
break;
case 0x0005:
position.set(Position.KEY_RSSI, buf.readUnsignedByte());
@@ -295,6 +299,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(length);
break;
}
+ buf.readerIndex(endIndex);
}
if (network.getCellTowers() != null || network.getWifiAccessPoints() != null) {
diff --git a/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java
index ee6c3fa7f..fe4b077c6 100644
--- a/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java
@@ -20,6 +20,9 @@ public class HuaShengProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"c000000077aa0200000000000e000100143347315f48312e315f56312e30372e54000300133335353835353035303434303635380004000b3531323030303000050005010006000400070004000800050000090018383936313032353431343533333239313833360d000a000f796573696e7465726e6574c0"));
+ verifyNotNull(decoder, binary(
+ "c0000000b9aa00000000000013c800001132333035303431343537323600186bc30045e5b8002a008b0077002d000100187f0c4b2600d906ec000005938800000000000e0000040009110000000e0005000a1d0400000079000900154646464646464646464646464646464646000f00133836323230353035353339313733360010000c302e30303030303000110008000000000014000bf81b204901b52a001500060000002000153231394030324030403130343438393139c0"));
+
verifyAttribute(decoder, binary(
"C00000001CAA120000000000020001001001000200030043008200C100C0"),
Position.KEY_DTCS, "P0100 P0200 P0300 C0300 B0200 U0100");