Squawk extraction fixed.
This commit is contained in:
parent
b4805ea7d4
commit
c9bb48675c
37
dump1090.c
37
dump1090.c
|
@ -705,7 +705,7 @@ int ICAOAddressWasRecentlySeen(uint32_t addr) {
|
||||||
* If the function successfully recovers a message with a correct checksum
|
* If the function successfully recovers a message with a correct checksum
|
||||||
* it returns 1. Otherwise 0 is returned. */
|
* it returns 1. Otherwise 0 is returned. */
|
||||||
int bruteForceAP(unsigned char *msg, int msgbits) {
|
int bruteForceAP(unsigned char *msg, int msgbits) {
|
||||||
unsigned char aux[MODES_LONG_MSG_BITS/8];
|
unsigned char aux[MODES_LONG_MSG_BYTES];
|
||||||
int msgtype = msg[0]>>3;
|
int msgtype = msg[0]>>3;
|
||||||
|
|
||||||
if (msgtype == 0 || /* Short air surveillance */
|
if (msgtype == 0 || /* Short air surveillance */
|
||||||
|
@ -907,7 +907,37 @@ void decodeModesMessage(struct modesMessage *mm, unsigned char *msg) {
|
||||||
mm->dr = msg[1] >> 3 & 31; /* Request extraction of downlink request. */
|
mm->dr = msg[1] >> 3 & 31; /* Request extraction of downlink request. */
|
||||||
mm->um = ((msg[1] & 7)<<3)| /* Request extraction of downlink request. */
|
mm->um = ((msg[1] & 7)<<3)| /* Request extraction of downlink request. */
|
||||||
msg[2]>>5;
|
msg[2]>>5;
|
||||||
mm->identity = (msg[2]&31 << 8) | msg[3]; /* 13 bits identity. */
|
|
||||||
|
/* In the squawk (identity) field bits are interleaved like that
|
||||||
|
* (message bit 20 to bit 32):
|
||||||
|
*
|
||||||
|
* C1-A1-C2-A2-C4-A4-ZERO-B1-D1-B2-D2-B4-D4
|
||||||
|
*
|
||||||
|
* So every group of three bits A, B, C, D represent an integer
|
||||||
|
* from 0 to 7.
|
||||||
|
*
|
||||||
|
* The actual meaning is just 4 octal numbers, but we convert it
|
||||||
|
* into a base ten number tha happens to represent the four
|
||||||
|
* octal numbers.
|
||||||
|
*
|
||||||
|
* For more info: http://en.wikipedia.org/wiki/Gillham_code */
|
||||||
|
{
|
||||||
|
int a,b,c,d;
|
||||||
|
|
||||||
|
a = ((msg[3] & 0x80) >> 5) |
|
||||||
|
((msg[2] & 0x02) >> 0) |
|
||||||
|
((msg[2] & 0x08) >> 3);
|
||||||
|
b = ((msg[3] & 0x02) << 1) |
|
||||||
|
((msg[3] & 0x08) >> 2) |
|
||||||
|
((msg[3] & 0x20) >> 5);
|
||||||
|
c = ((msg[2] & 0x01) << 2) |
|
||||||
|
((msg[2] & 0x04) >> 1) |
|
||||||
|
((msg[2] & 0x10) >> 4);
|
||||||
|
d = ((msg[3] & 0x01) << 2) |
|
||||||
|
((msg[3] & 0x04) >> 1) |
|
||||||
|
((msg[3] & 0x10) >> 4);
|
||||||
|
mm->identity = a*1000 + b*100 + c*10 + d;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if we can check the checksum for the Downlink Formats where
|
/* Check if we can check the checksum for the Downlink Formats where
|
||||||
* the checksum is xored with the aircraft ICAO address. We try to
|
* the checksum is xored with the aircraft ICAO address. We try to
|
||||||
|
@ -926,6 +956,7 @@ void decodeModesMessage(struct modesMessage *mm, unsigned char *msg) {
|
||||||
mm->crcok = 0;
|
mm->crcok = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this is DF 11 or DF 17 and the checksum was ok,
|
/* If this is DF 11 or DF 17 and the checksum was ok,
|
||||||
* we can add this address to the list of recently seen
|
* we can add this address to the list of recently seen
|
||||||
* addresses. */
|
* addresses. */
|
||||||
|
@ -1056,7 +1087,7 @@ void displayModesMessage(struct modesMessage *mm) {
|
||||||
printf(" Flight Status : %s\n", fs_str[mm->fs]);
|
printf(" Flight Status : %s\n", fs_str[mm->fs]);
|
||||||
printf(" DR : %d\n", mm->dr);
|
printf(" DR : %d\n", mm->dr);
|
||||||
printf(" UM : %d\n", mm->um);
|
printf(" UM : %d\n", mm->um);
|
||||||
printf(" Squawk : %o (octal)\n", mm->identity);
|
printf(" Squawk : %d\n", mm->identity);
|
||||||
printf(" ICAO Address : %02x%02x%02x\n", mm->aa1, mm->aa2, mm->aa3);
|
printf(" ICAO Address : %02x%02x%02x\n", mm->aa1, mm->aa2, mm->aa3);
|
||||||
|
|
||||||
if (mm->msgtype == 21) {
|
if (mm->msgtype == 21) {
|
||||||
|
|
Loading…
Reference in a new issue