aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolay Vlahovski <nvlahovski@gmail.com>2023-05-17 12:10:17 +0300
committerNikolay Vlahovski <nvlahovski@gmail.com>2023-05-17 12:10:17 +0300
commit34f6dfbf1d2c48ae932fa7565dd30d2817d2c1f9 (patch)
tree47d4e935c1aacd4f6d201fa1c4810de9459c8090
parentb7d46d78adc763eea3aae838f4e056e12e2dc487 (diff)
downloadtrackermap-server-34f6dfbf1d2c48ae932fa7565dd30d2817d2c1f9.tar.gz
trackermap-server-34f6dfbf1d2c48ae932fa7565dd30d2817d2c1f9.tar.bz2
trackermap-server-34f6dfbf1d2c48ae932fa7565dd30d2817d2c1f9.zip
remove extra empty lines
-rw-r--r--src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java8
-rw-r--r--src/test/java/org/traccar/protocol/TranSyncProtocolDecoderTest.java6
2 files changed, 7 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java b/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java
index 759c012b8..acb46ec48 100644
--- a/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java
@@ -131,7 +131,9 @@ public class TranSyncProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
+
ByteBuf buf = (ByteBuf) msg;
+
if (Arrays.equals(ByteBufUtil.getBytes(buf, 0, 2), STX)) {
buf.readUnsignedShort();
}
@@ -183,14 +185,14 @@ public class TranSyncProtocolDecoder extends BaseProtocolDecoder {
position.setNetwork(new Network(cellTower));
- if (buf.readableBytes() > 2) {
+ if (buf.readableBytes() > 5) {
buf.readUnsignedByte(); // odometerIndex
int odometerLength = buf.readUnsignedByte();
if (odometerLength > 0) {
int odometer = buf.readBytes(odometerLength).readInt();
position.set(Position.KEY_ODOMETER, odometer);
}
- if ((buf.readableBytes() > 2)) {
+ if ((buf.readableBytes() > 5)) {
buf.readUnsignedByte(); // tagIndex
int tagLength = buf.readUnsignedByte();
if (tagLength > 0) {
@@ -205,7 +207,7 @@ public class TranSyncProtocolDecoder extends BaseProtocolDecoder {
}
}
if ((buf.readableBytes() > 5)) {
- buf.readUnsignedByte(); // adc2Index
+ buf.readUnsignedByte(); // adc3Index
int adc2Length = buf.readUnsignedByte();
if (adc2Length > 0 && adc2Length <= buf.readableBytes() - 2) {
position.set(Position.PREFIX_ADC + 3, buf.readUnsignedShort());
diff --git a/src/test/java/org/traccar/protocol/TranSyncProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TranSyncProtocolDecoderTest.java
index 6cf2d0c1f..c84ae2e0f 100644
--- a/src/test/java/org/traccar/protocol/TranSyncProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/TranSyncProtocolDecoderTest.java
@@ -10,10 +10,8 @@ public class TranSyncProtocolDecoderTest extends ProtocolTest {
var decoder = inject(new TranSyncProtocolDecoder(null));
- verifyPosition(decoder, binary(
- "3a3a2b583f086065705154043900801017050b11190f01623ef40887dff00000c25e9ff707000007152a2d0000000105004794916902050000100000050252ee060200822323"));
+ verifyPosition(decoder, binary("3a3a2b583f086065705154043900801017050b11190f01623ef40887dff00000c25e9ff707000007152a2d0000000105004794916902050000100000050252ee060200822323"));
- verifyAttributes(decoder, binary(
- "3a3a2b583f086065705154043900801017050b11190f01623ef40887dff00000c25e9ff707000007152a2d0000000105004794916902050000000000050252ee060200822323"));
+ verifyAttributes(decoder, binary("3a3a2b583f086065705154043900801017050b11190f01623ef40887dff00000c25e9ff707000007152a2d0000000105004794916902050000000000050252ee060200822323"));
}
}