aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-10 16:13:31 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-10 20:32:49 +0100
commit641a1ffdf4e6d0bddfec27b474356254214d0cb7 (patch)
treeb4baee3901dcc84d8251124c013c1a9a154bb6d3 /src
parent70c5ba0867945bb097f466262ce03470b690518f (diff)
downloaddabmux-641a1ffdf4e6d0bddfec27b474356254214d0cb7.tar.gz
dabmux-641a1ffdf4e6d0bddfec27b474356254214d0cb7.tar.bz2
dabmux-641a1ffdf4e6d0bddfec27b474356254214d0cb7.zip
Set edi TIST, still in an incorrect way
Diffstat (limited to 'src')
-rw-r--r--src/ClockTAI.cpp8
-rw-r--r--src/DabMultiplexer.cpp44
-rw-r--r--src/DabMultiplexer.h1
-rw-r--r--src/dabOutput/edi/TagItems.h2
4 files changed, 34 insertions, 21 deletions
diff --git a/src/ClockTAI.cpp b/src/ClockTAI.cpp
index 1b2d4ef..992390b 100644
--- a/src/ClockTAI.cpp
+++ b/src/ClockTAI.cpp
@@ -30,6 +30,7 @@
#endif
#include "ClockTAI.h"
+#include "Log.h"
#include <stdio.h>
#include <errno.h>
@@ -71,11 +72,14 @@ int ClockTAI::get_offset()
else if (download_tai_utc_bulletin(tai_data_url2) == 0) {
m_offset = parse_tai_offset();
}
+ else {
+ throw std::runtime_error("Could not fetch TAI-UTC offset");
+ }
+
+ etiLog.level(info) << "Updated TAI-UTC offset to " << m_offset << "s.";
}
return m_offset;
-
- throw std::runtime_error("Could not fetch TAI-UTC offset");
}
#if SUPPORT_SETTING_CLOCK_TAI
diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp
index d9e1a10..28f799d 100644
--- a/src/DabMultiplexer.cpp
+++ b/src/DabMultiplexer.cpp
@@ -239,6 +239,10 @@ void DabMultiplexer::prepare()
*/
gettimeofday(&mnsc_time, NULL);
+ if (clock_gettime(CLOCK_REALTIME, &edi_time)) {
+ throw std::runtime_error("Setting eti_time with clock_gettime failed");
+ }
+
#if HAVE_OUTPUT_EDI
// Try to load offset once
@@ -471,22 +475,6 @@ void DabMultiplexer::mux_frame(std::vector<std::shared_ptr<DabOutput> >& outputs
// The above Tag Items will be assembled into a TAG Packet
TagPacket edi_tagpacket(edi_conf.tagpacket_alignment);
- edi_tagDETI.atstf = 1;
- edi_tagDETI.utco = 0;
- edi_tagDETI.seconds = 0;
- try {
- bool tist_enabled = m_pt.get("general.tist", false);
-
- if (tist_enabled and edi_conf.enabled) {
- edi_tagDETI.set_utco(m_clock_tai.get_offset());
- }
-
- edi_tagDETI.set_seconds(mnsc_time);
- }
- catch (std::runtime_error& e) {
- etiLog.level(error) << "Could not get UTC-TAI offset for EDI timestamp";
- }
-
date = getDabTime();
// Initialise the ETI frame
@@ -1784,12 +1772,29 @@ void DabMultiplexer::mux_frame(std::vector<std::shared_ptr<DabOutput> >& outputs
bool enableTist = m_pt.get("general.tist", false);
if (enableTist) {
tist->TIST = htonl(timestamp) | 0xff;
+ edi_tagDETI.tsta = timestamp & 0xffffff;
}
else {
tist->TIST = htonl(0xffffff) | 0xff;
+ edi_tagDETI.tsta = 0xffffff;
+ }
+
+ edi_tagDETI.atstf = 1;
+ edi_tagDETI.utco = 0;
+ edi_tagDETI.seconds = 0;
+ try {
+ bool tist_enabled = m_pt.get("general.tist", false);
+
+ if (tist_enabled and edi_conf.enabled) {
+ edi_tagDETI.set_utco(m_clock_tai.get_offset());
+ edi_tagDETI.set_seconds(edi_time);
+ }
+
+ }
+ catch (std::runtime_error& e) {
+ etiLog.level(error) << "Could not get UTC-TAI offset for EDI timestamp";
}
- edi_tagDETI.tsta = tist->TIST;
/* Coding of the TIST, according to ETS 300 799 Annex C
@@ -1808,8 +1813,11 @@ void DabMultiplexer::mux_frame(std::vector<std::shared_ptr<DabOutput> >& outputs
{
timestamp -= 0xfa0000; // Substract 16384000, corresponding to one second
- // Also update MNSC time for next frame
+ // Also update MNSC time for next time FP==0
MNSC_increment_time = true;
+
+ // Immediately update edi time
+ edi_time.tv_sec++;
}
diff --git a/src/DabMultiplexer.h b/src/DabMultiplexer.h
index 7b3834e..e8b2a00 100644
--- a/src/DabMultiplexer.h
+++ b/src/DabMultiplexer.h
@@ -102,6 +102,7 @@ class DabMultiplexer : public RemoteControllable {
unsigned timestamp;
bool MNSC_increment_time;
struct timeval mnsc_time;
+ struct timespec edi_time;
edi_configuration_t edi_conf;
diff --git a/src/dabOutput/edi/TagItems.h b/src/dabOutput/edi/TagItems.h
index dee857a..50d5e99 100644
--- a/src/dabOutput/edi/TagItems.h
+++ b/src/dabOutput/edi/TagItems.h
@@ -98,7 +98,7 @@ class TagDETI : public TagItem
*/
uint32_t seconds;
- void set_seconds(struct timeval tv)
+ void set_seconds(struct timespec tv)
{
time_t posix_timestamp_1_jan_2000 = 946684800;
seconds = tv.tv_sec - posix_timestamp_1_jan_2000;