From 7cf79580a419021d3df6e57c48ded38789a08ff3 Mon Sep 17 00:00:00 2001 From: Malcolm Robb Date: Sun, 28 Apr 2013 20:53:30 +0100 Subject: [PATCH] Change the message length decision Assume that DF0-DF15 are all short 56 bit messages Assume that DF16-DF31 are all long 112 bit messages This helps us error detect and error recover for bits in the first byte --- dump1090.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/dump1090.c b/dump1090.c index 5d02c62..6937f13 100644 --- a/dump1090.c +++ b/dump1090.c @@ -1125,16 +1125,15 @@ uint32_t modesChecksum(unsigned char *msg, int bits) { } return crc; // 24 bit checksum. } - -/* Given the Downlink Format (DF) of the message, return the message length - * in bits. */ +// +// Given the Downlink Format (DF) of the message, return the message length in bits. +// +// All known DF's 16 or greater are long. All known DF's 15 or less are short. +// There are lots of unused codes in both category, so we can assume ICAO will stick to +// these rules, meaning that the most significant bit of the DF indicates the length. +// int modesMessageLenByType(int type) { - if (type == 16 || type == 17 || - type == 19 || type == 20 || - type == 21) - return MODES_LONG_MSG_BITS; - else - return MODES_SHORT_MSG_BITS; + return (type & 0x10) ? MODES_LONG_MSG_BITS : MODES_SHORT_MSG_BITS ; } /* Try to fix single bit errors using the checksum. On success modifies