[hamradio-commits] [soapybladerf] 01/06: New upstream version 0.3.4

Andreas E. Bombe aeb at moszumanska.debian.org
Wed Jan 24 21:24:22 UTC 2018


This is an automated email from the git hooks/post-receive script.

aeb pushed a commit to annotated tag debian/0.3.4-1
in repository soapybladerf.

commit c1c82f56e6b680b4718a30c7f1ca41f5aa7bf9c6
Author: Andreas Bombe <aeb at debian.org>
Date:   Wed Jan 24 22:08:17 2018 +0100

    New upstream version 0.3.4
---
 Changelog.txt        |   7 ++
 bladeRF_Settings.cpp | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++
 bladeRF_SoapySDR.hpp |  27 ++++++++
 debian/changelog     |   6 ++
 debian/control       |   2 +-
 5 files changed, 218 insertions(+), 1 deletion(-)

diff --git a/Changelog.txt b/Changelog.txt
index f3b8980..d2b599f 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,3 +1,10 @@
+Release 0.3.4 (2018-01-16)
+==========================
+
+- Support for setting the gain mode (hardware AGC)
+- Support for DC offset and IQ imbalance corrections
+- Added readback support for arbitrary settings API
+
 Release 0.3.3 (2017-04-29)
 ==========================
 
diff --git a/bladeRF_Settings.cpp b/bladeRF_Settings.cpp
index d940c8f..884f2da 100644
--- a/bladeRF_Settings.cpp
+++ b/bladeRF_Settings.cpp
@@ -42,7 +42,11 @@ bladeRF_SoapySDR::bladeRF_SoapySDR(const bladerf_devinfo &devinfo):
     _rxBuffSize(0),
     _txBuffSize(0),
     _rxMinTimeoutMs(0),
+    _xb200Mode("disabled"),
+    _samplingMode("internal"),
+    _loopbackMode("disabled"),
     _dev(NULL)
