aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-16 12:11:27 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-16 12:11:27 +0100
commitac0b24dc76cae40cf513e97160da9305a7d5505c (patch)
treebb23001ecb643aa3348f80ca4ba0e8acf6050000 /src
parent8d4a68a3c5c2910f7868a54847e47e813664621b (diff)
downloaddabmod-ac0b24dc76cae40cf513e97160da9305a7d5505c.tar.gz
dabmod-ac0b24dc76cae40cf513e97160da9305a7d5505c.tar.bz2
dabmod-ac0b24dc76cae40cf513e97160da9305a7d5505c.zip
Make some SDR functions const
Diffstat (limited to 'src')
-rw-r--r--src/output/SDR.cpp1
-rw-r--r--src/output/SDRDevice.h15
-rw-r--r--src/output/Soapy.cpp16
-rw-r--r--src/output/Soapy.h16
-rw-r--r--src/output/UHD.cpp16
-rw-r--r--src/output/UHD.h18
6 files changed, 40 insertions, 42 deletions
diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp
index a2fb42a..e478de5 100644
--- a/src/output/SDR.cpp
+++ b/src/output/SDR.cpp
@@ -201,7 +201,6 @@ void SDR::process_thread_entry()
}
m_running.store(false);
- etiLog.level(warn) << "SDR Device thread terminated";
}
const char* SDR::name()
diff --git a/src/output/SDRDevice.h b/src/output/SDRDevice.h
index 856233b..89a9856 100644
--- a/src/output/SDRDevice.h
+++ b/src/output/SDRDevice.h
@@ -110,16 +110,15 @@ class SDRDevice {
size_t num_frames_modulated; //TODO increment
};
- // TODO make some functions const
virtual void tune(double lo_offset, double frequency) = 0;
- virtual double get_tx_freq(void) = 0;
+ virtual double get_tx_freq(void) const = 0;
virtual void set_txgain(double txgain) = 0;
- virtual double get_txgain(void) = 0;
+ virtual double get_txgain(void) const = 0;
virtual void transmit_frame(const struct FrameData& frame) = 0;
- virtual RunStatistics get_run_statistics(void) = 0;
- virtual double get_real_secs(void) = 0;
+ virtual RunStatistics get_run_statistics(void) const = 0;
+ virtual double get_real_secs(void) const = 0;
virtual void set_rxgain(double rxgain) = 0;
- virtual double get_rxgain(void) = 0;
+ virtual double get_rxgain(void) const = 0;
virtual size_t receive_frame(
complexf *buf,
size_t num_samples,
@@ -128,9 +127,9 @@ class SDRDevice {
// Return true if GPS and reference clock inputs are ok
- virtual bool is_clk_source_ok(void) = 0;
+ virtual bool is_clk_source_ok(void) const = 0;
- virtual const char* device_name(void) = 0;
+ virtual const char* device_name(void) const = 0;
};
} // namespace Output
diff --git a/src/output/Soapy.cpp b/src/output/Soapy.cpp
index e0a6f10..82c926b 100644
--- a/src/output/Soapy.cpp
+++ b/src/output/Soapy.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) 2017
+ Copyright (C) 2018
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -114,7 +114,7 @@ void Soapy::tune(double lo_offset, double frequency)
m_device->setFrequency(SOAPY_SDR_TX, 0, m_conf.frequency, offset_arg);
}
-double Soapy::get_tx_freq(void)
+double Soapy::get_tx_freq(void) const
{
if (not m_device) throw runtime_error("Soapy device not set up");
@@ -129,13 +129,13 @@ void Soapy::set_txgain(double txgain)
m_device->setGain(SOAPY_SDR_TX, 0, m_conf.txgain);
}
-double Soapy::get_txgain(void)
+double Soapy::get_txgain(void) const
{
if (not m_device) throw runtime_error("Soapy device not set up");
return m_device->getGain(SOAPY_SDR_TX, 0);
}
-SDRDevice::RunStatistics Soapy::get_run_statistics(void)
+SDRDevice::RunStatistics Soapy::get_run_statistics(void) const
{
RunStatistics rs;
rs.num_underruns = underflows;
@@ -146,7 +146,7 @@ SDRDevice::RunStatistics Soapy::get_run_statistics(void)
}
-double Soapy::get_real_secs(void)
+double Soapy::get_real_secs(void) const
{
if (m_device) {
long long time_ns = m_device->getHardwareTime();
@@ -163,7 +163,7 @@ void Soapy::set_rxgain(double rxgain)
m_conf.rxgain = m_device->getGain(SOAPY_SDR_RX, 0);
}
-double Soapy::get_rxgain(void)
+double Soapy::get_rxgain(void) const
{
return m_device->getGain(SOAPY_SDR_RX, 0);
}
@@ -197,13 +197,13 @@ size_t Soapy::receive_frame(
}
-bool Soapy::is_clk_source_ok()
+bool Soapy::is_clk_source_ok() const
{
// TODO
return true;
}
-const char* Soapy::device_name(void)
+const char* Soapy::device_name(void) const
{
return "Soapy";
}
diff --git a/src/output/Soapy.h b/src/output/Soapy.h
index c603193..7bf0239 100644
--- a/src/output/Soapy.h
+++ b/src/output/Soapy.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) 2017
+ Copyright (C) 2018
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -61,15 +61,15 @@ class Soapy : public Output::SDRDevice
~Soapy();
virtual void tune(double lo_offset, double frequency) override;
- virtual double get_tx_freq(void) override;
+ virtual double get_tx_freq(void) const override;
virtual void set_txgain(double txgain) override;
- virtual double get_txgain(void) override;
+ virtual double get_txgain(void) const override;
virtual void transmit_frame(const struct FrameData& frame) override;
- virtual RunStatistics get_run_statistics(void) override;
- virtual double get_real_secs(void) override;
+ virtual RunStatistics get_run_statistics(void) const override;
+ virtual double get_real_secs(void) const override;
virtual void set_rxgain(double rxgain) override;
- virtual double get_rxgain(void) override;
+ virtual double get_rxgain(void) const override;
virtual size_t receive_frame(
complexf *buf,
size_t num_samples,
@@ -77,8 +77,8 @@ class Soapy : public Output::SDRDevice
double timeout_secs) override;
// Return true if GPS and reference clock inputs are ok
- virtual bool is_clk_source_ok(void) override;
- virtual const char* device_name(void) override;
+ virtual bool is_clk_source_ok(void) const override;
+ virtual const char* device_name(void) const override;
private:
SDRDeviceConfig& m_conf;
diff --git a/src/output/UHD.cpp b/src/output/UHD.cpp
index 97cf5bb..dda008b 100644
--- a/src/output/UHD.cpp
+++ b/src/output/UHD.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) 2017
+ Copyright (C) 2018
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -230,7 +230,7 @@ void UHD::tune(double lo_offset, double frequency)
m_usrp->set_rx_freq(frequency);
}
-double UHD::get_tx_freq(void)
+double UHD::get_tx_freq(void) const
{
return m_usrp->get_tx_freq();
}
@@ -241,7 +241,7 @@ void UHD::set_txgain(double txgain)
m_conf.txgain = m_usrp->get_tx_gain();
}
-double UHD::get_txgain(void)
+double UHD::get_txgain(void) const
{
return m_usrp->get_tx_gain();
}
@@ -306,7 +306,7 @@ void UHD::transmit_frame(const struct FrameData& frame)
}
-SDRDevice::RunStatistics UHD::get_run_statistics(void)
+SDRDevice::RunStatistics UHD::get_run_statistics(void) const
{
RunStatistics rs;
rs.num_underruns = num_underflows;
@@ -316,7 +316,7 @@ SDRDevice::RunStatistics UHD::get_run_statistics(void)
return rs;
}
-double UHD::get_real_secs(void)
+double UHD::get_real_secs(void) const
{
return m_usrp->get_time_now().get_real_secs();
}
@@ -327,7 +327,7 @@ void UHD::set_rxgain(double rxgain)
m_conf.rxgain = m_usrp->get_rx_gain();
}
-double UHD::get_rxgain()
+double UHD::get_rxgain() const
{
return m_usrp->get_rx_gain();
}
@@ -358,7 +358,7 @@ size_t UHD::receive_frame(
}
// Return true if GPS and reference clock inputs are ok
-bool UHD::is_clk_source_ok(void)
+bool UHD::is_clk_source_ok(void) const
{
bool ok = true;
@@ -390,7 +390,7 @@ bool UHD::is_clk_source_ok(void)
return ok;
}
-const char* UHD::device_name(void)
+const char* UHD::device_name(void) const
{
return "UHD";
}
diff --git a/src/output/UHD.h b/src/output/UHD.h
index 448fb3f..ddcb33b 100644
--- a/src/output/UHD.h
+++ b/src/output/UHD.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) 2017
+ Copyright (C) 2018
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -74,15 +74,15 @@ class UHD : public Output::SDRDevice
~UHD();
virtual void tune(double lo_offset, double frequency) override;
- virtual double get_tx_freq(void) override;
+ virtual double get_tx_freq(void) const override;
virtual void set_txgain(double txgain) override;
- virtual double get_txgain(void) override;
+ virtual double get_txgain(void) const override;
virtual void transmit_frame(const struct FrameData& frame) override;
- virtual RunStatistics get_run_statistics(void) override;
- virtual double get_real_secs(void) override;
+ virtual RunStatistics get_run_statistics(void) const override;
+ virtual double get_real_secs(void) const override;
virtual void set_rxgain(double rxgain) override;
- virtual double get_rxgain(void) override;
+ virtual double get_rxgain(void) const override;
virtual size_t receive_frame(
complexf *buf,
size_t num_samples,
@@ -90,8 +90,8 @@ class UHD : public Output::SDRDevice
double timeout_secs) override;
// Return true if GPS and reference clock inputs are ok
- virtual bool is_clk_source_ok(void) override;
- virtual const char* device_name(void) override;
+ virtual bool is_clk_source_ok(void) const override;
+ virtual const char* device_name(void) const override;
private:
SDRDeviceConfig& m_conf;
@@ -112,7 +112,7 @@ class UHD : public Output::SDRDevice
// Returns true if we want to verify loss of refclk
bool refclk_loss_needs_check(void) const;
- bool suppress_refclk_loss_check = false;
+ mutable bool suppress_refclk_loss_check = false;
// Poll asynchronous metadata from UHD
std::atomic<bool> m_running;