Skip to content

Commit

Permalink
Fixed TCAS version in BDS1,0 (DataLinkCapabilityReport)
Browse files Browse the repository at this point in the history
The method interpreted bit 39 and 40 in the wrong order. See DO-181E,
Table B-3-16

Fixes #26
  • Loading branch information
fixje committed Dec 4, 2024
1 parent e157daa commit f88f2d8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ static boolean extractTcasRataCapability(byte[] message) {
}

static short extractTcasVersionNumber(byte[] message) {
return (short) (message[4] & 0x03);
return (short) ( ((message[4]<<1) & 0x02) | ((message[4]>>>1) & 0x01) );
}

static boolean extractBasicDataFlashCapability(byte[] message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void tcasRataCapability() {

@Test
public void tcasVersionNumber() {
assertEquals(1, DataLinkCapabilityReport.extractTcasVersionNumber(msg));
assertEquals(2, DataLinkCapabilityReport.extractTcasVersionNumber(msg));
}

@Test
Expand Down Expand Up @@ -139,4 +139,43 @@ public void extractChangeFlag() {
assertTrue(DataLinkCapabilityReport.extractChangeFlag(msg));
}

@Test
void tcacsVersion0() {
byte[] message = new byte[]{
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0b11111100,
(byte) 0xff, (byte) 0xff
};
assertEquals(0, DataLinkCapabilityReport.extractTcasVersionNumber(message));
}

@Test
void tcacsVersion1() {
byte[] message = new byte[]{
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0b11111110,
(byte) 0xff, (byte) 0xff
};
assertEquals(1, DataLinkCapabilityReport.extractTcasVersionNumber(message));
}

@Test
void tcacsVersion2() {
byte[] message = new byte[]{
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0b11111101,
(byte) 0xff, (byte) 0xff
};
assertEquals(2, DataLinkCapabilityReport.extractTcasVersionNumber(message));
}

@Test
void tcacsVersion3() {
byte[] message = new byte[]{
(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0b11111111,
(byte) 0xff, (byte) 0xff
};
assertEquals(3, DataLinkCapabilityReport.extractTcasVersionNumber(message));
}
}

0 comments on commit f88f2d8

Please sign in to comment.