+
 {
     bladerf_devinfo info = devinfo;
     SoapySDR::logf(SOAPY_SDR_INFO, "bladerf_open_with_devinfo()");
@@ -131,9 +135,165 @@ std::string bladeRF_SoapySDR::getAntenna(const int direction, const size_t chann
 }
 
 /*******************************************************************
+ * Calibration API
+ ******************************************************************/
+
+bool bladeRF_SoapySDR::hasDCOffset(const int, const size_t) const
+{
+    return true;
+}
+
+void bladeRF_SoapySDR::setDCOffset(const int direction, const size_t, const std::complex<double> &offset)
+{
+    int ret = 0;
+    int16_t i = 0;
+    int16_t q = 0;
+
+    if (offset.real() > 1.0)
+        i = int16_t(1.0 * 2048);
+    else
+        i = int16_t(offset.real() * 2048);
+
+    if (offset.imag() > 1.0)
+        q = int16_t(1.0 * 2048);
+    else
+        q = int16_t(offset.imag() * 2048);
+
+    ret = bladerf_set_correction(_dev, _dir2mod(direction), BLADERF_CORR_LMS_DCOFF_I, i);
+    if (ret != 0)
+    {
+        SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_set_correction(%f) returned %s", i, _err2str(ret).c_str());
+        throw std::runtime_error("setDCOffset() " + _err2str(ret));
+    }
+
+    ret = bladerf_set_correction(_dev, _dir2mod(direction), BLADERF_CORR_LMS_DCOFF_Q, q);
+    if (ret != 0)
+    {
+        SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_set_correction(%f) returned %s", q, _err2str(ret).c_str());
+        throw std::runtime_error("setDCOffset() " + _err2str(ret));
+    }
+}
+
+std::complex<double> bladeRF_SoapySDR::getDCOffset(const int direction, const size_t) const
+{
+    int ret = 0;
+    int16_t i = 0;
+    int16_t q = 0;
+
+    ret = bladerf_get_correction(_dev, _dir2mod(direction), BLADERF_CORR_LMS_DCOFF_I, &i);
+    if (ret != 0)
+    {
+        SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_get_correction() returned %s", _err2str(ret).c_str());
+        throw std::runtime_error("getDCOffset() " + _err2str(ret));
+    }
+
+    ret = bladerf_get_correction(_dev, _dir2mod(direction), BLADERF_CORR_LMS_DCOFF_Q, &q);
+    if (ret != 0)
+    {
+        SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_get_correction() returned %s", _err2str(ret).c_str());
+        throw std::runtime_error("getDCOffset() " + _err2str(ret));
+    }
+
+    std::complex<double> z(i / 2048.0f, q / 2048.0f);
+    return z;
+}
+
+bool bladeRF_SoapySDR::hasIQBalance(const int, const size_t) const
+{
+    return true;
+}
+
+void bladeRF_SoapySDR::setIQBalance(const int direction, const size_t, const std::complex<double> &balance)
+{
+    int ret = 0;
+    int16_t gain = 0;
+    int16_t phase = 0;
+
+    if (balance.real() > 1.0)
+        gain = int16_t(1.0 * 4096);
+    else
+        gain = int16_t(balance.real() * 4096);
+
+    if (balance.imag() > 1.0)
+        phase = int16_t(1.0 * 4096);
+    else
+        phase = int16_t(balance.imag() * 4096);
+
+    ret = bladerf_set_correction(_dev, _dir2mod(direction), BLADERF_CORR_FPGA_GAIN, gain);
+    if (ret != 0)
+    {
+        SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_set_correction(%f) returned %s", gain, _err2str(ret).c_str());
+        throw std::runtime_error("setIQBalance() " + _err2str(ret));
+    }
+
+    ret = bladerf_set_correction(_dev, _dir2mod(direction), BLADERF_CORR_FPGA_PHASE, phase);
+    if (ret != 0)
+    {
+        SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_set_correction(%f) returned %s", phase, _err2str(ret).c_str());
+        throw std::runtime_error("setIQBalance() " + _err2str(ret));
+    }
+}
+
+std::complex<double> bladeRF_SoapySDR::getIQBalance(const int direction, const size_t) const
+{
+    int ret = 0;
+    int16_t gain = 0;
+    int16_t phase = 0;
+
+    ret = bladerf_get_correction(_dev, _dir2mod(direction), BLADERF_CORR_FPGA_GAIN, &gain);
+    if (ret != 0)
+    {
+        SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_get_correction() returned %s", _err2str(ret).c_str());
+        throw std::runtime_error("getIQBalance() " + _err2str(ret));
+    }
+
+    ret = bladerf_get_correction(_dev, _dir2mod(direction), BLADERF_CORR_FPGA_PHASE, &phase);
+    if (ret != 0)
+    {
+        SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_get_correction() returned %s", _err2str(ret).c_str());
+        throw std::runtime_error("getIQBalance() " + _err2str(ret));
+    }
+
+    std::complex<double> z(gain / 4096.0f, phase / 4096.0f);
+    return z;
+}
+
+/*******************************************************************
  * Gain API
  ******************************************************************/
 
+bool bladeRF_SoapySDR::hasGainMode(const int direction, const size_t) const
+{
+    return _dir2mod(direction) == BLADERF_MODULE_RX ? true : false;
+}
+
+void bladeRF_SoapySDR::setGainMode(const int direction, const size_t, const bool automatic)
+{
+    bladerf_gain_mode gain_mode = automatic ? BLADERF_GAIN_AUTOMATIC : BLADERF_GAIN_MANUAL;
+    const int ret = bladerf_set_gain_mode(_dev, _dir2mod(direction), gain_mode);
+    if (ret != 0)
+    {
+        SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_set_gain_mode(%f) returned %s", gain_mode, _err2str(ret).c_str());
+        throw std::runtime_error("setGainMode() " + _err2str(ret));
+    }
+}
+
+bool bladeRF_SoapySDR::getGainMode(const int direction, const size_t) const
+{
+    int ret = 0;
+    bladerf_gain_mode gain_mode;
+    bool automatic;
+    ret = bladerf_get_gain_mode(_dev, _dir2mod(direction), &gain_mode);
+    if (ret != 0)
+    {
+        SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_get_gain_mode() returned %s", _err2str(ret).c_str());
+        throw std::runtime_error("getGainMode() " + _err2str(ret));
+    }
+
+    automatic = gain_mode == BLADERF_GAIN_AUTOMATIC ? true : false;
+    return automatic;
+}
+
 std::vector<std::string> bladeRF_SoapySDR::listGains(const int direction, const size_t) const
 {
     std::vector<std::string> options;
@@ -534,6 +694,20 @@ SoapySDR::ArgInfoList bladeRF_SoapySDR::getSettingInfo(void) const
     return setArgs;
 }
 
+std::string bladeRF_SoapySDR::readSetting(const std::string &key) const
+{
+    if (key == "xb200") {
+        return _xb200Mode;
+    } else if (key == "sampling_mode") {
+        return _samplingMode;
+    } else if (key == "loopback") {
+        return _loopbackMode;
+    }
+
+    SoapySDR_logf(SOAPY_SDR_WARNING, "Unknown setting '%s'", key.c_str());
+    return "";
+}
+
 void bladeRF_SoapySDR::writeSetting(const std::string &key, const std::string &value)
 {
     if (key == "xb200")
@@ -543,6 +717,7 @@ void bladeRF_SoapySDR::writeSetting(const std::string &key, const std::string &v
         if (std::find(std::begin(xb200_validSettings), std::end(xb200_validSettings), value) != std::end(xb200_validSettings))
         {
             // --> Valid setting has arrived
+            _xb200Mode = value;
 
             // Get attached expansion device
             bladerf_xb _bladerf_xb_attached = bladerf_xb::BLADERF_XB_NONE;
@@ -657,6 +832,7 @@ void bladeRF_SoapySDR::writeSetting(const std::string &key, const std::string &v
         if (std::find(std::begin(sampling_mode_validSettings), std::end(sampling_mode_validSettings), value) != std::end(sampling_mode_validSettings))
         {
             // --> Valid setting has arrived
+            _samplingMode = value;
 
             // Set the sampling mode
             int ret = 0;
@@ -692,6 +868,7 @@ void bladeRF_SoapySDR::writeSetting(const std::string &key, const std::string &v
         if (std::find(std::begin(loopback_validSettings), std::end(loopback_validSettings), value) != std::end(loopback_validSettings))
         {
             // --> Valid setting has arrived
+            _loopbackMode = value;
 
             // Which loopback mode was selected?
             bladerf_loopback loopback = bladerf_loopback::BLADERF_LB_NONE;
diff --git a/bladeRF_SoapySDR.hpp b/bladeRF_SoapySDR.hpp
index f696080..1df286f 100644
--- a/bladeRF_SoapySDR.hpp
+++ b/bladeRF_SoapySDR.hpp
@@ -147,9 +147,31 @@ public:
     std::string getAntenna(const int direction, const size_t channel) const;
 
     /*******************************************************************
+     * Calibration API
+     ******************************************************************/
+
+    bool hasDCOffset(const int direction, const size_t) const;
+
+    void setDCOffset(const int direction, const size_t, const std::complex<double> &offset);
+
+    std::complex<double> getDCOffset(const int direction, const size_t) const;
+
+    bool hasIQBalance(const int direction, const size_t) const;
+
+    void setIQBalance(const int direction, const size_t, const std::complex<double> &balance);
+
+    std::complex<double> getIQBalance(const int direction, const size_t) const;
+
+    /*******************************************************************
      * Gain API
      ******************************************************************/
 
+    bool hasGainMode(const int direction, const size_t channel) const;
+
+    void setGainMode(const int direction, const size_t channel, const bool automatic);
+
+    bool getGainMode(const int direction, const size_t channel) const;
+
     std::vector<std::string> listGains(const int direction, const size_t channel) const;
 
     void setGain(const int direction, const size_t channel, const double value);
@@ -214,6 +236,8 @@ public:
 
     void writeSetting(const std::string &key, const std::string &value);
 
+    std::string readSetting(const std::string &key) const;
+
     /*******************************************************************
      * GPIO API
      ******************************************************************/
@@ -307,6 +331,9 @@ private:
     long _rxMinTimeoutMs;
     std::queue<StreamMetadata> _rxCmds;
     std::queue<StreamMetadata> _txResps;
+    std::string _xb200Mode;
+    std::string _samplingMode;
+    std::string _loopbackMode;
 
     bladerf *_dev;
 };
diff --git a/debian/changelog b/debian/changelog
index d4b573e..c349fc4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+soapybladerf (0.3.4-1) unstable; urgency=low
+
+  * Release 0.3.4 (2018-01-16)
+
+ -- Josh Blum <josh at pothosware.com>  Tue, 16 Jan 2018 20:29:57 -0000
+
 soapybladerf (0.3.3-1) unstable; urgency=low
 
   * Release 0.3.3 (2017-04-29)
diff --git a/debian/control b/debian/control
index 5f8a51e..60cbdb5 100644
--- a/debian/control
+++ b/debian/control
@@ -7,7 +7,7 @@ Build-Depends:
     cmake,
     libbladerf-dev,
     libsoapysdr-dev
-Standards-Version: 3.9.8
+Standards-Version: 4.1.1
 Homepage: https://github.com/pothosware/SoapyBladeRF/wiki
 Vcs-Git: https://github.com/pothosware/SoapyBladeRF.git
 Vcs-Browser: https://github.com/pothosware/SoapyBladeRF

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/soapybladerf.git



More information about the pkg-hamradio-commits mailing list