diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/DabMux.cpp | 12 | ||||
-rw-r--r-- | src/dabOutput/edi/AFPacket.cpp | 21 | ||||
-rw-r--r-- | src/dabOutput/edi/PFT.cpp | 4 | ||||
-rw-r--r-- | src/dabOutput/edi/TagItems.cpp | 45 | ||||
-rw-r--r-- | src/dabOutput/edi/TagPacket.cpp | 5 |
5 files changed, 68 insertions, 19 deletions
diff --git a/src/DabMux.cpp b/src/DabMux.cpp index e2c161a..eb0ec99 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -657,7 +657,9 @@ int main(int argc, char *argv[]) #if EDI_DEBUG etiLog.log(info, "Setup EDI debug"); - //std::ofstream edi_debug_file("./edi.debug"); +# if EDI_DUMP + std::ofstream edi_debug_file("./edi.debug"); +# endif UdpSocket edi_output(13000); etiLog.log(info, "EDI debug set up"); #endif @@ -862,7 +864,7 @@ int main(int argc, char *argv[]) // (depending on mode) index = ((fc->NST) + 2 + 1) * 4; edi_tagDETI.fic_data = &etiFrame[index]; - edi_tagDETI.fic_length = FICL; + edi_tagDETI.fic_length = FICL * 4; // FIC Insertion FIGtype0* fig0; @@ -2048,8 +2050,10 @@ int main(int argc, char *argv[]) edi_output.send(udppacket); # endif - //std::ostream_iterator<uint8_t> debug_iterator(edi_debug_file); - //std::copy(edi_afpacket.begin(), edi_afpacket.end(), debug_iterator); +# if EDI_DUMP + std::ostream_iterator<uint8_t> debug_iterator(edi_debug_file); + std::copy(edi_afpacket.begin(), edi_afpacket.end(), debug_iterator); +# endif #endif #if _DEBUG diff --git a/src/dabOutput/edi/AFPacket.cpp b/src/dabOutput/edi/AFPacket.cpp index ce7ad3f..cf83078 100644 --- a/src/dabOutput/edi/AFPacket.cpp +++ b/src/dabOutput/edi/AFPacket.cpp @@ -30,6 +30,8 @@ #include "TagPacket.h" #include <vector> #include <string> +#include <iostream> +#include <cstdio> #include <stdint.h> #include <arpa/inet.h> @@ -43,16 +45,19 @@ AFPacket AFPacketiser::Assemble(TagPacket tag_packet) { std::vector<uint8_t> payload = tag_packet.Assemble(); + std::cerr << "Assemble AFPacket " << seq << std::endl; + std::string pack_data("AF"); // SYNC std::vector<uint8_t> packet(pack_data.begin(), pack_data.end()); uint32_t taglength = payload.size(); + std::cerr << " AFPacket payload size " << payload.size() << std::endl; // write length into packet - packet[2] = (taglength >> 24) & 0xFF; - packet[3] = (taglength >> 16) & 0xFF; - packet[4] = (taglength >> 8) & 0xFF; - packet[5] = taglength & 0xFF; + packet.push_back((taglength >> 24) & 0xFF); + packet.push_back((taglength >> 16) & 0xFF); + packet.push_back((taglength >> 8) & 0xFF); + packet.push_back(taglength & 0xFF); // fill rest of header packet.push_back(seq >> 8); @@ -65,15 +70,17 @@ AFPacket AFPacketiser::Assemble(TagPacket tag_packet) // calculate CRC over AF Header and payload uint16_t crc = 0xffff; - crc = crc16(crc, &(packet.back()), packet.size()); + crc = crc16(crc, &(packet.front()), packet.size()); crc ^= 0xffff; crc = htons(crc); - packet.push_back((crc >> 24) & 0xFF); - packet.push_back((crc >> 16) & 0xFF); + fprintf(stderr, " AFPacket crc %x\n", crc); + packet.push_back((crc >> 8) & 0xFF); packet.push_back(crc & 0xFF); + std::cerr << " AFPacket length " << packet.size() << std::endl; + return packet; } diff --git a/src/dabOutput/edi/PFT.cpp b/src/dabOutput/edi/PFT.cpp index 0a6b431..ffefaeb 100644 --- a/src/dabOutput/edi/PFT.cpp +++ b/src/dabOutput/edi/PFT.cpp @@ -142,12 +142,10 @@ std::vector< PFTFragment > PFT::Assemble(AFPacket af_packet) // calculate CRC over AF Header and payload uint16_t crc = 0xffff; - crc = crc16(crc, &(packet.back()), packet.size()); + crc = crc16(crc, &(packet.front()), packet.size()); crc ^= 0xffff; crc = htons(crc); - packet.push_back((crc >> 24) & 0xFF); - packet.push_back((crc >> 16) & 0xFF); packet.push_back((crc >> 8) & 0xFF); packet.push_back(crc & 0xFF); diff --git a/src/dabOutput/edi/TagItems.cpp b/src/dabOutput/edi/TagItems.cpp index 39ccb84..d4f73d2 100644 --- a/src/dabOutput/edi/TagItems.cpp +++ b/src/dabOutput/edi/TagItems.cpp @@ -30,22 +30,46 @@ #include "config.h" #include "TagItems.h" #include <vector> +#include <iostream> #include <string> #include <stdint.h> std::vector<uint8_t> TagStarPTR::Assemble() { - std::string pack_data("*ptr\0\0\0\100DETI"); + std::cerr << "TagItem *ptr" << std::endl; + std::string pack_data("*ptr"); std::vector<uint8_t> packet(pack_data.begin(), pack_data.end()); + + packet.push_back(0); + packet.push_back(0); + packet.push_back(0); + packet.push_back(0x40); + + std::string protocol("DETI"); + packet.insert(packet.end(), protocol.begin(), protocol.end()); + + // Major + packet.push_back(0); + packet.push_back(0); + + // Minor + packet.push_back(0); + packet.push_back(0); return packet; } std::vector<uint8_t> TagDETI::Assemble() { - std::string pack_data("deti\0\0\0\0"); + std::string pack_data("deti"); std::vector<uint8_t> packet(pack_data.begin(), pack_data.end()); packet.reserve(256); + // Placeholder for length + packet.push_back(0); + packet.push_back(0); + packet.push_back(0); + packet.push_back(0); + uint16_t detiHeader = dflc | (rfudf << 13) | (ficf << 14) | (atstf << 15); packet.push_back(detiHeader >> 8); packet.push_back(detiHeader & 0xFF); @@ -94,18 +118,27 @@ std::vector<uint8_t> TagDETI::Assemble() dflc = (dflc+1) % 5000; + std::cerr << "TagItem deti, packet.size " << packet.size() << std::endl; + std::cerr << " fic length " << fic_length << std::endl; + std::cerr << " length " << taglength / 8 << std::endl; return packet; } std::vector<uint8_t> TagESTn::Assemble() { - std::string pack_data("estN\0\0\0\0"); + std::string pack_data("est"); std::vector<uint8_t> packet(pack_data.begin(), pack_data.end()); + packet.reserve(mst_length*8 + 16); - packet[3] = id_; // replace the N in estN above + packet.push_back(id_); + + // Placeholder for length + packet.push_back(0); + packet.push_back(0); + packet.push_back(0); + packet.push_back(0); - packet.reserve(mst_length*8 + 16); uint32_t sstc = (scid << 18) | (sad << 8) | (tpl << 2) | rfa; packet.push_back((sstc >> 16) & 0xFF); @@ -126,6 +159,8 @@ std::vector<uint8_t> TagESTn::Assemble() packet[6] = (taglength >> 8) & 0xFF; packet[7] = taglength & 0xFF; + std::cerr << "TagItem ESTn, length " << packet.size() << std::endl; + std::cerr << " mst_length " << mst_length << std::endl; return packet; } #endif diff --git a/src/dabOutput/edi/TagPacket.cpp b/src/dabOutput/edi/TagPacket.cpp index 451da3c..0fc9a17 100644 --- a/src/dabOutput/edi/TagPacket.cpp +++ b/src/dabOutput/edi/TagPacket.cpp @@ -27,6 +27,7 @@ #include "TagPacket.h" #include "TagItems.h" #include <vector> +#include <iostream> #include <string> #include <list> #include <stdint.h> @@ -38,12 +39,16 @@ std::vector<uint8_t> TagPacket::Assemble() std::vector<uint8_t> packet; + std::cerr << "Assemble TAGPacket" << std::endl; + size_t packet_length = 0; for (tag = tag_items.begin(); tag != tag_items.end(); ++tag) { std::vector<uint8_t> tag_data = (*tag)->Assemble(); packet.insert(packet.end(), tag_data.begin(), tag_data.end()); packet_length += tag_data.size(); + + std::cerr << " Add TAGItem of length " << tag_data.size() << std::endl; } // Add padding |