diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-05-19 14:48:13 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-05-19 14:48:13 +0200 |
commit | 26b20a9aa0167b64e75b813aaf9b41557b4de3df (patch) | |
tree | 8ea23fc867cde052a70795159e8c122dccd763a7 /lib/edioutput | |
parent | 9067a63a4dd433c6109ba0157db516c9cac398e4 (diff) | |
download | dabmux-26b20a9aa0167b64e75b813aaf9b41557b4de3df.tar.gz dabmux-26b20a9aa0167b64e75b813aaf9b41557b4de3df.tar.bz2 dabmux-26b20a9aa0167b64e75b813aaf9b41557b4de3df.zip |
Common 44ae39c: Make SEQ and PSEQ available on EDI receive and improve error handling
Diffstat (limited to 'lib/edioutput')
-rw-r--r-- | lib/edioutput/AFPacket.cpp | 18 | ||||
-rw-r--r-- | lib/edioutput/AFPacket.h | 9 | ||||
-rw-r--r-- | lib/edioutput/EDIConfig.h | 1 | ||||
-rw-r--r-- | lib/edioutput/PFT.cpp | 8 | ||||
-rw-r--r-- | lib/edioutput/PFT.h | 5 | ||||
-rw-r--r-- | lib/edioutput/TagItems.cpp | 1 | ||||
-rw-r--r-- | lib/edioutput/TagItems.h | 1 | ||||
-rw-r--r-- | lib/edioutput/TagPacket.cpp | 1 | ||||
-rw-r--r-- | lib/edioutput/TagPacket.h | 1 | ||||
-rw-r--r-- | lib/edioutput/Transport.cpp | 15 | ||||
-rw-r--r-- | lib/edioutput/Transport.h | 15 |
11 files changed, 53 insertions, 22 deletions
diff --git a/lib/edioutput/AFPacket.cpp b/lib/edioutput/AFPacket.cpp index b38c38b..323a3b1 100644 --- a/lib/edioutput/AFPacket.cpp +++ b/lib/edioutput/AFPacket.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 + Copyright (C) 2021 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -25,7 +25,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" #include "crc.h" #include "AFPacket.h" #include "TagItems.h" @@ -50,7 +49,7 @@ AFPacket AFPacketiser::Assemble(TagPacket tag_packet) std::vector<uint8_t> payload = tag_packet.Assemble(); if (m_verbose) - std::cerr << "Assemble AFPacket " << seq << std::endl; + std::cerr << "Assemble AFPacket " << m_seq << std::endl; std::string pack_data("AF"); // SYNC std::vector<uint8_t> packet(pack_data.begin(), pack_data.end()); @@ -67,10 +66,10 @@ AFPacket AFPacketiser::Assemble(TagPacket tag_packet) packet.push_back(taglength & 0xFF); // fill rest of header - packet.push_back(seq >> 8); - packet.push_back(seq & 0xFF); - seq++; - packet.push_back((have_crc ? 0x80 : 0) | AFHEADER_VERSION); // ar_cf: CRC=1 + packet.push_back(m_seq >> 8); + packet.push_back(m_seq & 0xFF); + m_seq++; + packet.push_back((m_have_crc ? 0x80 : 0) | AFHEADER_VERSION); // ar_cf: CRC=1 packet.push_back(AFHEADER_PT_TAG); // insert payload, must have a length multiple of 8 bytes @@ -93,4 +92,9 @@ AFPacket AFPacketiser::Assemble(TagPacket tag_packet) return packet; } +void AFPacketiser::OverrideSeq(uint16_t seq) +{ + m_seq = seq; +} + } diff --git a/lib/edioutput/AFPacket.h b/lib/edioutput/AFPacket.h index f2c4e35..6e6ec47 100644 --- a/lib/edioutput/AFPacket.h +++ b/lib/edioutput/AFPacket.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 + Copyright (C) 2021 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -28,7 +28,6 @@ #pragma once -#include "config.h" #include <vector> #include <cstdint> #include "TagItems.h" @@ -49,10 +48,12 @@ class AFPacketiser AFPacket Assemble(TagPacket tag_packet); + void OverrideSeq(uint16_t seq); + private: - static const bool have_crc = true; + static const bool m_have_crc = true; - uint16_t seq = 0; //counter that overflows at 0xFFFF + uint16_t m_seq = 0; //counter that overflows at 0xFFFF bool m_verbose; }; diff --git a/lib/edioutput/EDIConfig.h b/lib/edioutput/EDIConfig.h index be6c9c4..d57e9ce 100644 --- a/lib/edioutput/EDIConfig.h +++ b/lib/edioutput/EDIConfig.h @@ -27,7 +27,6 @@ #pragma once -#include "config.h" #include <vector> #include <string> #include <memory> diff --git a/lib/edioutput/PFT.cpp b/lib/edioutput/PFT.cpp index b2f07e0..7e0e8e9 100644 --- a/lib/edioutput/PFT.cpp +++ b/lib/edioutput/PFT.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 + Copyright (C) 2021 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -30,7 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" #include <vector> #include <list> #include <cstdio> @@ -320,5 +319,10 @@ std::vector< PFTFragment > PFT::Assemble(AFPacket af_packet) return pft_fragments; } +void PFT::OverridePSeq(uint16_t pseq) +{ + m_pseq = pseq; +} + } diff --git a/lib/edioutput/PFT.h b/lib/edioutput/PFT.h index 4d138c5..42569a0 100644 --- a/lib/edioutput/PFT.h +++ b/lib/edioutput/PFT.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 + Copyright (C) 2021 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -32,7 +32,6 @@ #pragma once -#include "config.h" #include <vector> #include <list> #include <stdexcept> @@ -65,6 +64,8 @@ class PFT // Cut a RSBlock into several fragments that can be transmitted std::vector< std::vector<uint8_t> > ProtectAndFragment(AFPacket af_packet); + void OverridePSeq(uint16_t pseq); + private: unsigned int m_k = 207; // length of RS data word unsigned int m_m = 3; // number of fragments that can be recovered if lost diff --git a/lib/edioutput/TagItems.cpp b/lib/edioutput/TagItems.cpp index 739adfa..a47d168 100644 --- a/lib/edioutput/TagItems.cpp +++ b/lib/edioutput/TagItems.cpp @@ -26,7 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" #include "TagItems.h" #include <vector> #include <iostream> diff --git a/lib/edioutput/TagItems.h b/lib/edioutput/TagItems.h index f24dc44..029681c 100644 --- a/lib/edioutput/TagItems.h +++ b/lib/edioutput/TagItems.h @@ -28,7 +28,6 @@ #pragma once -#include "config.h" #include <vector> #include <array> #include <chrono> diff --git a/lib/edioutput/TagPacket.cpp b/lib/edioutput/TagPacket.cpp index ec52ad7..d89fce7 100644 --- a/lib/edioutput/TagPacket.cpp +++ b/lib/edioutput/TagPacket.cpp @@ -24,7 +24,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" #include "TagPacket.h" #include "TagItems.h" #include <vector> diff --git a/lib/edioutput/TagPacket.h b/lib/edioutput/TagPacket.h index b53b718..ad23530 100644 --- a/lib/edioutput/TagPacket.h +++ b/lib/edioutput/TagPacket.h @@ -26,7 +26,6 @@ #pragma once -#include "config.h" #include "TagItems.h" #include <vector> #include <string> diff --git a/lib/edioutput/Transport.cpp b/lib/edioutput/Transport.cpp index 274f7ec..5d34814 100644 --- a/lib/edioutput/Transport.cpp +++ b/lib/edioutput/Transport.cpp @@ -126,6 +126,11 @@ void Sender::write(const TagPacket& tagpacket) // Assemble into one AF Packet edi::AFPacket af_packet = edi_afPacketiser.Assemble(tagpacket); + write(af_packet); +} + +void Sender::write(const AFPacket& af_packet) +{ if (m_conf.enable_pft) { // Apply PFT layer to AF Packet (Reed Solomon FEC and Fragmentation) vector<edi::PFTFragment> edi_fragments = edi_pft.Assemble(af_packet); @@ -194,6 +199,16 @@ void Sender::write(const TagPacket& tagpacket) } } +void Sender::override_af_sequence(uint16_t seq) +{ + edi_afPacketiser.OverrideSeq(seq); +} + +void Sender::override_pft_sequence(uint16_t pseq) +{ + edi_pft.OverridePSeq(pseq); +} + void Sender::run() { while (m_running) { diff --git a/lib/edioutput/Transport.h b/lib/edioutput/Transport.h index 3bcc2f4..be93297 100644 --- a/lib/edioutput/Transport.h +++ b/lib/edioutput/Transport.h @@ -27,7 +27,6 @@ #pragma once -#include "config.h" #include "EDIConfig.h" #include "AFPacket.h" #include "PFT.h" @@ -44,7 +43,7 @@ namespace edi { -/** Configuration for EDI output */ +/** STI sender for EDI output */ class Sender { public: @@ -53,8 +52,20 @@ class Sender { Sender operator=(const Sender&) = delete; ~Sender(); + // Assemble the tagpacket into an AF packet, and if needed, + // apply PFT and then schedule for transmission. void write(const TagPacket& tagpacket); + // Schedule an already assembled AF Packet for transmission, + // applying PFT if needed. + void write(const AFPacket& af_packet); + + // Set the sequence numbers to be used for the next call to write() + // seq is for the AF layer + // pseq is for the PFT layer + void override_af_sequence(uint16_t seq); + void override_pft_sequence(uint16_t pseq); + private: void run(); |