Skip to content

Commit

Permalink
Galileo Iridium frame decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Jun 15, 2023
1 parent 94fbc93 commit 03650ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/java/org/traccar/protocol/GalileoFrameDecoder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
* Copyright 2013 - 2023 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@

public class GalileoFrameDecoder extends BaseFrameDecoder {

private static final int MESSAGE_MINIMUM_LENGTH = 5;
private static final int MESSAGE_MINIMUM_LENGTH = 6;

@Override
protected Object decode(
Expand All @@ -32,9 +32,15 @@ protected Object decode(
return null;
}

int length = buf.getUnsignedShortLE(buf.readerIndex() + 1) & 0x7fff;
if (buf.readableBytes() >= (length + MESSAGE_MINIMUM_LENGTH)) {
return buf.readRetainedSlice(length + MESSAGE_MINIMUM_LENGTH);
int length;
if (buf.getByte(buf.readerIndex()) == 0x01 && buf.getUnsignedMedium(buf.readerIndex() + 3) == 0x01001c) {
length = 3 + buf.getUnsignedShort(buf.readerIndex() + 1);
} else {
length = 5 + (buf.getUnsignedShortLE(buf.readerIndex() + 1) & 0x7fff);
}

if (buf.readableBytes() >= length) {
return buf.readRetainedSlice(length);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public void testDecode() throws Exception {

var decoder = inject(new GalileoFrameDecoder());

assertEquals(
binary("01003f01001c475b166133303035333430363431383437393000001d000064897bb003000b0221c20512a60a0000000802000f209d7b8964300f2536fbfd103c1d01"),
decoder.decode(null, null, binary("01003f01001c475b166133303035333430363431383437393000001d000064897bb003000b0221c20512a60a0000000802000f209d7b8964300f2536fbfd103c1d01")));

assertEquals(
binary("011780011102e603383633353931303238393630323437043200801c"),
decoder.decode(null, null, binary("011780011102e603383633353931303238393630323437043200801c")));
Expand Down

0 comments on commit 03650ff

Please sign in to comment.