Skip to content

Commit

Permalink
Decode Meiligao digital inputs and outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed May 21, 2018
1 parent 4b42dab commit 7e6b73a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/org/traccar/protocol/MeiligaoProtocolDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
Expand Down Expand Up @@ -269,7 +270,15 @@ private Position decodeRegular(Position position, String sentence) {
position.setAltitude(parser.nextDouble(0));
}

position.set(Position.KEY_STATUS, parser.next());
if (parser.hasNext()) {
int status = parser.nextHexInt();
for (int i = 1; i <= 5; i++) {
position.set(Position.PREFIX_OUT + i, BitUtil.check(status, i - 1));
}
for (int i = 1; i <= 5; i++) {
position.set(Position.PREFIX_IN + i, BitUtil.check(status, i - 1 + 8));
}
}

for (int i = 1; i <= 8; i++) {
position.set(Position.PREFIX_ADC + i, parser.nextHexInt());
Expand Down

0 comments on commit 7e6b73a

Please sign in to comment.