diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-06-19 10:27:14 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-06-19 10:27:14 -0700 |
commit | cfe72dc8cded38c6426fdcc6db22defeae2e1caf (patch) | |
tree | 4337857afa8c64b984087566083b004ea03f0d2a /src/main/java/org | |
parent | a17db18001085f64599699560087b4bf56ee1711 (diff) | |
download | trackermap-server-cfe72dc8cded38c6426fdcc6db22defeae2e1caf.tar.gz trackermap-server-cfe72dc8cded38c6426fdcc6db22defeae2e1caf.tar.bz2 trackermap-server-cfe72dc8cded38c6426fdcc6db22defeae2e1caf.zip |
Fix harsh driving decoding
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java | 28 |
1 files changed, 17 insertions, 11 deletions
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); } |