dump1090-fa/crc.h

40 lines
1.4 KiB
C
Raw Permalink Normal View History

2015-01-20 16:49:01 +00:00
// Part of dump1090, a Mode S message decoder for RTLSDR devices.
2015-01-19 23:41:26 +00:00
//
2015-01-20 16:49:01 +00:00
// crc.h: Mode S checksum prototypes.
2015-01-19 23:41:26 +00:00
//
2015-01-20 16:49:01 +00:00
// Copyright (c) 2014,2015 Oliver Jowett <oliver@mutability.co.uk>
2015-01-19 23:41:26 +00:00
//
// This file is free software: you may copy, redistribute and/or modify it
2015-01-20 16:49:01 +00:00
// under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 2 of the License, or (at your
// option) any later version.
2015-01-19 23:41:26 +00:00
//
// This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2015-01-20 16:49:01 +00:00
// General Public License for more details.
2015-01-19 23:41:26 +00:00
//
// You should have received a copy of the GNU General Public License
2015-01-20 16:49:01 +00:00
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2015-01-19 23:41:26 +00:00
#ifndef DUMP1090_CRC_H
#define DUMP1090_CRC_H
#include <stdint.h>
// Global max for fixable bit erros
#define MODES_MAX_BITERRORS 2
struct errorinfo {
uint32_t syndrome; // CRC syndrome
int errors; // number of errors
int8_t bit[MODES_MAX_BITERRORS]; // bit positions to fix (-1 = no bit)
};
void modesChecksumInit(int fixBits);
Overhaul of message scoring & error correction. Major changes: Try to error-correct all messages that potentially could be DF11/17/18 even if the original DF value is different. This allows messages with correctable damage in the first 5 bits to be correctable. Track recently-seen DF18 addresses separately to DF17 addresses. DF18 does not imply Mode S support, so we don't want to treat it like a known Mode S emitter, but once we've heard some DF18 for an aircraft we can be more confident about future DF18 messages for the same address. Rework the scoring system so it's just a big enum that lists all the possible outcomes in the order that we want. This makes the relative ordering of different messages clearer, and makes it easier to move messages above/below the accept thresholds as needed. Don't accept 2-bit-error-corrected messages that are from aircraft we have not previously seen. This greatly reduces the number of garbage messages when using 2-bit error correction. Overall results are: * more CPU required for decoding (approx 30% increase in my tests) as we're doing a lot more speculative CRC-checking work * no significant change to message rates with error correction off * about 5% more 1-bit-corrected DF17 decodes, with a disproportionate increase in those messages contributing to successful position decodes / unique aircraft counts * _fewer_ decodes with 2-bit correction (versus old code with 2-bit correction), but the message quality is substantially improved, the rate of garbage decodes / phantom aircraft is greatly reduced sample stats: 1-bit correction, old code: 141158 total usable messages 137852 accepted with correct CRC 3306 accepted with 1-bit error repaired 27446 DF17 messages 51 unique aircraft tracks 1-bit correction, new code: 141296 total usable messages 137854 accepted with correct CRC 3442 accepted with 1-bit error repaired 27528 DF17 messages 55 unique aircraft tracks 2-bit correction, old code: 142656 total usable messages 137809 accepted with correct CRC 3283 accepted with 1-bit error repaired 1564 accepted with 2-bit error repaired 28803 DF17 messages 349 unique aircraft tracks (<- note that most of these are garbage) 2-bit correction, new code: 142426 total usable messages 137822 accepted with correct CRC 3420 accepted with 1-bit error repaired 1184 accepted with 2-bit error repaired 28666 DF17 messages 55 unique aircraft tracks
2021-02-09 11:43:38 +00:00
uint32_t modesChecksum(const uint8_t *msg, int bitlen);
struct errorinfo *modesChecksumDiagnose(uint32_t syndrome, int bitlen);
void modesChecksumFix(uint8_t *msg, struct errorinfo *info);
2015-01-19 23:41:26 +00:00
#endif