summaryrefslogtreecommitdiffstats
path: root/src/dabOutput
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2014-06-06 18:03:14 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2014-06-06 18:03:14 +0200
commitc714196bc8e2b3d4ecead22855096753b1b46e40 (patch)
tree7d5bcbdcd9d7780329c838e0e15da67824984827 /src/dabOutput
parentc5d91bc88c264366d1e9062b23557d92e61b2298 (diff)
downloaddabmux-c714196bc8e2b3d4ecead22855096753b1b46e40.tar.gz
dabmux-c714196bc8e2b3d4ecead22855096753b1b46e40.tar.bz2
dabmux-c714196bc8e2b3d4ecead22855096753b1b46e40.zip
Fix several EDI bugs
Diffstat (limited to 'src/dabOutput')
-rw-r--r--src/dabOutput/edi/AFPacket.cpp21
-rw-r--r--src/dabOutput/edi/PFT.cpp4
-rw-r--r--src/dabOutput/edi/TagItems.cpp45
-rw-r--r--src/dabOutput/edi/TagPacket.cpp5
4 files changed, 60 insertions, 15 deletions
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