aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-09-15 20:43:53 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-09-15 20:43:53 -0700
commita498a5584dc21d8ee3c1bdfe56dd158b789d463e (patch)
tree45f7b26c63b157cfcc523bd786a3c503cdecc66b
parent9e044f48f06b1201eaf642b2e53e5ba40c46c0ff (diff)
downloadtrackermap-server-a498a5584dc21d8ee3c1bdfe56dd158b789d463e.tar.gz
trackermap-server-a498a5584dc21d8ee3c1bdfe56dd158b789d463e.tar.bz2
trackermap-server-a498a5584dc21d8ee3c1bdfe56dd158b789d463e.zip
Fix power decoding
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java6
-rw-r--r--src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java5
2 files changed, 6 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index a562267aa..f67cc3d8f 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -305,13 +305,13 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
position.set("fuel1", buf.readUnsignedShort() * 0.1);
buf.readUnsignedByte(); // unused
break;
- case 0x0004:
- position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01);
- break;
case 0x0023:
position.set("fuel2", Double.parseDouble(
buf.readCharSequence(6, StandardCharsets.US_ASCII).toString()));
break;
+ case 0x00CE:
+ position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01);
+ break;
default:
buf.skipBytes(extendedLength - 2);
break;
diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
index f547cf9da..f44accc57 100644
--- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
@@ -14,8 +14,9 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"7E01000021013345678906000F002C012F373031313142534A2D4D3742203030303030303001D4C1423838383838B47E"));
- verifyPositions(decoder, binary(
- "7e070400db07904116875014480003010046000000000000000b020057d40072fb9c0064017200f220090215230301040000092930011f31010ceb1c000c00b28921200272401241734f00060089ffffffef000400ce1d460046000000000000000b0200570c0072fdb2005f013600ee20090215230801040000092a30011f31010ceb1c000c00b28921200272401241734f00060089ffffffef000400ce1e800046000000000000000b020056ac0072fe9b005a00d200ec20090215231301040000092a30011b31010ceb1c000c00b28921200272401241734f00060089ffffffef000400ce1e35d77e"));
+ verifyAttribute(decoder, binary(
+ "7e070400db07904116875014480003010046000000000000000b020057d40072fb9c0064017200f220090215230301040000092930011f31010ceb1c000c00b28921200272401241734f00060089ffffffef000400ce1d460046000000000000000b0200570c0072fdb2005f013600ee20090215230801040000092a30011f31010ceb1c000c00b28921200272401241734f00060089ffffffef000400ce1e800046000000000000000b020056ac0072fe9b005a00d200ec20090215231301040000092a30011b31010ceb1c000c00b28921200272401241734f00060089ffffffef000400ce1e35d77e"),
+ Position.KEY_POWER, 74.94);
verifyAttribute(decoder, binary(
"7e550104337401903111850622072002454206133574075359513a0000080100000001aa00005ded05e203000000000c06005affb5ffb40a0302dc65100100137e"),