aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny S Maksimov <me@vragam.net>2019-01-23 22:43:09 +0300
committerEvgeny S Maksimov <me@vragam.net>2019-01-23 22:43:09 +0300
commit7601d1625dbe3ffbbfeb0f81c224fc4bce8bbcdc (patch)
treed815b5ec9511e5524e15332ea709841cc3fbc967 /src
parent55d5d635b321af3b8c3086e8f47afc44fa7e4084 (diff)
downloadtraccar-server-7601d1625dbe3ffbbfeb0f81c224fc4bce8bbcdc.tar.gz
traccar-server-7601d1625dbe3ffbbfeb0f81c224fc4bce8bbcdc.tar.bz2
traccar-server-7601d1625dbe3ffbbfeb0f81c224fc4bce8bbcdc.zip
Use BitUtil for some bit operations
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/NavisProtocolDecoder.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java
index 4bce4e37f..1e474556a 100644
--- a/src/org/traccar/protocol/NavisProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavisProtocolDecoder.java
@@ -137,7 +137,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
} else if (isFormat(format, F50, F51, F52)) {
short extField = buf.readUnsignedByte();
position.set(Position.KEY_OUTPUT, extField & 0x3);
- position.set(Position.KEY_SATELLITES, extField >> 2);
+ position.set(Position.KEY_SATELLITES, BitUtil.from(extField, 2));
position.set(Position.PREFIX_OUT + 1, BitUtil.check(extField, 0));
position.set(Position.PREFIX_OUT + 2, BitUtil.check(extField, 1));
} else if (isFormat(format, F40, F60)) {
@@ -160,10 +160,10 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_IN + 2, BitUtil.check(input, 1));
position.set(Position.PREFIX_IN + 3, BitUtil.check(input, 2));
position.set(Position.PREFIX_IN + 4, BitUtil.check(input, 3));
- position.set(Position.PREFIX_IN + 5, (input & 0x70) >> 4);
- position.set(Position.PREFIX_IN + 6, (input & 0x380) >> 7);
- position.set(Position.PREFIX_IN + 7, (input & 0xC00) >> 10);
- position.set(Position.PREFIX_IN + 8, (input & 0x3000) >> 12);
+ position.set(Position.PREFIX_IN + 5, BitUtil.between(input, 4, 7));
+ position.set(Position.PREFIX_IN + 6, BitUtil.between(input, 7, 10));
+ position.set(Position.PREFIX_IN + 7, BitUtil.between(input, 10, 12));
+ position.set(Position.PREFIX_IN + 5, BitUtil.between(input, 12, 14));
}
} else if (isFormat(format, F50, F51, F52, F60)) {
short input = buf.readUnsignedByte();
@@ -227,7 +227,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
int navSensorState = buf.readUnsignedByte();
position.setValid(BitUtil.check(navSensorState, 1));
if (isFormat(format, F60)) {
- position.set(Position.KEY_SATELLITES, navSensorState >> 2);
+ position.set(Position.KEY_SATELLITES, BitUtil.from(navSensorState, 2));
}
DateBuilder dateBuilder = new DateBuilder()
@@ -369,7 +369,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
case 7:
int navSensorState = buf.readUnsignedByte();
position.setValid(BitUtil.check(navSensorState, 1));
- position.set(Position.KEY_SATELLITES, navSensorState >> 2);
+ position.set(Position.KEY_SATELLITES, BitUtil.from(navSensorState, 2));
break;
case 8:
position.setTime(new DateBuilder(new Date(buf.readUnsignedIntLE() * 1000)).getDate());
@@ -511,7 +511,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
int navSensorState = buf.readUnsignedByte();
position.setValid(BitUtil.check(navSensorState, 1));
- position.set(Position.KEY_SATELLITES, navSensorState >> 2);
+ position.set(Position.KEY_SATELLITES, BitUtil.from(navSensorState, 2));
position.setTime(new DateBuilder(new Date(buf.readUnsignedIntLE() * 1000)).getDate());
position.setLatitude(buf.readIntLE() / 600000.0);