Comments (6)
The implementation is transparently calling bladerf_get_gain and bladerf_set_gain:
- https://github.com/pothosware/SoapyBladeRF/blob/master/bladeRF_Settings.cpp#L361
- https://github.com/pothosware/SoapyBladeRF/blob/master/bladeRF_Settings.cpp#L381
So it might be a bug in libbladerf. You can put a few prints in there to confirm its libbladerf?
from soapybladerf.
from soapybladerf.
Thanks @drahosj, it seems I first need to explicitly disable the gain, before I can set it.
I don't know if it's the expected/usual behavior.
There still seem to be other errors on the libbladerf part, see Nuand/bladeRF#731 .
from soapybladerf.
I found what the real issue was, for the BladeRF2.
In BladeRF test_gain.c, there is
/* Enable channel (necessary for RX gain changes to register
* on bladerf2) */
status = bladerf_enable_module(dev, ch, true);
I've currently updated the SoapyBladeRF code to this
void bladeRF_SoapySDR::setGain(const int direction, const size_t channel, const double value)
{
// Enable channel (necessary for RX gain changes to register on bladerf2)
// See bladeRF/host/libraries/libbladeRF_test/test_ctrl/src/test_gain.c
int ret = bladerf_enable_module(_dev, _toch(direction, channel), true);
if (ret != 0)
{
SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_enable_module returned %s", _err2str(ret).c_str());
throw std::runtime_error("setGain() " + _err2str(ret));
}
ret = bladerf_set_gain(_dev, _toch(direction, channel), bladerf_gain(std::round(value)));
if (ret != 0)
{
SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_set_gain(%f) returned %s", value, _err2str(ret).c_str());
throw std::runtime_error("setGain() " + _err2str(ret));
}
}
I'm not sure if it's possible to know if the channel is already enabled to avoid redoing it, nor if it causes issues if it's already opened.
Also this might make more sense for the BladeRF code to take care of that...
from soapybladerf.
It seems like we should be able to call bladerf_enable_module in the constructor then. Can you try removing it from setup/closeStream, and move them to the constructor instead?
from soapybladerf.
It seems to be working (I haven't done extensive tests). I removed the bladerf_enable_module
calls from setupStream
and closeStream
and created a simple function to enable or disable all channels in both directions, that I call in the constructor and destructor:
void bladeRF_SoapySDR::_enable_or_disable_module(const bool enable, const bool throwOnError) {
std::vector<int> directions;
directions.push_back(SOAPY_SDR_RX);
directions.push_back(SOAPY_SDR_TX);
std::vector<size_t> channels;
channels.push_back(0);
if (_isBladeRF2)
channels.push_back(1);
for (const auto dir : directions) {
for (const auto ch : channels)
{
const int ret = bladerf_enable_module(_dev, _toch(dir, ch), enable);
if (ret != 0)
{
SoapySDR::logf(SOAPY_SDR_ERROR, "bladerf_enable_module(%s) returned %s", enable ? "true" : "false", _err2str(ret).c_str());
if (throwOnError)
throw std::runtime_error("bladerf_enable_module() " + _err2str(ret));
}
}
}
directions.clear();
channels.clear();
}
from soapybladerf.
Related Issues (20)
- Return the status of MINIEXP1 & MINIEXP2 in readStream HOT 3
- Access quick tune API HOT 6
- How to use XB200 transverter board? HOT 2
- Activating the PLL clock refrerence HOT 11
- BladeRf 2.0 multiple input - 2 different frequences on 2 different inputs HOT 2
- Issue with Bladerf2 + soapy (+ osmosdr) HOT 2
- Libbladerf 2.4 and loss of manual gain control
- Add setting for "verbose"
- Unable to enable Bias-T with Soapy Sink and/or Source blocks for the BladeRF (2.0 xA4). HOT 2
- 2-Channel Receive Error with libbladerf 2021.10 HOT 2
- SoapyBladeRF usb timeout errors HOT 2
- More problems with 2 channel reception HOT 4
- Update dual streaming patch not building HOT 3
- ‘SOAPY_SDR_USER_FLAG1’ was not declared in this scope HOT 2
- Consider supplying the quick_tune parameter to bladerf_schedule_retune() when the XB-200 is enabled. HOT 4
- Add new release tag HOT 1
- (Request) Add ability to specify new sample format and oversample settings
- BladeRF wait_for_buffer error HOT 1
- Multiple Blades must be loaded in a specific order
- Units for timestamp keyword on setFrequency() are inconsistent with the rest of SoapySDR
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from soapybladerf.