aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/example.ini7
-rw-r--r--src/ConfigParser.cpp2
-rw-r--r--src/ConfigParser.h8
-rw-r--r--src/DabMod.cpp19
-rw-r--r--[-rwxr-xr-x]src/output/BladeRF.cpp0
-rw-r--r--[-rwxr-xr-x]src/output/BladeRF.h0
6 files changed, 31 insertions, 5 deletions
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 <string>
#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
index c16b64d..c16b64d 100755..100644
--- a/src/output/BladeRF.cpp
+++ b/src/output/BladeRF.cpp
diff --git a/src/output/BladeRF.h b/src/output/BladeRF.h
index fa3419e..fa3419e 100755..100644
--- a/src/output/BladeRF.h
+++ b/src/output/BladeRF.h