aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/DabMultiplexer.cpp5
-rw-r--r--src/fig/FIG.h1
-rw-r--r--src/fig/FIG0.cpp20
-rw-r--r--src/fig/FIG0.h17
-rw-r--r--src/fig/FIGCarousel.cpp5
-rw-r--r--src/fig/FIGCarousel.h2
-rw-r--r--src/utils.cpp30
-rw-r--r--src/utils.h11
8 files changed, 59 insertions, 32 deletions
diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp
index 3ac6623..1707a50 100644
--- a/src/DabMultiplexer.cpp
+++ b/src/DabMultiplexer.cpp
@@ -374,7 +374,6 @@ void DabMultiplexer::prepare_data_inputs()
/* Each call creates one ETI frame */
void DabMultiplexer::mux_frame(std::vector<std::shared_ptr<DabOutput> >& outputs)
{
- time_t date;
unsigned char etiFrame[6144];
unsigned short index = 0;
@@ -393,7 +392,7 @@ 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);
- date = getDabTime();
+ update_dab_time();
// Initialise the ETI frame
memset(etiFrame, 0, 6144);
@@ -571,7 +570,7 @@ void DabMultiplexer::mux_frame(std::vector<std::shared_ptr<DabOutput> >& outputs
edi_tagDETI.fic_length = FICL * 4;
// Insert all FIBs
- fig_carousel.update(currentFrame, date);
+ fig_carousel.update(currentFrame);
const bool fib3_present = ensemble->mode == 3;
index += fig_carousel.write_fibs(&etiFrame[index], currentFrame % 4, fib3_present);
diff --git a/src/fig/FIG.h b/src/fig/FIG.h
index 0316d77..2325252 100644
--- a/src/fig/FIG.h
+++ b/src/fig/FIG.h
@@ -41,7 +41,6 @@ class FIGRuntimeInformation {
ensemble(e),
factumAnalyzer(false) {}
- time_t date;
unsigned long currentFrame;
std::shared_ptr<dabEnsemble> ensemble;
bool factumAnalyzer;
diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp
index 41cf9f2..3bd1307 100644
--- a/src/fig/FIG0.cpp
+++ b/src/fig/FIG0.cpp
@@ -27,6 +27,7 @@
#include "fig/FIG0.h"
#include "dabUtils.h"
+#include "utils.h"
namespace FIC {
@@ -817,16 +818,16 @@ FillStatus FIG0_10::fill(uint8_t *buf, size_t max_size)
auto ensemble = m_rti->ensemble;
size_t remaining = max_size;
- if (remaining < 6) {
+ if (remaining < 8) {
fs.num_bytes_written = 0;
return fs;
}
//Time and country identifier
- auto fig0_10 = (FIGtype0_10 *)buf;
+ auto fig0_10 = (FIGtype0_10_LongForm*)buf;
fig0_10->FIGtypeNumber = 0;
- fig0_10->Length = 5;
+ fig0_10->Length = 7;
fig0_10->CN = 0;
fig0_10->OE = 0;
fig0_10->PD = 0;
@@ -835,7 +836,10 @@ FillStatus FIG0_10::fill(uint8_t *buf, size_t max_size)
remaining -= 2;
tm* timeData;
- timeData = gmtime(&m_rti->date);
+ time_t dab_time_seconds = 0;
+ uint32_t dab_time_millis = 0;
+ get_dab_time(&dab_time_seconds, &dab_time_millis);
+ timeData = gmtime(&dab_time_seconds);
fig0_10->RFU = 0;
fig0_10->setMJD(gregorian2mjd(timeData->tm_year + 1900,
@@ -843,11 +847,13 @@ FillStatus FIG0_10::fill(uint8_t *buf, size_t max_size)
timeData->tm_mday));
fig0_10->LSI = 0;
fig0_10->ConfInd = 1;
- fig0_10->UTC = 0;
+ fig0_10->UTC = 1;
fig0_10->setHours(timeData->tm_hour);
fig0_10->Minutes = timeData->tm_min;
- buf += 4;
- remaining -= 4;
+ fig0_10->Seconds = timeData->tm_sec;
+ fig0_10->setMilliseconds(dab_time_millis);
+ buf += 6;
+ remaining -= 6;
fs.num_bytes_written = max_size - remaining;
fs.complete_fig_transmitted = true;
diff --git a/src/fig/FIG0.h b/src/fig/FIG0.h
index a096d57..59ed1af 100644
--- a/src/fig/FIG0.h
+++ b/src/fig/FIG0.h
@@ -428,9 +428,10 @@ struct FIGtype0_9 {
} PACKED;
-struct FIGtype0_10 {
+struct FIGtype0_10_LongForm {
uint8_t Length:5;
uint8_t FIGtypeNumber:3;
+
uint8_t Extension:5;
uint8_t PD:1;
uint8_t OE:1;
@@ -438,14 +439,23 @@ struct FIGtype0_10 {
uint8_t MJD_high:7;
uint8_t RFU:1;
+
uint8_t MJD_med;
+
uint8_t Hours_high:3;
uint8_t UTC:1;
uint8_t ConfInd:1;
uint8_t LSI:1;
uint8_t MJD_low:2;
+
uint8_t Minutes:6;
uint8_t Hours_low:2;
+
+ uint8_t Milliseconds_high:2;
+ uint8_t Seconds:6;
+
+ uint8_t Milliseconds_low;
+
void setMJD(uint32_t date) {
MJD_high = (date >> 10) & 0x7f;
MJD_med = (date >> 2) & 0xff;
@@ -455,6 +465,11 @@ struct FIGtype0_10 {
Hours_high = (hours >> 2) & 0x07;
Hours_low = hours & 0x03;
}
+
+ void setMilliseconds(uint16_t ms) {
+ Milliseconds_high = (ms >> 8) & 0x03;
+ Milliseconds_low = ms & 0xFF;
+ }
} PACKED;
diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp
index 8c7558a..20b3412 100644
--- a/src/fig/FIGCarousel.cpp
+++ b/src/fig/FIGCarousel.cpp
@@ -3,7 +3,7 @@
2011, 2012 Her Majesty the Queen in Right of Canada (Communications
Research Center Canada)
- Copyright (C) 2015
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
Implementation of the FIG carousel to schedule the FIGs into the
@@ -116,10 +116,9 @@ void FIGCarousel::load_and_allocate(IFIG& fig, FIBAllocation fib)
allocate_fig_to_fib(type, extension, fib);
}
-void FIGCarousel::update(unsigned long currentFrame, time_t dabTime)
+void FIGCarousel::update(unsigned long currentFrame)
{
m_rti.currentFrame = currentFrame;
- m_rti.date = dabTime;
}
void FIGCarousel::allocate_fig_to_fib(int figtype, int extension, FIBAllocation fib)
diff --git a/src/fig/FIGCarousel.h b/src/fig/FIGCarousel.h
index 738a302..583ac39 100644
--- a/src/fig/FIGCarousel.h
+++ b/src/fig/FIGCarousel.h
@@ -60,7 +60,7 @@ class FIGCarousel {
public:
FIGCarousel(std::shared_ptr<dabEnsemble> ensemble);
- void update(unsigned long currentFrame, time_t dabTime);
+ void update(unsigned long currentFrame);
void allocate_fig_to_fib(int figtype, int extension, FIBAllocation fib);
diff --git a/src/utils.cpp b/src/utils.cpp
index ec3e0c7..7221453 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -3,8 +3,8 @@
2011, 2012 Her Majesty the Queen in Right of Canada (Communications
Research Center Canada)
- Copyright (C) 2013, 2014, 2015 Matthias P. Braendli
- http://mpb.li
+ Copyright (C) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
*/
/*
This file is part of ODR-DabMux.
@@ -31,20 +31,26 @@
using namespace std;
-time_t getDabTime()
+static time_t dab_time_seconds = 0;
+static int dab_time_millis = 0;
+
+void update_dab_time()
{
- static time_t oldTime = 0;
- static int offset = 0;
- if (oldTime == 0) {
- oldTime = time(NULL);
+ if (dab_time_seconds == 0) {
+ dab_time_seconds = time(NULL);
} else {
- offset+= 24;
- if (offset >= 1000) {
- offset -= 1000;
- ++oldTime;
+ dab_time_millis+= 24;
+ if (dab_time_millis >= 1000) {
+ dab_time_millis -= 1000;
+ ++dab_time_seconds;
}
}
- return oldTime;
+}
+
+void get_dab_time(time_t *time, uint32_t *millis)
+{
+ *time = dab_time_seconds;
+ *millis = dab_time_millis;
}
diff --git a/src/utils.h b/src/utils.h
index 544c6ca..7ffa325 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -3,11 +3,12 @@
2011, 2012 Her Majesty the Queen in Right of Canada (Communications
Research Center Canada)
- Includes modifications
- 2012, Matthias P. Braendli, matthias.braendli@mpb.li
+ Copyright (C) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
This file contains a set of utility functions that are used to show
- useful information to the user.
+ useful information to the user, and handles time and date for the
+ the signalling.
*/
/*
This file is part of ODR-DabMux.
@@ -32,7 +33,9 @@
#include <memory>
#include "MuxElements.h"
-time_t getDabTime();
+/* Must be called once per ETI frame to update the time */
+void update_dab_time(void);
+void get_dab_time(time_t *time, uint32_t *millis);
/* Shows the introductory header on program start */
void header_message();