From 3c74432709c61a7cb914c51748eb73bbbf35af38 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 13 Jun 2014 09:54:38 +0200 Subject: EDI PFT corrections --- src/DabMux.cpp | 25 +++++++++++++++---------- src/dabOutput/edi/AFPacket.cpp | 1 - src/dabOutput/edi/PFT.cpp | 15 ++++++++++----- 3 files changed, 25 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/DabMux.cpp b/src/DabMux.cpp index eb0ec99..02dadc8 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -28,7 +28,8 @@ #endif #define EDI_DEBUG 0 -#define EDI_PFT 0 +#define EDI_DUMP 1 +#define EDI_PFT 1 #include #include @@ -664,6 +665,14 @@ int main(int argc, char *argv[]) etiLog.log(info, "EDI debug set up"); #endif + // The TagPacket will then be placed into an AFPacket + AFPacketiser edi_afPacketiser(EDI_AFPACKET_PROTOCOLTYPE_TAGITEMS); + +#if EDI_PFT + // The AF Packet will be protected with reed-solomon and split in fragments + PFT edi_pft(207, 3); +#endif + /* Each iteration of the main loop creates one ETI frame */ for (currentFrame = 0; running; currentFrame++) { if ((limit > 0) && (currentFrame >= limit)) { @@ -679,17 +688,8 @@ int main(int argc, char *argv[]) // The above Tag Items will be assembled into a TAG Packet TagPacket edi_tagpacket; - // The TagPacket will then be placed into an AFPacket - AFPacketiser edi_afPacketiser(EDI_AFPACKET_PROTOCOLTYPE_TAGITEMS); - - // The AF Packet will be protected with reed-solomon and split in fragments -#if EDI_PFT - PFT edi_pft(207, 3); -#endif - edi_tagDETI.atstf = 0; // TODO add ATST support - date = getDabTime(); // Initialise the ETI frame @@ -2033,6 +2033,11 @@ int main(int argc, char *argv[]) udppacket.addData(&(edi_frag->front()), edi_frag->size()); edi_output.send(udppacket); + +# if EDI_DUMP + std::ostream_iterator debug_iterator(edi_debug_file); + std::copy(edi_frag->begin(), edi_frag->end(), debug_iterator); +# endif } fprintf(stderr, "EDI number of PFT fragments %zu\n", edi_fragments.size()); diff --git a/src/dabOutput/edi/AFPacket.cpp b/src/dabOutput/edi/AFPacket.cpp index cf83078..ae2bdd6 100644 --- a/src/dabOutput/edi/AFPacket.cpp +++ b/src/dabOutput/edi/AFPacket.cpp @@ -72,7 +72,6 @@ AFPacket AFPacketiser::Assemble(TagPacket tag_packet) uint16_t crc = 0xffff; crc = crc16(crc, &(packet.front()), packet.size()); crc ^= 0xffff; - crc = htons(crc); fprintf(stderr, " AFPacket crc %x\n", crc); diff --git a/src/dabOutput/edi/PFT.cpp b/src/dabOutput/edi/PFT.cpp index ffefaeb..ac53f5d 100644 --- a/src/dabOutput/edi/PFT.cpp +++ b/src/dabOutput/edi/PFT.cpp @@ -88,6 +88,9 @@ vector< vector > PFT::ProtectAndFragment(AFPacket af_packet) const size_t fragment_size = m_num_chunks * (m_k + ParityBytes) / max_payload_size; const size_t num_fragments = m_num_chunks * (m_k + ParityBytes) / fragment_size; + fprintf(stderr, " PnF fragment_size %zu, num frag %zu\n", + fragment_size, num_fragments); + vector< vector > fragments(num_fragments); for (size_t i = 0; i < num_fragments; i++) { @@ -119,7 +122,6 @@ std::vector< PFTFragment > PFT::Assemble(AFPacket af_packet) packet.push_back(m_pseq >> 8); packet.push_back(m_pseq & 0xFF); - m_pseq++; packet.push_back(findex >> 16); packet.push_back(findex >> 8); @@ -133,9 +135,8 @@ std::vector< PFTFragment > PFT::Assemble(AFPacket af_packet) unsigned int plen = fragment.size(); plen |= 0x8000; // Set FEC bit - packet.push_back(plen >> 16); - packet.push_back(plen >> 8); - packet.push_back(plen & 0xFF); + packet.push_back(plen >> 8); // RSk + packet.push_back(plen & 0xFF); // RSz packet.push_back(m_k); packet.push_back(zero_pad); @@ -144,7 +145,6 @@ std::vector< PFTFragment > PFT::Assemble(AFPacket af_packet) uint16_t crc = 0xffff; crc = crc16(crc, &(packet.front()), packet.size()); crc ^= 0xffff; - crc = htons(crc); packet.push_back((crc >> 8) & 0xFF); packet.push_back(crc & 0xFF); @@ -153,8 +153,13 @@ std::vector< PFTFragment > PFT::Assemble(AFPacket af_packet) packet.insert(packet.end(), fragment.begin(), fragment.end()); pft_fragments.push_back(packet); + + fprintf(stderr, "* PFT pseq %d, findex %d, fcount %d, plen %d\n", + m_pseq, findex, fcount, plen & ~0x8000); } + m_pseq++; + return pft_fragments; } -- cgit v1.2.3