From 0d7bbac6a1820d092e5dd3ca2a474f327f15e115 Mon Sep 17 00:00:00 2001 From: heurist1 Date: Sat, 30 Oct 2021 00:53:29 +0100 Subject: [PATCH] Added switching message length Improves detections in test file from 77 to 80 --- firmware/baseband/proc_adsbrx.cpp | 7 ++++++- firmware/baseband/proc_adsbrx.hpp | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/firmware/baseband/proc_adsbrx.cpp b/firmware/baseband/proc_adsbrx.cpp index 5a933bb1..7854accd 100644 --- a/firmware/baseband/proc_adsbrx.cpp +++ b/firmware/baseband/proc_adsbrx.cpp @@ -54,7 +54,7 @@ void ADSBRXProcessor::execute(const buffer_c8_t& buffer) { // 1 bit lasts 2 samples if (sample_count & 1) { - if (bit_count >= 112) + if (bit_count >= msgLen) { const ADSBFrameMessage message(frame); shared_memory.application_queue.push(message); @@ -80,6 +80,10 @@ void ADSBRXProcessor::execute(const buffer_c8_t& buffer) { if (!(bit_count & 7)) { // Got one byte frame.push_byte(byte); + // Check at the end of the first byte of the message + if ( (bit_count == 8) && !(byte & (0x10<<3)) ) { + msgLen = 56; // DFs 16 or greater are long 112. DFs 15 or less are short 56. + } } } // Second sample of each bit sample_count++; @@ -126,6 +130,7 @@ void ADSBRXProcessor::execute(const buffer_c8_t& buffer) { { //if (c == ADSB_PREAMBLE_LENGTH) { decoding = true; + msgLen = 112; sample_count = 0; bit_count = 0; frame.clear(); diff --git a/firmware/baseband/proc_adsbrx.hpp b/firmware/baseband/proc_adsbrx.hpp index f705b8c8..4d7ecf47 100644 --- a/firmware/baseband/proc_adsbrx.hpp +++ b/firmware/baseband/proc_adsbrx.hpp @@ -53,6 +53,7 @@ private: float threshold { }, threshold_low { }, threshold_high { }; //size_t null_count{ 0 }; size_t bit_count { 0 }, sample_count { 0 }; + size_t msgLen{ 112 }; //std::pair shifter[ADSB_PREAMBLE_LENGTH]; float shifter[ADSB_PREAMBLE_LENGTH]; bool decoding { };