aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2023-03-31 14:31:32 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2023-03-31 14:31:32 +0200
commitae70341365e27d766c8530924209fc4826036aea (patch)
treeb18247e0b96b45b6f74b66d0ab5b5d69bb63f143
parentfe19871f8ee362f65d194b864eb989618b994e58 (diff)
downloaddabmod-ae70341365e27d766c8530924209fc4826036aea.tar.gz
dabmod-ae70341365e27d766c8530924209fc4826036aea.tar.bz2
dabmod-ae70341365e27d766c8530924209fc4826036aea.zip
Add JSON output to RC
-rw-r--r--lib/RemoteControl.cpp94
-rw-r--r--lib/RemoteControl.h14
-rw-r--r--src/DabModulator.cpp7
-rw-r--r--src/DabModulator.h10
-rw-r--r--src/FIRFilter.cpp9
-rw-r--r--src/FIRFilter.h10
-rw-r--r--src/GainControl.cpp20
-rw-r--r--src/GainControl.h12
-rw-r--r--src/GuardIntervalInserter.cpp9
-rw-r--r--src/GuardIntervalInserter.h14
-rw-r--r--src/MemlessPoly.cpp10
-rw-r--r--src/MemlessPoly.h14
-rw-r--r--src/OfdmGenerator.cpp9
-rw-r--r--src/OfdmGenerator.h13
-rw-r--r--src/TII.cpp11
-rw-r--r--src/TII.h14
-rw-r--r--src/TimestampDecoder.cpp21
-rw-r--r--src/TimestampDecoder.h12
-rw-r--r--src/output/SDR.cpp26
-rw-r--r--src/output/SDR.h2
-rw-r--r--src/output/SDRDevice.h3
-rw-r--r--src/output/UHD.h8
22 files changed, 255 insertions, 87 deletions
diff --git a/lib/RemoteControl.cpp b/lib/RemoteControl.cpp
index 30dcb60..6e9af20 100644
--- a/lib/RemoteControl.cpp
+++ b/lib/RemoteControl.cpp
@@ -25,6 +25,8 @@
#include <list>
#include <string>
#include <iostream>
+#include <sstream>
+#include <iomanip>
#include <string>
#include <algorithm>
@@ -102,6 +104,74 @@ std::list< std::vector<std::string> > RemoteControllers::get_param_list_values(c
return allparams;
}
+
+static std::string escape_json(const std::string &s) {
+ std::ostringstream o;
+ for (auto c = s.cbegin(); c != s.cend(); c++) {
+ switch (*c) {
+ case '"': o << "\\\""; break;
+ case '\\': o << "\\\\"; break;
+ case '\b': o << "\\b"; break;
+ case '\f': o << "\\f"; break;
+ case '\n': o << "\\n"; break;
+ case '\r': o << "\\r"; break;
+ case '\t': o << "\\t"; break;
+ default:
+ if ('\x00' <= *c && *c <= '\x1f') {
+ o << "\\u"
+ << std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(*c);
+ } else {
+ o << *c;
+ }
+ }
+ }
+ return o.str();
+}
+
+std::string RemoteControllers::get_params_json(const std::string& name) {
+ RemoteControllable* controllable = get_controllable_(name);
+ const auto& values = controllable->get_all_values();
+
+ std::ostringstream ss;
+ ss << "{ ";
+ size_t ix = 0;
+ for (const auto& element : values) {
+ if (ix > 0) {
+ ss << ",";
+ }
+
+ ss << "\"" << escape_json(element.first) << "\": ";
+
+ const auto& value = element.second;
+ if (std::holds_alternative<string>(value)) {
+ ss << "\"" << escape_json(std::get<string>(value)) << "\"";
+ }
+ else if (std::holds_alternative<double>(value)) {
+ ss << std::defaultfloat << std::get<double>(value);
+ }
+ else if (std::holds_alternative<ssize_t>(value)) {
+ ss << std::get<ssize_t>(value);
+ }
+ else if (std::holds_alternative<size_t>(value)) {
+ ss << std::get<size_t>(value);
+ }
+ else if (std::holds_alternative<bool>(value)) {
+ ss << (std::get<bool>(value) ? "true" : "false");
+ }
+ else if (std::holds_alternative<std::nullopt_t>(value)) {
+ ss << "null";
+ }
+ else {
+ throw std::logic_error("variant alternative not handled");
+ }
+
+ ix++;
+ }
+ ss << " }";
+
+ return ss.str();
+}
+
std::string RemoteControllers::get_param(const std::string& name, const std::string& param) {
RemoteControllable* controllable = get_controllable_(name);
return controllable->get_parameter(param);
@@ -427,10 +497,15 @@ void RemoteControllerZmq::recv_all(zmq::socket_t& pSocket, std::vector<std::stri
bool more = true;
do {
zmq::message_t msg;
- pSocket.recv(msg);
- std::string incoming((char*)msg.data(), msg.size());
- message.push_back(incoming);
- more = msg.more();
+ const auto zresult = pSocket.recv(msg);
+ if (zresult) {
+ std::string incoming((char*)msg.data(), msg.size());
+ message.push_back(incoming);
+ more = msg.more();
+ }
+ else {
+ more = false;
+ }
} while (more);
}
@@ -532,6 +607,15 @@ void RemoteControllerZmq::process()
send_fail_reply(repSocket, err.what());
}
}
+ else if (msg.size() == 2 && command == "showjson") {
+ std::string module((char*) msg[1].data(), msg[1].size());
+ std::string json = rcs.get_params_json(module);
+
+ zmq::message_t zmsg(json.size());
+ memcpy(zmsg.data(), json.data(), json.size());
+
+ repSocket.send(zmsg, zmq::send_flags::none);
+ }
else if (msg.size() == 3 && command == "get") {
std::string module((char*) msg[1].data(), msg[1].size());
std::string parameter((char*) msg[2].data(), msg[2].size());
@@ -561,7 +645,7 @@ void RemoteControllerZmq::process()
}
else {
send_fail_reply(repSocket,
- "Unsupported command. commands: list, show, get, set");
+ "Unsupported command. commands: list, show, get, set, showjson");
}
}
}
diff --git a/lib/RemoteControl.h b/lib/RemoteControl.h
index 2358b3a..4bc3b68 100644
--- a/lib/RemoteControl.h
+++ b/lib/RemoteControl.h
@@ -3,7 +3,7 @@
Her Majesty the Queen in Right of Canada (Communications Research
Center Canada)
- Copyright (C) 2019
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -36,6 +36,8 @@
#endif
#include <list>
+#include <unordered_map>
+#include <variant>
#include <map>
#include <memory>
#include <string>
@@ -113,13 +115,16 @@ class RemoteControllable {
}
/* Base function to set parameters. */
- virtual void set_parameter(
- const std::string& parameter,
- const std::string& value) = 0;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) = 0;
/* Getting a parameter always returns a string. */
virtual const std::string get_parameter(const std::string& parameter) const = 0;
+ using value_t = std::variant<std::string, double, size_t, ssize_t, bool, std::nullopt_t>;
+ using map_t = std::unordered_map<std::string, value_t>;
+
+ virtual const map_t get_all_values() const = 0;
+
protected:
std::string m_rc_name;
std::list< std::vector<std::string> > m_parameters;
@@ -135,6 +140,7 @@ class RemoteControllers {
void check_faults();
std::list< std::vector<std::string> > get_param_list_values(const std::string& name);
std::string get_param(const std::string& name, const std::string& param);
+ std::string get_params_json(const std::string& name);
void set_param(
const std::string& name,
diff --git a/src/DabModulator.cpp b/src/DabModulator.cpp
index 3d8bd46..67764ba 100644
--- a/src/DabModulator.cpp
+++ b/src/DabModulator.cpp
@@ -410,3 +410,10 @@ const string DabModulator::get_parameter(const string& parameter) const
}
return ss.str();
}
+
+const RemoteControllable::map_t DabModulator::get_all_values() const
+{
+ map_t map;
+ map["rate"] = m_settings.outputRate;
+ return map;
+}
diff --git a/src/DabModulator.h b/src/DabModulator.h
index 00d71f5..0d46e9f 100644
--- a/src/DabModulator.h
+++ b/src/DabModulator.h
@@ -3,7 +3,7 @@
Her Majesty the Queen in Right of Canada (Communications Research
Center Canada)
- Copyright (C) 2019
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -60,11 +60,9 @@ public:
EtiSource* getEtiSource() { return &myEtiSource; }
/******* REMOTE CONTROL ********/
- virtual void set_parameter(const std::string& parameter,
- const std::string& value) override;
-
- virtual const std::string get_parameter(
- const std::string& parameter) const override;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
void setMode(unsigned mode);
diff --git a/src/FIRFilter.cpp b/src/FIRFilter.cpp
index 89cf0da..523d405 100644
--- a/src/FIRFilter.cpp
+++ b/src/FIRFilter.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -347,3 +347,10 @@ const string FIRFilter::get_parameter(const string& parameter) const
return ss.str();
}
+const RemoteControllable::map_t FIRFilter::get_all_values() const
+{
+ map_t map;
+ map["ntaps"] = m_taps.size();
+ map["tapsfile"] = m_taps_file;
+ return map;
+}
diff --git a/src/FIRFilter.h b/src/FIRFilter.h
index 8d2e707..2a469aa 100644
--- a/src/FIRFilter.h
+++ b/src/FIRFilter.h
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -59,11 +59,9 @@ public:
const char* name() override { return "FIRFilter"; }
/******* REMOTE CONTROL ********/
- virtual void set_parameter(const std::string& parameter,
- const std::string& value) override;
-
- virtual const std::string get_parameter(
- const std::string& parameter) const override;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
virtual int internal_process(Buffer* const dataIn, Buffer* dataOut) override;
diff --git a/src/GainControl.cpp b/src/GainControl.cpp
index b781640..c111de3 100644
--- a/src/GainControl.cpp
+++ b/src/GainControl.cpp
@@ -3,7 +3,7 @@
Her Majesty the Queen in Right of Canada (Communications Research
Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -574,3 +574,21 @@ const string GainControl::get_parameter(const string& parameter) const
return ss.str();
}
+const RemoteControllable::map_t GainControl::get_all_values() const
+{
+ map_t map;
+ map["digital"] = m_digGain;
+ switch (m_gainmode) {
+ case GainMode::GAIN_FIX:
+ map["mode"] = "fix";
+ break;
+ case GainMode::GAIN_MAX:
+ map["mode"] = "max";
+ break;
+ case GainMode::GAIN_VAR:
+ map["mode"] = "var";
+ break;
+ }
+ map["var"] = m_var_variance_rc;
+ return map;
+}
diff --git a/src/GainControl.h b/src/GainControl.h
index 4c9a2bc..f0fd6b6 100644
--- a/src/GainControl.h
+++ b/src/GainControl.h
@@ -3,7 +3,7 @@
Her Majesty the Queen in Right of Canada (Communications Research
Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -63,13 +63,9 @@ class GainControl : public PipelinedModCodec, public RemoteControllable
const char* name() override { return "GainControl"; }
/* Functions for the remote control */
- /* Base function to set parameters. */
- virtual void set_parameter(const std::string& parameter,
- const std::string& value) override;
-
- /* Getting a parameter always returns a string. */
- virtual const std::string get_parameter(
- const std::string& parameter) const override;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
virtual int internal_process(
diff --git a/src/GuardIntervalInserter.cpp b/src/GuardIntervalInserter.cpp
index 0cd5bd5..d5c71fb 100644
--- a/src/GuardIntervalInserter.cpp
+++ b/src/GuardIntervalInserter.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2206, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -302,3 +302,10 @@ const std::string GuardIntervalInserter::get_parameter(const std::string& parame
}
return ss.str();
}
+
+const RemoteControllable::map_t GuardIntervalInserter::get_all_values() const
+{
+ map_t map;
+ map["windowlen"] = d_windowOverlap;
+ return map;
+}
diff --git a/src/GuardIntervalInserter.h b/src/GuardIntervalInserter.h
index 02ba72c..f88bdac 100644
--- a/src/GuardIntervalInserter.h
+++ b/src/GuardIntervalInserter.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -52,15 +52,13 @@ class GuardIntervalInserter : public ModCodec, public RemoteControllable
size_t symSize,
size_t& windowOverlap);
- int process(Buffer* const dataIn, Buffer* dataOut);
- const char* name() { return "GuardIntervalInserter"; }
+ int process(Buffer* const dataIn, Buffer* dataOut) override;
+ const char* name() override { return "GuardIntervalInserter"; }
/******* REMOTE CONTROL ********/
- virtual void set_parameter(const std::string& parameter,
- const std::string& value);
-
- virtual const std::string get_parameter(
- const std::string& parameter) const;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
void update_window(size_t new_window_overlap);
diff --git a/src/MemlessPoly.cpp b/src/MemlessPoly.cpp
index 905ca67..4801ba0 100644
--- a/src/MemlessPoly.cpp
+++ b/src/MemlessPoly.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
Andreas Steger, andreas.steger@digris.ch
@@ -467,3 +467,11 @@ const string MemlessPoly::get_parameter(const string& parameter) const
return ss.str();
}
+const RemoteControllable::map_t MemlessPoly::get_all_values() const
+{
+ map_t map;
+ map["ncoefs"] = m_coefs_am.size();
+ map["coefs"] = serialise_coefficients();
+ map["coeffile"] = m_coefs_file;
+ return map;
+}
diff --git a/src/MemlessPoly.h b/src/MemlessPoly.h
index 4642596..09adc13 100644
--- a/src/MemlessPoly.h
+++ b/src/MemlessPoly.h
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -63,17 +63,15 @@ public:
MemlessPoly& operator=(const MemlessPoly& other) = delete;
virtual ~MemlessPoly();
- virtual const char* name() { return "MemlessPoly"; }
+ virtual const char* name() override { return "MemlessPoly"; }
/******* REMOTE CONTROL ********/
- virtual void set_parameter(const std::string& parameter,
- const std::string& value);
-
- virtual const std::string get_parameter(
- const std::string& parameter) const;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
private:
- int internal_process(Buffer* const dataIn, Buffer* dataOut);
+ int internal_process(Buffer* const dataIn, Buffer* dataOut) override;
void load_coefficients(std::istream& coefData);
std::string serialise_coefficients() const;
diff --git a/src/OfdmGenerator.cpp b/src/OfdmGenerator.cpp
index 2e68df0..d161861 100644
--- a/src/OfdmGenerator.cpp
+++ b/src/OfdmGenerator.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -457,3 +457,10 @@ const std::string OfdmGenerator::get_parameter(const std::string& parameter) con
}
return ss.str();
}
+
+const RemoteControllable::map_t OfdmGenerator::get_all_values() const
+{
+ map_t map;
+ // TODO needs rework of the values
+ return map;
+}
diff --git a/src/OfdmGenerator.h b/src/OfdmGenerator.h
index 30fdff4..90e562a 100644
--- a/src/OfdmGenerator.h
+++ b/src/OfdmGenerator.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -59,14 +59,9 @@ class OfdmGenerator : public ModCodec, public RemoteControllable
const char* name() override { return "OfdmGenerator"; }
/* Functions for the remote control */
- /* Base function to set parameters. */
- virtual void set_parameter(
- const std::string& parameter,
- const std::string& value) override;
-
- /* Getting a parameter always returns a string. */
- virtual const std::string get_parameter(
- const std::string& parameter) const override;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
struct cfr_iter_stat_t {
diff --git a/src/TII.cpp b/src/TII.cpp
index 904f3ff..b329cdb 100644
--- a/src/TII.cpp
+++ b/src/TII.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -385,3 +385,12 @@ const std::string TII::get_parameter(const std::string& parameter) const
return ss.str();
}
+const RemoteControllable::map_t TII::get_all_values() const
+{
+ map_t map;
+ map["enable"] = m_conf.enable;
+ map["pattern"] = m_conf.pattern;
+ map["comb"] = m_conf.comb;
+ map["old_variant"] = m_conf.old_variant;
+ return map;
+}
diff --git a/src/TII.h b/src/TII.h
index d8c785d..b0ba646 100644
--- a/src/TII.h
+++ b/src/TII.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -83,15 +83,13 @@ class TII : public ModCodec, public RemoteControllable
public:
TII(unsigned int dabmode, tii_config_t& tii_config);
- int process(Buffer* dataIn, Buffer* dataOut);
- const char* name();
+ int process(Buffer* dataIn, Buffer* dataOut) override;
+ const char* name() override;
/******* REMOTE CONTROL ********/
- virtual void set_parameter(const std::string& parameter,
- const std::string& value);
-
- virtual const std::string get_parameter(
- const std::string& parameter) const;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
// Fill m_Acp with the correct carriers for the pattern/comb
diff --git a/src/TimestampDecoder.cpp b/src/TimestampDecoder.cpp
index 6e97af6..149cd50 100644
--- a/src/TimestampDecoder.cpp
+++ b/src/TimestampDecoder.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -301,3 +301,22 @@ const std::string TimestampDecoder::get_parameter(
return ss.str();
}
+const RemoteControllable::map_t TimestampDecoder::get_all_values() const
+{
+ map_t map;
+ map["offset"] = timestamp_offset;
+ if (full_timestamp_received) {
+ map["timestamp"] = time_secs + ((double)time_pps / 16384000.0);
+ }
+ else {
+ map["timestamp"] = std::nullopt;
+ }
+
+ if (full_timestamp_received) {
+ map["timestamp0"] = time_secs_of_frame0 + ((double)time_pps_of_frame0 / 16384000.0);
+ }
+ else {
+ map["timestamp0"] = std::nullopt;
+ }
+ return map;
+}
diff --git a/src/TimestampDecoder.h b/src/TimestampDecoder.h
index 597b777..dc5aa78 100644
--- a/src/TimestampDecoder.h
+++ b/src/TimestampDecoder.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2022
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -118,16 +118,12 @@ class TimestampDecoder : public RemoteControllable
/*********** REMOTE CONTROL ***************/
/* Base function to set parameters. */
- virtual void set_parameter(const std::string& parameter,
- const std::string& value);
-
- /* Getting a parameter always returns a string. */
- virtual const std::string get_parameter(
- const std::string& parameter) const;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
const char* name() { return "TS"; }
-
protected:
/* Push a new MNSC field into the decoder */
void pushMNSCData(uint8_t framephase, uint16_t mnsc);
diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp
index cc080dc..860d8ed 100644
--- a/src/output/SDR.cpp
+++ b/src/output/SDR.cpp
@@ -491,6 +491,9 @@ const string SDR::get_parameter(const string& parameter) const
else if (std::holds_alternative<bool>(value)) {
ss << (std::get<bool>(value) ? 1 : 0);
}
+ else if (std::holds_alternative<std::nullopt_t>(value)) {
+ ss << "";
+ }
else {
throw std::logic_error("variant alternative not handled");
}
@@ -507,4 +510,27 @@ const string SDR::get_parameter(const string& parameter) const
return ss.str();
}
+const RemoteControllable::map_t SDR::get_all_values() const
+{
+ map_t stat = m_device->get_run_statistics();
+
+ stat["txgain"] = m_config.txgain;
+ stat["rxgain"] = m_config.rxgain;
+ stat["freq"] = m_config.frequency;
+ stat["muting"] = m_config.muting;
+ stat["temp"] = std::nullopt;
+
+ if (m_device) {
+ const std::optional<double> temp = m_device->get_temperature();
+ if (temp) {
+ stat["temp"] = *temp;
+ }
+ }
+ stat["queued_frames_ms"] = m_queue.size() *
+ (size_t)chrono::duration_cast<chrono::milliseconds>(transmission_frame_duration(m_config.dabMode))
+ .count();
+
+ return stat;
+}
+
} // namespace Output
diff --git a/src/output/SDR.h b/src/output/SDR.h
index eb0ed9d..9f08348 100644
--- a/src/output/SDR.h
+++ b/src/output/SDR.h
@@ -67,6 +67,8 @@ class SDR : public ModOutput, public ModMetadata, public RemoteControllable {
virtual const std::string get_parameter(
const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
+
private:
void process_thread_entry(void);
void handle_frame(struct FrameData&& frame);
diff --git a/src/output/SDRDevice.h b/src/output/SDRDevice.h
index a4f551c..628372a 100644
--- a/src/output/SDRDevice.h
+++ b/src/output/SDRDevice.h
@@ -112,8 +112,7 @@ struct FrameData {
// All SDR Devices must implement the SDRDevice interface
class SDRDevice {
public:
- using run_statistic_t = std::variant<std::string, double, size_t, ssize_t, bool>;
- using run_statistics_t = std::unordered_map<std::string, run_statistic_t>;
+ using run_statistics_t = RemoteControllable::map_t;
virtual void tune(double lo_offset, double frequency) = 0;
virtual double get_tx_freq(void) const = 0;
diff --git a/src/output/UHD.h b/src/output/UHD.h
index 5823c0e..97a821e 100644
--- a/src/output/UHD.h
+++ b/src/output/UHD.h
@@ -55,14 +55,6 @@ DESCRIPTION:
#include <stdio.h>
#include <sys/types.h>
-// If the timestamp is further in the future than
-// 100 seconds, abort
-#define TIMESTAMP_ABORT_FUTURE 100
-
-// Add a delay to increase buffers when
-// frames are too far in the future
-#define TIMESTAMP_MARGIN_FUTURE 0.5
-
namespace Output {
class UHD : public Output::SDRDevice