From 3c6c1ea2b45ec06ce493d595fc8cd3a03f056a84 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 31 Jul 2017 11:15:40 +0200 Subject: Insert metadata properly and enable EDI out in zmq2edi --- src/dabOutput/metadata.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/dabOutput/metadata.cpp') 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 -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(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; -- cgit v1.2.3