mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-08 00:44:56 -04:00
Integrate more soapy device params
- Check current sample/frequency ranges when switching devices to keep them in bounds.
This commit is contained in:
@@ -1,11 +1,41 @@
|
||||
#include "SDRDeviceInfo.h"
|
||||
|
||||
SDRDeviceRange::SDRDeviceRange() {
|
||||
low = 0;
|
||||
high = 0;
|
||||
}
|
||||
|
||||
int SDRDeviceChannel::getChannel() const {
|
||||
SDRDeviceRange::SDRDeviceRange(double low, double high) {
|
||||
this->low = low;
|
||||
this->high = high;
|
||||
}
|
||||
|
||||
double SDRDeviceRange::getLow() {
|
||||
return low;
|
||||
}
|
||||
void SDRDeviceRange::setLow(double low) {
|
||||
this->low = low;
|
||||
}
|
||||
double SDRDeviceRange::getHigh() {
|
||||
return high;
|
||||
}
|
||||
void SDRDeviceRange::setHigh(double high) {
|
||||
this->high = high;
|
||||
}
|
||||
|
||||
SDRDeviceChannel::SDRDeviceChannel() {
|
||||
|
||||
}
|
||||
|
||||
SDRDeviceChannel::~SDRDeviceChannel() {
|
||||
|
||||
}
|
||||
|
||||
int SDRDeviceChannel::getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
void SDRDeviceChannel::setChannel(const int channel) {
|
||||
void SDRDeviceChannel::setChannel(int channel) {
|
||||
this->channel = channel;
|
||||
}
|
||||
|
||||
@@ -33,27 +63,27 @@ void SDRDeviceChannel::setRx(bool rx) {
|
||||
this->rx = rx;
|
||||
}
|
||||
|
||||
const SDRDeviceRange &SDRDeviceChannel::getGain() const {
|
||||
SDRDeviceRange &SDRDeviceChannel::getGain() {
|
||||
return rangeGain;
|
||||
}
|
||||
|
||||
const SDRDeviceRange &SDRDeviceChannel::getLNAGain() const {
|
||||
SDRDeviceRange &SDRDeviceChannel::getLNAGain() {
|
||||
return rangeLNA;
|
||||
}
|
||||
|
||||
const SDRDeviceRange &SDRDeviceChannel::getFreqRange() const {
|
||||
SDRDeviceRange &SDRDeviceChannel::getFreqRange() {
|
||||
return rangeFull;
|
||||
}
|
||||
|
||||
const SDRDeviceRange &SDRDeviceChannel::getRFRange() const {
|
||||
SDRDeviceRange &SDRDeviceChannel::getRFRange() {
|
||||
return rangeRF;
|
||||
}
|
||||
|
||||
const std::vector<long long> &SDRDeviceChannel::getSampleRates() const {
|
||||
std::vector<long long> &SDRDeviceChannel::getSampleRates() {
|
||||
return sampleRates;
|
||||
}
|
||||
|
||||
const std::vector<long long> &SDRDeviceChannel::getFilterBandwidths() const {
|
||||
std::vector<long long> &SDRDeviceChannel::getFilterBandwidths() {
|
||||
return filterBandwidths;
|
||||
}
|
||||
|
||||
@@ -177,3 +207,32 @@ void SDRDeviceInfo::setStreamArgs(SoapySDR::Kwargs streamArgs) {
|
||||
SoapySDR::Kwargs SDRDeviceInfo::getStreamArgs() {
|
||||
return streamArgs;
|
||||
}
|
||||
|
||||
void SDRDeviceInfo::addChannel(SDRDeviceChannel *chan) {
|
||||
channels.push_back(chan);
|
||||
}
|
||||
|
||||
std::vector<SDRDeviceChannel *> &SDRDeviceInfo::getChannels() {
|
||||
return channels;
|
||||
}
|
||||
|
||||
SDRDeviceChannel * SDRDeviceInfo::getRxChannel() {
|
||||
std::vector<SDRDeviceChannel *>::iterator channel_i;
|
||||
for (channel_i = channels.begin(); channel_i != channels.end(); channel_i++) {
|
||||
if ((*channel_i)->isRx()) {
|
||||
return (*channel_i);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDRDeviceChannel * SDRDeviceInfo::getTxChannel() {
|
||||
std::vector<SDRDeviceChannel *>::iterator channel_i;
|
||||
for (channel_i = channels.begin(); channel_i != channels.end(); channel_i++) {
|
||||
if ((*channel_i)->isTx()) {
|
||||
return (*channel_i);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
+24
-16
@@ -34,20 +34,25 @@
|
||||
|
||||
class SDRDeviceRange {
|
||||
public:
|
||||
SDRDeviceRange(float low, float high);
|
||||
SDRDeviceRange();
|
||||
SDRDeviceRange(double low, double high);
|
||||
|
||||
float getLow() const;
|
||||
void setLow(const float low);
|
||||
float getHigh() const;
|
||||
void setHigh(const float high);
|
||||
double getLow();
|
||||
void setLow(double low);
|
||||
double getHigh();
|
||||
void setHigh(double high);
|
||||
|
||||
private:
|
||||
float low, high;
|
||||
double low, high;
|
||||
};
|
||||
|
||||
class SDRDeviceChannel {
|
||||
int getChannel() const;
|
||||
void setChannel(const int channel);
|
||||
public:
|
||||
SDRDeviceChannel();
|
||||
~SDRDeviceChannel();
|
||||
|
||||
int getChannel();
|
||||
void setChannel(int channel);
|
||||
|
||||
bool isFullDuplex();
|
||||
void setFullDuplex(bool fullDuplex);
|
||||
@@ -58,13 +63,13 @@ class SDRDeviceChannel {
|
||||
bool isRx();
|
||||
void setRx(bool rx);
|
||||
|
||||
const SDRDeviceRange &getGain() const;
|
||||
const SDRDeviceRange &getLNAGain() const;
|
||||
const SDRDeviceRange &getFreqRange() const;
|
||||
const SDRDeviceRange &getRFRange() const;
|
||||
SDRDeviceRange &getGain();
|
||||
SDRDeviceRange &getLNAGain();
|
||||
SDRDeviceRange &getFreqRange();
|
||||
SDRDeviceRange &getRFRange();
|
||||
|
||||
const std::vector<long long> &getSampleRates() const;
|
||||
const std::vector<long long> &getFilterBandwidths() const;
|
||||
std::vector<long long> &getSampleRates();
|
||||
std::vector<long long> &getFilterBandwidths();
|
||||
|
||||
private:
|
||||
int channel;
|
||||
@@ -114,7 +119,10 @@ public:
|
||||
bool hasTimestamps() const;
|
||||
void setTimestamps(bool timestamps);
|
||||
|
||||
const std::vector<SDRDeviceChannel>& getChannels() const;
|
||||
void addChannel(SDRDeviceChannel *chan);
|
||||
std::vector<SDRDeviceChannel *> &getChannels();
|
||||
SDRDeviceChannel * getRxChannel();
|
||||
SDRDeviceChannel * getTxChannel();
|
||||
|
||||
void setDeviceArgs(SoapySDR::Kwargs deviceArgs);
|
||||
SoapySDR::Kwargs getDeviceArgs();
|
||||
@@ -129,5 +137,5 @@ private:
|
||||
bool timestamps, available, hardwareDC;
|
||||
|
||||
SoapySDR::Kwargs deviceArgs, streamArgs;
|
||||
std::vector<SDRDeviceChannel> channels;
|
||||
std::vector<SDRDeviceChannel *> channels;
|
||||
};
|
||||
|
||||
@@ -111,6 +111,25 @@ std::vector<SDRDeviceInfo *> *SDREnumerator::enumerate_devices() {
|
||||
}
|
||||
}
|
||||
|
||||
int numChan = device->getNumChannels(SOAPY_SDR_RX);
|
||||
for (int i = 0; i < numChan; i++) {
|
||||
SDRDeviceChannel *chan = new SDRDeviceChannel();
|
||||
|
||||
SoapySDR::RangeList rfRange = device->getFrequencyRange(SOAPY_SDR_RX, i);
|
||||
double rfMin = rfRange[0].minimum();
|
||||
double rfMax = rfRange[rfRange.size()-1].maximum();
|
||||
chan->setChannel(i);
|
||||
chan->setFullDuplex(device->getFullDuplex(SOAPY_SDR_RX, i));
|
||||
chan->setRx(true);
|
||||
chan->setTx(false);
|
||||
chan->getRFRange().setLow(rfMin);
|
||||
chan->getRFRange().setHigh(rfMax);
|
||||
|
||||
std::vector<double> rates = device->listSampleRates(SOAPY_SDR_RX, i);
|
||||
chan->getSampleRates().assign(rates.begin(), rates.end());
|
||||
dev->addChannel(chan);
|
||||
}
|
||||
|
||||
if (device->hasDCOffsetMode(SOAPY_SDR_RX, 0)) {
|
||||
device->setDCOffsetMode(SOAPY_SDR_RX, 0, true);
|
||||
std::cout << "Hardware DC offset support detected; internal DC offset correction will be disabled." << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user