diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-11-18 17:39:22 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-11-18 17:39:22 +0100 |
commit | 7b0bd2675b7514e2292684bfe2bd647f87330727 (patch) | |
tree | 73f85d7b8f9dcabbb1c71f7956fd9f8cc2096a5d /src/output | |
parent | e84f532b9e97dc2ad53ad96cc9543a178d6f20fd (diff) | |
download | dabmod-7b0bd2675b7514e2292684bfe2bd647f87330727.tar.gz dabmod-7b0bd2675b7514e2292684bfe2bd647f87330727.tar.bz2 dabmod-7b0bd2675b7514e2292684bfe2bd647f87330727.zip |
Add SDR temperature to RC
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/SDR.cpp | 13 | ||||
-rw-r--r-- | src/output/SDRDevice.h | 2 | ||||
-rw-r--r-- | src/output/Soapy.cpp | 8 | ||||
-rw-r--r-- | src/output/Soapy.h | 2 | ||||
-rw-r--r-- | src/output/UHD.cpp | 9 | ||||
-rw-r--r-- | src/output/UHD.h | 2 |
6 files changed, 36 insertions, 0 deletions
diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp index 9be9aa2..068b5af 100644 --- a/src/output/SDR.cpp +++ b/src/output/SDR.cpp @@ -75,6 +75,7 @@ SDR::SDR(SDRDeviceConfig& config, std::shared_ptr<SDRDevice> device) : RC_ADD_PARAMETER(rxgain, "RX gain for DPD feedback"); RC_ADD_PARAMETER(freq, "Transmission frequency"); RC_ADD_PARAMETER(muting, "Mute the output by stopping the transmitter"); + RC_ADD_PARAMETER(temp, "Temperature in degrees C of the 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"); @@ -412,6 +413,18 @@ const string SDR::get_parameter(const string& parameter) const else if (parameter == "muting") { ss << m_config.muting; } + else if (parameter == "temp") { + if (not m_device) { + throw ParameterError("OutputSDR has no device"); + } + const double temp = m_device->get_temperature(); + if (std::isnan(temp)) { + throw ParameterError("Temperature not available"); + } + else { + ss << temp; + } + } else if (parameter == "underruns" or parameter == "latepackets" or parameter == "frames" ) { diff --git a/src/output/SDRDevice.h b/src/output/SDRDevice.h index 9e052b0..90a1123 100644 --- a/src/output/SDRDevice.h +++ b/src/output/SDRDevice.h @@ -130,6 +130,8 @@ class SDRDevice { struct frame_timestamp& ts, double timeout_secs) = 0; + // Returns device temperature in degrees C or NaN if not available + virtual double get_temperature(void) const = 0; // Return true if GPS and reference clock inputs are ok virtual bool is_clk_source_ok(void) const = 0; diff --git a/src/output/Soapy.cpp b/src/output/Soapy.cpp index 36ecaa8..86ed3e0 100644 --- a/src/output/Soapy.cpp +++ b/src/output/Soapy.cpp @@ -35,6 +35,7 @@ DESCRIPTION: #include <SoapySDR/Errors.hpp> #include <chrono> +#include <limits> #include <cstdio> #include <iomanip> @@ -239,6 +240,13 @@ const char* Soapy::device_name(void) const return "Soapy"; } +double Soapy::get_temperature(void) const +{ + // TODO Unimplemented + // LimeSDR exports 'lms7_temp' + return std::numeric_limits<double>::quiet_NaN(); +} + void Soapy::transmit_frame(const struct FrameData& frame) { if (not m_device) throw runtime_error("Soapy device not set up"); diff --git a/src/output/Soapy.h b/src/output/Soapy.h index 3045420..9feb0b8 100644 --- a/src/output/Soapy.h +++ b/src/output/Soapy.h @@ -79,6 +79,8 @@ class Soapy : public Output::SDRDevice virtual bool is_clk_source_ok(void) const override; virtual const char* device_name(void) const override; + virtual double get_temperature(void) const override; + private: SDRDeviceConfig& m_conf; SoapySDR::Device *m_device = nullptr; diff --git a/src/output/UHD.cpp b/src/output/UHD.cpp index 1106fe0..9358072 100644 --- a/src/output/UHD.cpp +++ b/src/output/UHD.cpp @@ -451,6 +451,15 @@ const char* UHD::device_name(void) const return "UHD"; } +double UHD::get_temperature(void) const +{ + try { + return std::round(m_usrp->get_tx_sensor("temp", 0).to_real()); + } + catch (uhd::lookup_error &e) { + return std::numeric_limits<double>::quiet_NaN(); + } +} bool UHD::refclk_loss_needs_check() const { diff --git a/src/output/UHD.h b/src/output/UHD.h index 9aec7ce..f42b6e8 100644 --- a/src/output/UHD.h +++ b/src/output/UHD.h @@ -93,6 +93,8 @@ class UHD : public Output::SDRDevice virtual bool is_clk_source_ok(void) const override; virtual const char* device_name(void) const override; + virtual double get_temperature(void) const override; + private: SDRDeviceConfig& m_conf; uhd::usrp::multi_usrp::sptr m_usrp; |