summaryrefslogtreecommitdiffstats
path: root/src/dabOutput/edi/AFPacket.cpp
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/edi/AFPacket.cpp
parentc5d91bc88c264366d1e9062b23557d92e61b2298 (diff)
downloaddabmux-c714196bc8e2b3d4ecead22855096753b1b46e40.tar.gz
dabmux-c714196bc8e2b3d4ecead22855096753b1b46e40.tar.bz2
dabmux-c714196bc8e2b3d4ecead22855096753b1b46e40.zip
Fix several EDI bugs
Diffstat (limited to 'src/dabOutput/edi/AFPacket.cpp')
-rw-r--r--src/dabOutput/edi/AFPacket.cpp21
1 files changed, 14 insertions, 7 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;
}