From 60d791fee684aaa847b4987542b753b772b989ba Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 1 May 2024 08:02:57 +0200 Subject: Add startupcheck --- doc/example.ini | 7 +++++++ src/ConfigParser.cpp | 2 ++ src/ConfigParser.h | 8 +++----- src/DabMod.cpp | 19 +++++++++++++++++++ src/output/BladeRF.cpp | 0 src/output/BladeRF.h | 0 6 files changed, 31 insertions(+), 5 deletions(-) mode change 100755 => 100644 src/output/BladeRF.cpp mode change 100755 => 100644 src/output/BladeRF.h diff --git a/doc/example.ini b/doc/example.ini index 6e71d4a..eda50a5 100644 --- a/doc/example.ini +++ b/doc/example.ini @@ -1,5 +1,12 @@ ; Sample configuration file for ODR-DabMod +[general] +; Before starting up, run this command, and abort if it doesn't return 0. +; This is useful to ensure that NTP has properly synchronised time. +startupcheck= +;startupcheck=chronyc waitsync 10 0.01 +;startupcheck=ntp-wait -fv + [remotecontrol] ; The RC feature is described in detail in doc/README-RC.md diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index 1219ae7..4a1e362 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -80,6 +80,8 @@ static void parse_configfile( throw std::runtime_error("Cannot read configuration file"); } + mod_settings.startupCheck = pt.Get("general.startupcheck", ""); + // remote controller interfaces: if (pt.GetInteger("remotecontrol.telnet", 0) == 1) { try { diff --git a/src/ConfigParser.h b/src/ConfigParser.h index d35432b..ae76dee 100644 --- a/src/ConfigParser.h +++ b/src/ConfigParser.h @@ -34,13 +34,11 @@ #include #include "GainControl.h" #include "TII.h" -#include "output/SDR.h" -#include "output/UHD.h" -#include "output/Soapy.h" -#include "output/Lime.h" -#include "output/BladeRF.h" +#include "output/SDRDevice.h" struct mod_settings_t { + std::string startupCheck; + std::string outputName; bool useZeroMQOutput = false; std::string zmqOutputSocketType = ""; diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 648b7ad..f238ca4 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -394,6 +394,25 @@ int launch_modulator(int argc, char* argv[]) throw std::runtime_error("Configuration error: Output not specified"); } + if (not mod_settings.startupCheck.empty()) { + etiLog.level(info) << "Running startup check '" << mod_settings.startupCheck << "'"; + int wstatus = system(mod_settings.startupCheck.c_str()); + + if (WIFEXITED(wstatus)) { + if (WEXITSTATUS(wstatus) == 0) { + etiLog.level(info) << "Startup check ok"; + } + else { + etiLog.level(error) << "Startup check failed, returned " << WEXITSTATUS(wstatus); + return 1; + } + } + else { + etiLog.level(error) << "Startup check failed, child didn't terminate normally"; + return 1; + } + } + printModSettings(mod_settings); ModulatorData m; diff --git a/src/output/BladeRF.cpp b/src/output/BladeRF.cpp old mode 100755 new mode 100644 diff --git a/src/output/BladeRF.h b/src/output/BladeRF.h old mode 100755 new mode 100644 -- cgit v1.2.3