aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-02-02 20:25:38 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2021-02-02 20:25:38 -0800
commit028e0f9737c5ddf8f7bcc011f0d14923e4ce0646 (patch)
treea1d228540ff6c4278fbe85a48f8189205276ca8b
parent00ddff42e766e834dee49eb471c0c3aefab022b2 (diff)
downloadtrackermap-server-028e0f9737c5ddf8f7bcc011f0d14923e4ce0646.tar.gz
trackermap-server-028e0f9737c5ddf8f7bcc011f0d14923e4ce0646.tar.bz2
trackermap-server-028e0f9737c5ddf8f7bcc011f0d14923e4ce0646.zip
Ignore invalid values
-rw-r--r--src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
index 3ad70bdca..2e1ddf5f2 100644
--- a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2021 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -234,8 +234,14 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
int length = buf.readUnsignedShort() - 4;
switch (subtype) {
case 0x0001:
- position.set(Position.KEY_COOLANT_TEMP, buf.readUnsignedByte() - 40);
- position.set(Position.KEY_RPM, buf.readUnsignedShort());
+ int coolantTemperature = buf.readUnsignedByte() - 40;
+ if (coolantTemperature <= 215) {
+ position.set(Position.KEY_COOLANT_TEMP, coolantTemperature);
+ }
+ int rpm = buf.readUnsignedShort();
+ if (rpm <= 65535) {
+ position.set(Position.KEY_RPM, rpm);
+ }
position.set("averageSpeed", buf.readUnsignedByte());
buf.readUnsignedShort(); // interval fuel consumption
position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedShort() * 0.01);