From 028e0f9737c5ddf8f7bcc011f0d14923e4ce0646 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 2 Feb 2021 20:25:38 -0800 Subject: Ignore invalid values --- .../java/org/traccar/protocol/HuaShengProtocolDecoder.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java') 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); -- cgit v1.2.3