summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dabOutput/metadata.cpp14
-rw-r--r--src/zmq2edi/zmq2edi.cpp33
2 files changed, 28 insertions, 19 deletions
diff --git a/src/dabOutput/metadata.cpp b/src/dabOutput/metadata.cpp
index cb355cc..a77ccf5 100644
--- a/src/dabOutput/metadata.cpp
+++ b/src/dabOutput/metadata.cpp
@@ -35,7 +35,7 @@
#endif
template <typename T>
-size_t write_meta(output_metadata_id_e md, uint8_t *buf, T value)
+size_t write_meta(output_metadata_id_e md, uint8_t *buf, const T value)
{
buf[0] = static_cast<uint8_t>(md);
@@ -48,12 +48,16 @@ size_t write_meta(output_metadata_id_e md, uint8_t *buf, T value)
buf[3] = value;
}
else if (len_value == 2) {
- const uint16_t value = htons(value);
- memcpy(buf + 3, &value, sizeof(value));
+ const uint16_t val = htons(value);
+ memcpy(buf + 3, &val, sizeof(val));
}
else if (len_value == 4) {
- const uint32_t value = htons(value);
- memcpy(buf + 3, &value, sizeof(value));
+ const uint32_t val = htonl(value);
+ memcpy(buf + 3, &val, sizeof(val));
+ }
+ else {
+ throw std::runtime_error("Unsupported metadata len " +
+ std::to_string(len_value));
}
return 3 + len_value;
diff --git a/src/zmq2edi/zmq2edi.cpp b/src/zmq2edi/zmq2edi.cpp
index 7a2eed1..5fd02e2 100644
--- a/src/zmq2edi/zmq2edi.cpp
+++ b/src/zmq2edi/zmq2edi.cpp
@@ -160,11 +160,11 @@ static metadata_t get_md_one_frame(uint8_t *buf, size_t size, size_t *consumed_b
while (remaining) {
uint8_t id = buf[0];
- uint16_t len = (((uint16_t)buf[0]) << 8) + buf[1];
+ uint16_t len = (((uint16_t)buf[1]) << 8) + buf[2];
if (id == static_cast<uint8_t>(output_metadata_id_e::separation_marker)) {
if (len != 0) {
- etiLog.level(warn) << "Invalid length for metadata: separation_marker";
+ etiLog.level(warn) << "Invalid length " << len << " for metadata: separation_marker";
}
if (not utc_offset_received or not edi_time_received or not dlfc_received) {
@@ -177,42 +177,42 @@ static metadata_t get_md_one_frame(uint8_t *buf, size_t size, size_t *consumed_b
}
else if (id == static_cast<uint8_t>(output_metadata_id_e::utc_offset)) {
if (len != 2) {
- etiLog.level(warn) << "Invalid length for metadata: utc_offset";
+ etiLog.level(warn) << "Invalid length " << len << " for metadata: utc_offset";
}
if (remaining < 2) {
throw std::runtime_error("Insufficient data for utc_offset");
}
uint16_t utco;
- std::memcpy(&utco, buf + 2, sizeof(utco));
- md.utc_offset = ntohl(utco);
+ std::memcpy(&utco, buf + 3, sizeof(utco));
+ md.utc_offset = ntohs(utco);
utc_offset_received = true;
remaining -= 5;
buf += 5;
}
else if (id == static_cast<uint8_t>(output_metadata_id_e::edi_time)) {
if (len != 4) {
- etiLog.level(warn) << "Invalid length for metadata: edi_time";
+ etiLog.level(warn) << "Invalid length " << len << " for metadata: edi_time";
}
if (remaining < 4) {
throw std::runtime_error("Insufficient data for edi_time");
}
uint32_t edi_time;
- std::memcpy(&edi_time, buf + 2, sizeof(edi_time));
+ std::memcpy(&edi_time, buf + 3, sizeof(edi_time));
md.edi_time = ntohl(edi_time);
edi_time_received = true;
remaining -= 7;
buf += 7;
}
else if (id == static_cast<uint8_t>(output_metadata_id_e::dlfc)) {
- if (len != 3) {
- etiLog.level(warn) << "Invalid length for metadata: dlfc";
+ if (len != 2) {
+ etiLog.level(warn) << "Invalid length " << len << " for metadata: dlfc";
}
if (remaining < 2) {
throw std::runtime_error("Insufficient data for dlfc");
}
uint16_t dlfc;
- std::memcpy(&dlfc, buf + 2, sizeof(dlfc));
- md.dlfc = ntohl(dlfc);
+ std::memcpy(&dlfc, buf + 3, sizeof(dlfc));
+ md.dlfc = ntohs(dlfc);
dlfc_received = true;
remaining -= 5;
buf += 5;
@@ -234,9 +234,14 @@ static void send_eti_frame(uint8_t* p, metadata_t metadata)
edi_tagDETI.stat = p[0];
// LIDATA FCT
- //const int fct = p[4];
edi_tagDETI.dlfc = metadata.dlfc;
+ const int fct = p[4];
+ if (metadata.dlfc % 250 != fct) {
+ etiLog.level(warn) << "Frame FCT=" << fct << " does not correspond to DLFC=" << metadata.dlfc;
+ }
+
+
bool ficf = (p[5] & 0x80) >> 7;
const int nst = p[5] & 0x7F;
@@ -458,6 +463,8 @@ int start(int argc, char **argv)
return 1;
}
+ edi_conf.destinations.push_back(edi_destination);
+
print_edi_conf();
edi_setup();
@@ -520,8 +527,6 @@ int start(int argc, char **argv)
for (auto &f : all_frames) {
size_t consumed_bytes = 0;
- std::cerr << "MD: " << incoming.size() - offset << std::endl;
-
f.second = get_md_one_frame(
static_cast<uint8_t*>(incoming.data()) + offset,
incoming.size() - offset,