aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/protocol/G1rusProtocolDecoder.java8
-rw-r--r--src/test/java/org/traccar/protocol/G1rusProtocolDecoderTest.java18
2 files changed, 24 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/G1rusProtocolDecoder.java b/src/main/java/org/traccar/protocol/G1rusProtocolDecoder.java
index e974e446d..17cfbc1eb 100644
--- a/src/main/java/org/traccar/protocol/G1rusProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/G1rusProtocolDecoder.java
@@ -124,8 +124,12 @@ public class G1rusProtocolDecoder extends BaseProtocolDecoder {
ByteBuf buf = (ByteBuf) msg;
+ buf.readUnsignedByte(); // header
+ buf.readUnsignedByte(); // version
+
int type = buf.readUnsignedByte();
String imei = String.valueOf(buf.readLong());
+ buf.readerIndex(buf.readerIndex() - 1);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession == null) {
return null;
@@ -144,14 +148,14 @@ public class G1rusProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.to(subtype, 6) == MSG_REGULAR) {
positions.add(decodeRegular(deviceSession, buf, subtype));
} else {
- buf.skipBytes(length);
+ buf.skipBytes(length - 1);
}
}
return positions.isEmpty() ? null : positions;
}
- buf.skipBytes(2);
+ buf.readUnsignedShort(); // checksum
buf.readUnsignedByte(); // tail
return null;
diff --git a/src/test/java/org/traccar/protocol/G1rusProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/G1rusProtocolDecoderTest.java
new file mode 100644
index 000000000..c8b4e35fe
--- /dev/null
+++ b/src/test/java/org/traccar/protocol/G1rusProtocolDecoderTest.java
@@ -0,0 +1,18 @@
+package org.traccar.protocol;
+
+import org.junit.Test;
+import org.traccar.ProtocolTest;
+
+public class G1rusProtocolDecoderTest extends ProtocolTest {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ var decoder = inject(new G1rusProtocolDecoder(null));
+
+ verifyPositions(decoder, binary(
+ "f84604000d85f5e55298004b012ad7d524003d1d0f50726f6d61205361742031303030201556312e31302656312e312e340a03120fa0142b8475a157050401846dfc060175120a29a10d02440111002100310041005107d10ef8"));
+
+ }
+
+}