diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-04-08 15:26:06 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-04-08 15:26:06 +0200 |
commit | c4d841b4901563e38f705f62860d6214da53a689 (patch) | |
tree | be6b74c0072a5253bb179ece95f8edb721a6d616 /src/fig | |
parent | eedbb66a46d0a0b55e2e2816ff09a692a3b680e6 (diff) | |
download | dabmux-c4d841b4901563e38f705f62860d6214da53a689.tar.gz dabmux-c4d841b4901563e38f705f62860d6214da53a689.tar.bz2 dabmux-c4d841b4901563e38f705f62860d6214da53a689.zip |
Clean up FIG carousel a bit
Diffstat (limited to 'src/fig')
-rw-r--r-- | src/fig/FIG.cpp | 2 | ||||
-rw-r--r-- | src/fig/FIG.h | 7 | ||||
-rw-r--r-- | src/fig/FIG0_1.cpp | 9 | ||||
-rw-r--r-- | src/fig/FIG0_1.h | 6 | ||||
-rw-r--r-- | src/fig/FIG0_10.h | 2 | ||||
-rw-r--r-- | src/fig/FIG0_13.h | 1 | ||||
-rw-r--r-- | src/fig/FIG0_17.h | 2 | ||||
-rw-r--r-- | src/fig/FIG0_2.h | 1 | ||||
-rw-r--r-- | src/fig/FIG0_8.h | 1 | ||||
-rw-r--r-- | src/fig/FIG0_9.h | 2 | ||||
-rw-r--r-- | src/fig/FIG0structs.h | 2 | ||||
-rw-r--r-- | src/fig/FIGCarousel.cpp | 82 | ||||
-rw-r--r-- | src/fig/FIGCarousel.h | 8 |
13 files changed, 65 insertions, 60 deletions
diff --git a/src/fig/FIG.cpp b/src/fig/FIG.cpp index e064a33..ed79cf3 100644 --- a/src/fig/FIG.cpp +++ b/src/fig/FIG.cpp @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2016 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li */ diff --git a/src/fig/FIG.h b/src/fig/FIG.h index 116ac8b..9752245 100644 --- a/src/fig/FIG.h +++ b/src/fig/FIG.h @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2016 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li */ @@ -24,8 +24,7 @@ along with ODR-DabMux. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef __FIG_H_ -#define __FIG_H_ +#pragma once #include <memory> #include "MuxElements.h" @@ -106,5 +105,3 @@ class IFIG } // namespace FIC -#endif // __FIG_H_ - diff --git a/src/fig/FIG0_1.cpp b/src/fig/FIG0_1.cpp index 60704f2..d72b301 100644 --- a/src/fig/FIG0_1.cpp +++ b/src/fig/FIG0_1.cpp @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2016 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li */ /* @@ -23,9 +23,7 @@ along with ODR-DabMux. If not, see <http://www.gnu.org/licenses/>. */ -#include "fig/FIG0structs.h" #include "fig/FIG0_1.h" -#include "utils.h" namespace FIC { @@ -101,7 +99,7 @@ FillStatus FIG0_1::fill(uint8_t *buf, size_t max_size) size_t remaining = max_size; etiLog.level(FIG0_1_TRACE) << "FIG0_1::fill initialised=" << - (m_initialised ? 1 : 0); + (m_initialised ? 1 : 0) << " max_size=" << max_size; const int watermark_bit = (m_watermarkData[m_watermarkPos >> 3] >> (7 - (m_watermarkPos & 0x07))) & 1; @@ -130,7 +128,8 @@ FillStatus FIG0_1::fill(uint8_t *buf, size_t max_size) for (; subchannelFIG0_1 != subchannels.end(); ++subchannelFIG0_1 ) { size_t subch_iter_ix = std::distance(subchannels.begin(), subchannelFIG0_1); - etiLog.level(FIG0_1_TRACE) << "FIG0_1::fill loop ix=" << subch_iter_ix; + etiLog.level(FIG0_1_TRACE) << "FIG0_1::fill loop ix=" << subch_iter_ix << + " of " << subchannels.size(); dabProtection* protection = &(*subchannelFIG0_1)->protection; diff --git a/src/fig/FIG0_1.h b/src/fig/FIG0_1.h index 4fc70ea..2bb898f 100644 --- a/src/fig/FIG0_1.h +++ b/src/fig/FIG0_1.h @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2016 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li */ /* @@ -26,11 +26,11 @@ #pragma once #include <cstdint> -#include <vector> +#include "fig/FIG.h" namespace FIC { -// FIG type 0/1, MIC, Sub-Channel Organization, +// FIG type 0/1, MCI, Sub-Channel Organization, // one instance of the part for each subchannel class FIG0_1 : public IFIG { diff --git a/src/fig/FIG0_10.h b/src/fig/FIG0_10.h index bc4a84b..69ba342 100644 --- a/src/fig/FIG0_10.h +++ b/src/fig/FIG0_10.h @@ -26,7 +26,7 @@ #pragma once #include <cstdint> -#include <vector> +#include "fig/FIG.h" namespace FIC { diff --git a/src/fig/FIG0_13.h b/src/fig/FIG0_13.h index 18159f0..00b5137 100644 --- a/src/fig/FIG0_13.h +++ b/src/fig/FIG0_13.h @@ -27,6 +27,7 @@ #include <cstdint> #include <vector> +#include "fig/FIG.h" namespace FIC { diff --git a/src/fig/FIG0_17.h b/src/fig/FIG0_17.h index d796f43..8d478c0 100644 --- a/src/fig/FIG0_17.h +++ b/src/fig/FIG0_17.h @@ -26,7 +26,7 @@ #pragma once #include <cstdint> -#include <vector> +#include "fig/FIG.h" namespace FIC { diff --git a/src/fig/FIG0_2.h b/src/fig/FIG0_2.h index 6cfca24..a96f189 100644 --- a/src/fig/FIG0_2.h +++ b/src/fig/FIG0_2.h @@ -27,6 +27,7 @@ #include <cstdint> #include <vector> +#include "fig/FIG.h" namespace FIC { // FIG type 0/2, MCI, Service Organization, one instance of diff --git a/src/fig/FIG0_8.h b/src/fig/FIG0_8.h index 64ca8d2..aef86c5 100644 --- a/src/fig/FIG0_8.h +++ b/src/fig/FIG0_8.h @@ -27,6 +27,7 @@ #include <cstdint> #include <vector> +#include "fig/FIG.h" namespace FIC { diff --git a/src/fig/FIG0_9.h b/src/fig/FIG0_9.h index f0ae2ea..ae9b7d1 100644 --- a/src/fig/FIG0_9.h +++ b/src/fig/FIG0_9.h @@ -26,8 +26,8 @@ #pragma once #include <cstdint> -#include <map> #include <list> +#include "fig/FIG.h" namespace FIC { diff --git a/src/fig/FIG0structs.h b/src/fig/FIG0structs.h index eb77df4..5f514b3 100644 --- a/src/fig/FIG0structs.h +++ b/src/fig/FIG0structs.h @@ -26,8 +26,6 @@ #pragma once #include <cstdint> -#include <map> -#include <set> #include "fig/FIG.h" diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp index 4c5c04c..9748dbf 100644 --- a/src/fig/FIGCarousel.cpp +++ b/src/fig/FIGCarousel.cpp @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2020 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li Implementation of the FIG carousel to schedule the FIGs into the @@ -148,11 +148,14 @@ void FIGCarousel::load_and_allocate(IFIG& fig, FIBAllocation fib) m_fibs[fib].push_back(el); } -void FIGCarousel::update(unsigned long currentFrame) +size_t FIGCarousel::write_fibs( + uint8_t *buf, + uint64_t current_frame, + bool fib3_present) { - m_rti.currentFrame = currentFrame; + m_rti.currentFrame = current_frame; - if ((currentFrame % 250) == 0 and m_missed_deadlines.size() > 0) { + if ((current_frame % 250) == 0 and m_missed_deadlines.size() > 0) { std::stringstream ss; for (const auto& fig_missed_count : m_missed_deadlines) { ss << " " << fig_missed_count; @@ -161,21 +164,7 @@ void FIGCarousel::update(unsigned long currentFrame) etiLog.level(info) << "Could not respect repetition rates for FIGs:" << ss.str(); } -} - -void dumpfib(const uint8_t *buf, size_t bufsize) { - std::cerr << "FIB "; - for (size_t i = 0; i < bufsize; i++) { - std::cerr << boost::format("%02x ") % (unsigned int)buf[i]; - } - std::cerr << std::endl; -} -size_t FIGCarousel::write_fibs( - uint8_t *buf, - int framephase, - bool fib3_present) -{ /* Decrement all deadlines of all figs */ for (auto& fib_fig : m_fibs) { auto& fig = fib_fig.second; @@ -183,6 +172,9 @@ size_t FIGCarousel::write_fibs( fig_el.reduce_deadline(); if (fig_el.deadline < 0) { +#if CAROUSELDEBUG + etiLog.level(warn) << " FIG" << fig_el.fig->name() << " LATE"; +#endif m_missed_deadlines.insert(fig_el.fig->name()); } } @@ -192,7 +184,7 @@ size_t FIGCarousel::write_fibs( for (int fib = 0; fib < fibCount; fib++) { memset(buf, 0x00, 30); - size_t figSize = carousel(fib, buf, 30, framephase); + size_t figSize = carousel(fib, buf, 30, current_frame); if (figSize < 30) { buf[figSize] = 0xff; // end marker @@ -219,8 +211,10 @@ size_t FIGCarousel::carousel( int fib, uint8_t *buf, const size_t bufsize, - int framephase) + uint64_t current_frame) { + const int framephase = current_frame % 4; + uint8_t *pbuf = buf; FIBAllocation fibix; @@ -253,9 +247,10 @@ size_t FIGCarousel::carousel( for (auto& fig : sorted_figs) { if (fig->check_deadline()) { #if CAROUSELDEBUG - std::cerr << " FIG" << fig->fig->figtype() << "/" << - fig->fig->figextension() << " deadline changed" << - std::endl; + etiLog.level(debug) << + "FRAME " << current_frame << + " FIG" << fig->fig->figtype() << "/" << + fig->fig->figextension() << " deadline changed"; #endif } } @@ -267,12 +262,18 @@ size_t FIGCarousel::carousel( return left->deadline < right->deadline; }); -#if CAROUSELDEBUG - std::cerr << " ************** FIGs" << std::endl; - for (auto& f : sorted_figs) { - std::cerr << " FIG" << f->fig->figtype() << "/" << - f->fig->figextension() << " deadline " << - f->deadline << std::endl; +#if 0 + { + std::stringstream ss; + ss << "FRAME " << current_frame + << " sorted FIGs "; + + for (auto& f : sorted_figs) { + ss << f->fig->figtype() << "/" << + f->fig->figextension() << "(" << + f->deadline << ") "; + } + etiLog.level(debug) << ss.str(); } #endif @@ -301,8 +302,9 @@ size_t FIGCarousel::carousel( pbuf += written; #if CAROUSELDEBUG - std::cerr << " ****** FIG0/0(special) wrote\t" << written << " bytes" - << std::endl; + etiLog.level(debug) << + "FRAME " << current_frame << + " *** FIG0/0(special) wrote\t" << written << " bytes"; #endif } else { @@ -325,8 +327,9 @@ size_t FIGCarousel::carousel( pbuf += written; #if CAROUSELDEBUG - std::cerr << " ****** FIG0/7(special) wrote\t" << written << " bytes" - << std::endl; + etiLog.level(debug) << + "FRAME " << current_frame << + " ****** FIG0/7(special) wrote\t" << written << " bytes"; #endif } @@ -376,13 +379,14 @@ size_t FIGCarousel::carousel( } #if CAROUSELDEBUG if (written) { - std::cerr << + etiLog.level(debug) << + " FRAME " << current_frame << " ** FIB" << fib << " FIG" << fig_el->fig->figtype() << "/" << fig_el->fig->figextension() << " wrote\t" << written << " bytes" << (status.complete_fig_transmitted ? ", complete" : ", incomplete") << - std::endl; + ", margin " << fig_el->deadline; } #endif @@ -393,7 +397,13 @@ size_t FIGCarousel::carousel( sorted_figs.pop_front(); } - //dumpfib(buf, bufsize); +#if 0 + std::cerr << "FIB "; + for (size_t i = 0; i < bufsize; i++) { + std::cerr << boost::format("%02x ") % (unsigned int)buf[i]; + } + std::cerr << std::endl; +#endif return bufsize - available_size; } diff --git a/src/fig/FIGCarousel.h b/src/fig/FIGCarousel.h index 00b6d18..1e33577 100644 --- a/src/fig/FIGCarousel.h +++ b/src/fig/FIGCarousel.h @@ -3,7 +3,7 @@ 2011, 2012 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2020 + Copyright (C) 2024 Matthias P. Braendli, matthias.braendli@mpb.li Implementation of the FIG carousel to schedule the FIGs into the @@ -69,8 +69,6 @@ class FIGCarousel { public: FIGCarousel(std::shared_ptr<dabEnsemble> ensemble); - void update(unsigned long currentFrame); - /* Write all FIBs to the buffer, including correct padding and crc. * Returns number of bytes written. * @@ -79,11 +77,11 @@ class FIGCarousel { */ size_t write_fibs( uint8_t *buf, - int framephase, + uint64_t current_frame, bool fib3_present); private: - size_t carousel(int fib, uint8_t *buf, size_t bufsize, int framephase); + size_t carousel(int fib, uint8_t *buf, size_t bufsize, uint64_t current_frame); void load_and_allocate(IFIG& fig, FIBAllocation fib); |