From cfe72dc8cded38c6426fdcc6db22defeae2e1caf Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 19 Jun 2021 10:27:14 -0700 Subject: Fix harsh driving decoding --- .../traccar/protocol/RuptelaProtocolDecoder.java | 28 +++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java index b6378f416..5c2885a8b 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -111,14 +111,20 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_TEMP + (id - 78), readValue(buf, length, true) * 0.1); break; case 198: - position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED); + if (readValue(buf, length, false) > 0) { + position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED); + } break; case 199: case 200: - position.set(Position.KEY_ALARM, Position.ALARM_BRAKING); + if (readValue(buf, length, false) > 0) { + position.set(Position.KEY_ALARM, Position.ALARM_BRAKING); + } break; case 201: - position.set(Position.KEY_ALARM, Position.ALARM_ACCELERATION); + if (readValue(buf, length, false) > 0) { + position.set(Position.KEY_ALARM, Position.ALARM_ACCELERATION); + } break; default: position.set(Position.PREFIX_IO + id, readValue(buf, length, false)); @@ -181,29 +187,29 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { } // Read 1 byte data - int cnt = buf.readUnsignedByte(); - for (int j = 0; j < cnt; j++) { + int valueCount = buf.readUnsignedByte(); + for (int j = 0; j < valueCount; j++) { int id = type == MSG_EXTENDED_RECORDS ? buf.readUnsignedShort() : buf.readUnsignedByte(); decodeParameter(position, id, buf, 1); } // Read 2 byte data - cnt = buf.readUnsignedByte(); - for (int j = 0; j < cnt; j++) { + valueCount = buf.readUnsignedByte(); + for (int j = 0; j < valueCount; j++) { int id = type == MSG_EXTENDED_RECORDS ? buf.readUnsignedShort() : buf.readUnsignedByte(); decodeParameter(position, id, buf, 2); } // Read 4 byte data - cnt = buf.readUnsignedByte(); - for (int j = 0; j < cnt; j++) { + valueCount = buf.readUnsignedByte(); + for (int j = 0; j < valueCount; j++) { int id = type == MSG_EXTENDED_RECORDS ? buf.readUnsignedShort() : buf.readUnsignedByte(); decodeParameter(position, id, buf, 4); } // Read 8 byte data - cnt = buf.readUnsignedByte(); - for (int j = 0; j < cnt; j++) { + valueCount = buf.readUnsignedByte(); + for (int j = 0; j < valueCount; j++) { int id = type == MSG_EXTENDED_RECORDS ? buf.readUnsignedShort() : buf.readUnsignedByte(); decodeParameter(position, id, buf, 8); } -- cgit v1.2.3