diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-08-15 10:58:11 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-08-15 10:58:11 +0200 |
commit | a759d1fae861e7f0836283dae5dce49dae6528fc (patch) | |
tree | 23694a2bcc40cb075988eda7300b1ee42cf07d61 | |
parent | 2980f73251c631960fcbe048eda861afa7a1be89 (diff) | |
download | dabmod-a759d1fae861e7f0836283dae5dce49dae6528fc.tar.gz dabmod-a759d1fae861e7f0836283dae5dce49dae6528fc.tar.bz2 dabmod-a759d1fae861e7f0836283dae5dce49dae6528fc.zip |
Add parameters sdr.synchronous and mainloop.running_since
-rw-r--r-- | src/DabMod.cpp | 15 | ||||
-rw-r--r-- | src/Utils.cpp | 13 | ||||
-rw-r--r-- | src/Utils.h | 3 | ||||
-rw-r--r-- | src/output/SDR.cpp | 6 |
4 files changed, 30 insertions, 7 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 7daa72a..d43ebd5 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -114,6 +114,7 @@ class ModulatorData : public RemoteControllable { ModulatorData() : RemoteControllable("mainloop") { RC_ADD_PARAMETER(num_modulator_restarts, "(Read-only) Number of mod restarts"); RC_ADD_PARAMETER(most_recent_edi_decoded, "(Read-only) UNIX Timestamp of most recently decoded EDI frame"); + RC_ADD_PARAMETER(running_since, "(Read-only) UNIX Timestamp of most recent modulator restart"); } virtual ~ModulatorData() {} @@ -127,6 +128,9 @@ class ModulatorData : public RemoteControllable { if (parameter == "num_modulator_restarts") { ss << num_modulator_restarts; } + if (parameter == "running_since") { + ss << running_since; + } else if (parameter == "most_recent_edi_decoded") { ss << most_recent_edi_decoded; } @@ -142,12 +146,14 @@ class ModulatorData : public RemoteControllable { { json::map_t map; map["num_modulator_restarts"].v = num_modulator_restarts; + map["running_since"].v = running_since; map["most_recent_edi_decoded"].v = most_recent_edi_decoded; return map; } size_t num_modulator_restarts = 0; time_t most_recent_edi_decoded = 0; + time_t running_since = 0; }; enum class run_modulator_state_t { @@ -391,6 +397,8 @@ int launch_modulator(int argc, char* argv[]) bool run_again = true; while (run_again) { + m.running_since = get_clock_realtime_seconds(); + Flowgraph flowgraph(mod_settings.showProcessTime); m.framecount = 0; @@ -544,12 +552,7 @@ static run_modulator_state_t run_modulator(const mod_settings_t& mod_settings, M break; } - struct timespec t; - if (clock_gettime(CLOCK_REALTIME, &t) != 0) { - throw std::runtime_error(std::string("Failed to retrieve CLOCK_REALTIME") + strerror(errno)); - } - - m.most_recent_edi_decoded = t.tv_sec; + m.most_recent_edi_decoded = get_clock_realtime_seconds(); fct = m.ediInput->ediReader.getFct(); fp = m.ediInput->ediReader.getFp(); ts = m.ediInput->ediReader.getTimestamp(); diff --git a/src/Utils.cpp b/src/Utils.cpp index 94f198c..20297ea 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -25,7 +25,8 @@ along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>. */ -#include "sstream" +#include <ctime> +#include <sstream> #include "Utils.h" #include "GainControl.h" #if defined(HAVE_PRCTL) @@ -304,3 +305,13 @@ std::chrono::milliseconds transmission_frame_duration(unsigned int dabmode) } } + +time_t get_clock_realtime_seconds() +{ + struct timespec t; + if (clock_gettime(CLOCK_REALTIME, &t) != 0) { + throw std::runtime_error(std::string("Failed to retrieve CLOCK_REALTIME") + strerror(errno)); + } + + return t.tv_sec; +} diff --git a/src/Utils.h b/src/Utils.h index 82728e9..367dd48 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -36,6 +36,7 @@ #include <cstdio> #include <ctime> #include <cstdlib> +#include <cstdint> #include <unistd.h> #include "ConfigParser.h" @@ -59,3 +60,5 @@ double parseChannel(const std::string& chan); // dabMode is either 1, 2, 3, 4, corresponding to TM I, TM II, TM III and TM IV. // throws a runtime_error if dabMode is not one of these values. std::chrono::milliseconds transmission_frame_duration(unsigned int dabmode); + +time_t get_clock_realtime_seconds(); diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp index d57e4d6..e466287 100644 --- a/src/output/SDR.cpp +++ b/src/output/SDR.cpp @@ -84,6 +84,7 @@ SDR::SDR(SDRDeviceConfig& config, std::shared_ptr<SDRDevice> device) : RC_ADD_PARAMETER(underruns, "Counter of number of underruns"); RC_ADD_PARAMETER(latepackets, "Counter of number of late packets"); RC_ADD_PARAMETER(frames, "Counter of number of frames modulated"); + RC_ADD_PARAMETER(synchronous, "1 if configured for synchronous transmission"); #ifdef HAVE_OUTPUT_UHD if (std::dynamic_pointer_cast<UHD>(device)) { @@ -435,6 +436,9 @@ const string SDR::get_parameter(const string& parameter) const chrono::duration_cast<chrono::milliseconds>(transmission_frame_duration(m_config.dabMode)) .count(); } + else if (parameter == "synchronous") { + ss << m_config.enableSync; + } else { if (m_device) { const auto stat = m_device->get_run_statistics(); @@ -494,6 +498,8 @@ const json::map_t SDR::get_all_values() const (size_t)chrono::duration_cast<chrono::milliseconds>(transmission_frame_duration(m_config.dabMode)) .count(); + stat["synchronous"].v = m_config.enableSync; + return stat; } |