Remove SoapySDR::Device proxy classes and functions, use SoapySDR directly

This commit is contained in:
Charles J. Cliffe 2016-01-31 15:11:54 -05:00
parent 4a891d4785
commit 48aff5baf1
8 changed files with 178 additions and 392 deletions

View File

@ -556,7 +556,7 @@ void AppFrame::updateDeviceParams() {
// Build settings menu
wxMenu *newSettingsMenu = new wxMenu;
newSettingsMenu->Append(wxID_SET_FREQ_OFFSET, "Frequency Offset");
if (devInfo->getRxChannel()->hasCORR()) {
if (devInfo->hasCORR(SOAPY_SDR_RX, 0)) {
newSettingsMenu->Append(wxID_SET_PPM, "Device PPM");
}
@ -566,7 +566,7 @@ void AppFrame::updateDeviceParams() {
SoapySDR::ArgInfoList::const_iterator args_i;
int i = 0;
settingArgs = devInfo->getSettingsArgInfo();
settingArgs = devInfo->getSoapyDevice()->getSettingInfo();
for (args_i = settingArgs.begin(); args_i != settingArgs.end(); args_i++) {
SoapySDR::ArgInfo arg = (*args_i);
std::string currentVal = wxGetApp().getSDRThread()->readSetting(arg.key);
@ -610,7 +610,7 @@ void AppFrame::updateDeviceParams() {
settingsMenu = newSettingsMenu;
// Build sample rate menu
sampleRates = devInfo->getRxChannel()->getSampleRates();
sampleRates = devInfo->getSampleRates(SOAPY_SDR_RX, 0);
sampleRateMenuItems.erase(sampleRateMenuItems.begin(),sampleRateMenuItems.end());
wxMenu *newSampleRateMenu = new wxMenu;
@ -637,7 +637,7 @@ void AppFrame::updateDeviceParams() {
if (!wxGetApp().getAGCMode()) {
gainSpacerItem->Show(true);
gainSizerItem->Show(true);
gainSizerItem->SetMinSize(devInfo->getRxChannel()->getGains().size()*50,0);
gainSizerItem->SetMinSize(devInfo->getSoapyDevice()->listGains(SOAPY_SDR_RX,0).size()*50,0);
demodTray->Layout();
gainCanvas->updateGainUI();
gainCanvas->Refresh();
@ -695,7 +695,7 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
wxGetApp().setAGCMode(false);
gainSpacerItem->Show(true);
gainSizerItem->Show(true);
gainSizerItem->SetMinSize(wxGetApp().getDevice()->getRxChannel()->getGains().size()*40,0);
gainSizerItem->SetMinSize(wxGetApp().getDevice()->getSoapyDevice()->listGains(SOAPY_SDR_RX, 0).size()*40,0);
demodTray->Layout();
gainCanvas->updateGainUI();
gainCanvas->Refresh();
@ -837,14 +837,14 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
break;
}
SDRDeviceChannel *chan = dev->getRxChannel();
std::vector<long> sampleRates = dev->getSampleRates(SOAPY_SDR_RX, 0);
rateLow = 2000000;
rateHigh = 30000000;
if (chan->getSampleRates().size()) {
rateLow = chan->getSampleRates()[0];
rateHigh = chan->getSampleRates()[chan->getSampleRates().size()-1];
if (sampleRates.size()) {
rateLow = sampleRates[0];
rateHigh = sampleRates[sampleRates.size()-1];
}
long bw = wxGetNumberFromUser("\n" + dev->getName() + "\n\n "
@ -1377,11 +1377,8 @@ bool AppFrame::loadSession(std::string fileName) {
SDRDeviceInfo *dev = wxGetApp().getSDRThread()->getDevice();
if (dev) {
SDRDeviceChannel *chan = dev->getRxChannel();
if (chan) {
// Try for a reasonable default sample rate.
sample_rate = chan->getSampleRateNear(sample_rate);
}
// Try for a reasonable default sample rate.
sample_rate = dev->getSampleRateNear(SOAPY_SDR_RX, 0, sample_rate);
wxGetApp().setSampleRate(sample_rate);
deviceChanged.store(true);
} else {

View File

@ -526,45 +526,34 @@ void CubicSDR::setDevice(SDRDeviceInfo *dev) {
DeviceConfig *devConfig = config.getDevice(dev->getDeviceId());
SDRDeviceChannel *chan = dev->getRxChannel();
SoapySDR::Device *soapyDev = dev->getSoapyDevice();
if (chan) {
if (soapyDev) {
long long freqHigh, freqLow;
freqHigh = chan->getRFRange().getHigh();
freqLow = chan->getRFRange().getLow();
SoapySDR::RangeList freqRange = soapyDev->getFrequencyRange(SOAPY_SDR_RX, 0);
freqLow = freqRange[0].minimum();
freqHigh = freqRange[freqRange.size()-1].maximum();
// Try for a reasonable default sample rate.
if (!sampleRateInitialized.load()) {
sampleRate = chan->getSampleRateNear(DEFAULT_SAMPLE_RATE);
sampleRate = dev->getSampleRateNear(SOAPY_SDR_RX, 0, DEFAULT_SAMPLE_RATE);
sampleRateInitialized.store(true);
} else {
sampleRate = dev->getSampleRateNear(SOAPY_SDR_RX, 0, sampleRate);
}
int rateHigh, rateLow;
rateHigh = rateLow = sampleRate;
if (chan->getSampleRates().size()) {
rateLow = chan->getSampleRates()[0];
rateHigh = chan->getSampleRates()[chan->getSampleRates().size()-1];
}
if (sampleRate > rateHigh) {
sampleRate = rateHigh;
} else if (sampleRate < rateLow) {
sampleRate = rateLow;
}
if (frequency < sampleRate/2) {
frequency = sampleRate/2;
}
setFrequency(frequency);
setSampleRate(sampleRate);
setPPM(devConfig->getPPM());
setOffset(devConfig->getOffset());
t_SDR = new std::thread(&SDRThread::threadMain, sdrThread);
}
}

View File

@ -104,7 +104,7 @@ void SDRDevicesDialog::OnSelectionChanged( wxTreeEvent& event ) {
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getName());
m_propertyGrid->Clear();
SoapySDR::ArgInfoList args = dev->getSettingsArgInfo();
SoapySDR::ArgInfoList args = dev->getSoapyDevice()->getSettingInfo();
SoapySDR::ArgInfoList::const_iterator args_i;
m_propertyGrid->Append(new wxPropertyCategory("General Settings"));
@ -125,8 +125,8 @@ void SDRDevicesDialog::OnSelectionChanged( wxTreeEvent& event ) {
}
}
if (dev->getRxChannel()) {
args = dev->getRxChannel()->getStreamArgsInfo();
if (dev) {
args = dev->getSoapyDevice()->getStreamArgsInfo(SOAPY_SDR_RX, 0);
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
ConfigSettings devStreamOpts = devConfig->getStreamOpts();
@ -237,7 +237,7 @@ void SDRDevicesDialog::OnUseSelected( wxMouseEvent& /* event */) {
if (dev != NULL) {
int i = 0;
SoapySDR::ArgInfoList::const_iterator args_i;
SoapySDR::ArgInfoList args = dev->getSettingsArgInfo();
SoapySDR::ArgInfoList args = dev->getSoapyDevice()->getSettingInfo();
SoapySDR::Kwargs settingArgs;
SoapySDR::Kwargs streamArgs;
@ -257,8 +257,8 @@ void SDRDevicesDialog::OnUseSelected( wxMouseEvent& /* event */) {
i++;
}
if (dev->getRxChannel()) {
args = dev->getRxChannel()->getStreamArgsInfo();
if (dev) {
args = dev->getSoapyDevice()->getStreamArgsInfo(SOAPY_SDR_RX, 0);
if (args.size()) {
for (args_i = args.begin(); args_i != args.end(); args_i++) {

View File

@ -1,167 +1,14 @@
#include "SDRDeviceInfo.h"
#include <cstdlib>
SDRDeviceRange::SDRDeviceRange() {
low = 0;
high = 0;
SDRDeviceInfo::SDRDeviceInfo() : name(""), serial(""), available(false), remote(false), manual(false), soapyDevice(nullptr) {
}
SDRDeviceRange::SDRDeviceRange(double low, double high) {
this->low = low;
this->high = high;
}
SDRDeviceRange::SDRDeviceRange(std::string name, double low, double high) : SDRDeviceRange(low, high) {
this->name = name;
}
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;
}
std::string SDRDeviceRange::getName() {
return this->name;
}
void SDRDeviceRange::setName(std::string name) {
this->name = name;
}
SDRDeviceChannel::SDRDeviceChannel() {
hardwareDC = false;
hasCorr = false;
}
SDRDeviceChannel::~SDRDeviceChannel() {
}
int SDRDeviceChannel::getChannel() {
return channel;
}
void SDRDeviceChannel::setChannel(int channel) {
this->channel = channel;
}
bool SDRDeviceChannel::isFullDuplex() {
return fullDuplex;
}
void SDRDeviceChannel::setFullDuplex(bool fullDuplex) {
this->fullDuplex = fullDuplex;
}
bool SDRDeviceChannel::isTx() {
return tx;
}
void SDRDeviceChannel::setTx(bool tx) {
this->tx = tx;
}
bool SDRDeviceChannel::isRx() {
return rx;
}
void SDRDeviceChannel::setRx(bool rx) {
this->rx = rx;
}
SDRDeviceRange &SDRDeviceChannel::getGain() {
return rangeGain;
}
SDRDeviceRange &SDRDeviceChannel::getLNAGain() {
return rangeLNA;
}
SDRDeviceRange &SDRDeviceChannel::getFreqRange() {
return rangeFull;
}
SDRDeviceRange &SDRDeviceChannel::getRFRange() {
return rangeRF;
}
void SDRDeviceChannel::addGain(SDRDeviceRange range) {
gainInfo.push_back(range);
}
std::vector<SDRDeviceRange> &SDRDeviceChannel::getGains() {
return gainInfo;
}
void SDRDeviceChannel::addGain(std::string name, SoapySDR::Range range) {
gainInfo.push_back(SDRDeviceRange(name,range.minimum(),range.maximum()));
}
std::vector<long> &SDRDeviceChannel::getSampleRates() {
return sampleRates;
}
long SDRDeviceChannel::getSampleRateNear(long sampleRate_in) {
long returnRate = sampleRates[0];
long sDelta = (long)sampleRate_in-sampleRates[0];
long minDelta = std::abs(sDelta);
for (std::vector<long>::iterator i = sampleRates.begin(); i != sampleRates.end(); i++) {
long thisDelta = std::abs(sampleRate_in - (*i));
if (thisDelta < minDelta) {
minDelta = thisDelta;
returnRate = (*i);
}
SDRDeviceInfo::~SDRDeviceInfo() {
if (soapyDevice != nullptr) {
SoapySDR::Device::unmake(soapyDevice);
}
return returnRate;
}
std::vector<long long> &SDRDeviceChannel::getFilterBandwidths() {
return filterBandwidths;
}
const bool& SDRDeviceChannel::hasHardwareDC() const {
return hardwareDC;
}
void SDRDeviceChannel::setHardwareDC(const bool& hardware) {
hardwareDC = hardware;
}
const bool& SDRDeviceChannel::hasCORR() const {
return hasCorr;
}
void SDRDeviceChannel::setCORR(const bool& hasCorr) {
this->hasCorr = hasCorr;
}
void SDRDeviceChannel::setStreamArgsInfo(SoapySDR::ArgInfoList streamArgs) {
streamArgInfo = streamArgs;
}
SoapySDR::ArgInfoList SDRDeviceChannel::getStreamArgsInfo() {
return streamArgInfo;
}
std::vector<std::string> SDRDeviceChannel::getStreamArgNames() {
std::vector<std::string> names;
for (SoapySDR::ArgInfoList::const_iterator i = streamArgInfo.begin(); i != streamArgInfo.end(); i++) {
names.push_back((*i).key);
}
return names;
}
SDRDeviceInfo::SDRDeviceInfo() : name(""), serial(""), available(false), remote(false), manual(false) {
}
std::string SDRDeviceInfo::getDeviceId() {
@ -294,48 +141,66 @@ SoapySDR::Kwargs SDRDeviceInfo::getStreamArgs() {
return streamArgs;
}
void SDRDeviceInfo::setSettingsInfo(SoapySDR::ArgInfoList settingsArgs) {
settingInfo = settingsArgs;
}
SoapySDR::ArgInfoList SDRDeviceInfo::getSettingsArgInfo() {
return settingInfo;
}
std::vector<std::string> SDRDeviceInfo::getSettingNames() {
std::vector<std::string> names;
for (SoapySDR::ArgInfoList::const_iterator i = settingInfo.begin(); i != settingInfo.end(); i++) {
names.push_back((*i).key);
void SDRDeviceInfo::setSoapyDevice(SoapySDR::Device *dev) {
if (soapyDevice) {
SoapySDR::Device::unmake(soapyDevice);
}
return names;
soapyDevice = dev;
}
void SDRDeviceInfo::addChannel(SDRDeviceChannel *chan) {
channels.push_back(chan);
SoapySDR::Device *SDRDeviceInfo::getSoapyDevice() {
if (soapyDevice == nullptr) {
soapyDevice = SoapySDR::Device::make(deviceArgs);
}
return soapyDevice;
}
std::vector<SDRDeviceChannel *> &SDRDeviceInfo::getChannels() {
return channels;
bool SDRDeviceInfo::hasCORR(int direction, size_t channel) {
SoapySDR::Device *dev = getSoapyDevice();
std::vector<std::string> freqs = dev->listFrequencies(direction, channel);
if (std::find(freqs.begin(), freqs.end(), "CORR") != freqs.end()) {
return true;
} else {
return false;
}
}
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);
std::vector<long> SDRDeviceInfo::getSampleRates(int direction, size_t channel) {
SoapySDR::Device *dev = getSoapyDevice();
std::vector<long> result;
std::vector<double> sampleRates = dev->listSampleRates(direction, channel);
for (std::vector<double>::iterator si = sampleRates.begin(); si != sampleRates.end(); si++) {
result.push_back((long)(*si));
}
return result;
}
long SDRDeviceInfo::getSampleRateNear(int direction, size_t channel, long sampleRate_in) {
std::vector<long> sampleRates = getSampleRates(direction, channel);
long returnRate = sampleRates[0];
long sDelta = (long)sampleRate_in-sampleRates[0];
long minDelta = std::abs(sDelta);
for (std::vector<long>::iterator i = sampleRates.begin(); i != sampleRates.end(); i++) {
long thisDelta = std::abs(sampleRate_in - (*i));
if (thisDelta < minDelta) {
minDelta = thisDelta;
returnRate = (*i);
}
}
return NULL;
return returnRate;
}
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);
}
SDRRangeMap SDRDeviceInfo::getGains(int direction, size_t channel) {
SoapySDR::Device *dev = getSoapyDevice();
std::vector<std::string> gainNames = dev->listGains(direction, channel);
std::map<std::string, SoapySDR::Range> gainMap;
for (std::vector<std::string>::iterator gname = gainNames.begin(); gname!= gainNames.end(); gname++) {
gainMap[(*gname)] = dev->getGainRange(direction, channel, (*gname));
}
return NULL;
return gainMap;
}

View File

@ -4,84 +4,19 @@
#include <vector>
#include <SoapySDR/Types.hpp>
#include <SoapySDR/Device.hpp>
typedef struct _SDRManualDef {
std::string factory;
std::string params;
} SDRManualDef;
class SDRDeviceRange {
public:
SDRDeviceRange();
SDRDeviceRange(double low, double high);
SDRDeviceRange(std::string name, double low, double high);
double getLow();
void setLow(double low);
double getHigh();
void setHigh(double high);
std::string getName();
void setName(std::string name);
private:
std::string name;
double low, high;
};
class SDRDeviceChannel {
public:
SDRDeviceChannel();
~SDRDeviceChannel();
int getChannel();
void setChannel(int channel);
bool isFullDuplex();
void setFullDuplex(bool fullDuplex);
bool isTx();
void setTx(bool tx);
bool isRx();
void setRx(bool rx);
void addGain(SDRDeviceRange range);
void addGain(std::string name, SoapySDR::Range range);
std::vector<SDRDeviceRange> &getGains();
SDRDeviceRange &getGain();
SDRDeviceRange &getLNAGain();
SDRDeviceRange &getFreqRange();
SDRDeviceRange &getRFRange();
std::vector<long> &getSampleRates();
long getSampleRateNear(long sampleRate_in);
std::vector<long long> &getFilterBandwidths();
const bool& hasHardwareDC() const;
void setHardwareDC(const bool& hardware);
const bool& hasCORR() const;
void setCORR(const bool& corr);
void setStreamArgsInfo(SoapySDR::ArgInfoList streamArgs);
SoapySDR::ArgInfoList getStreamArgsInfo();
std::vector<std::string> getStreamArgNames();
private:
int channel;
bool fullDuplex, tx, rx, hardwareDC, hasCorr;
SDRDeviceRange rangeGain, rangeLNA, rangeFull, rangeRF;
std::vector<long> sampleRates;
std::vector<long long> filterBandwidths;
SoapySDR::ArgInfoList streamArgInfo;
std::vector<SDRDeviceRange> gainInfo;
};
typedef std::map<std::string, SoapySDR::Range> SDRRangeMap;
class SDRDeviceInfo {
public:
SDRDeviceInfo();
~SDRDeviceInfo();
std::string getDeviceId();
@ -123,11 +58,6 @@ public:
void setManualParams(std::string manualParams);
std::string getManualParams();
void addChannel(SDRDeviceChannel *chan);
std::vector<SDRDeviceChannel *> &getChannels();
SDRDeviceChannel * getRxChannel();
SDRDeviceChannel * getTxChannel();
void setDeviceArgs(SoapySDR::Kwargs deviceArgs);
SoapySDR::Kwargs getDeviceArgs();
@ -135,11 +65,22 @@ public:
void setStreamArgs(SoapySDR::Kwargs deviceArgs);
SoapySDR::Kwargs getStreamArgs();
void setSettingsInfo(SoapySDR::ArgInfoList settingsArgs);
SoapySDR::ArgInfoList getSettingsArgInfo();
// void setSettingsInfo(SoapySDR::ArgInfoList settingsArgs);
// SoapySDR::ArgInfoList getSettingsArgInfo();
std::vector<std::string> getSettingNames();
// std::vector<std::string> getSettingNames();
void setSoapyDevice(SoapySDR::Device *dev);
SoapySDR::Device *getSoapyDevice();
bool hasCORR(int direction, size_t channel);
std::vector<long> getSampleRates(int direction, size_t channel);
long getSampleRateNear(int direction, size_t channel, long sampleRate_in);
SDRRangeMap getGains(int direction, size_t channel);
private:
int index;
std::string name, serial, product, manufacturer, tuner;
@ -147,6 +88,5 @@ private:
bool timestamps, available, remote, manual;
SoapySDR::Kwargs deviceArgs, streamArgs;
SoapySDR::ArgInfoList settingInfo;
std::vector<SDRDeviceChannel *> channels;
SoapySDR::Device *soapyDevice;
};

View File

@ -273,67 +273,66 @@ std::vector<SDRDeviceInfo *> *SDREnumerator::enumerate_devices(std::string remot
}
dev->setDeviceArgs(deviceArgs);
dev->setSettingsInfo(settingsInfo);
// dev->setSettingsInfo(settingsInfo);
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<std::string> freqs = device->listFrequencies(SOAPY_SDR_RX,i);
if (std::find(freqs.begin(), freqs.end(), "CORR") != freqs.end()) {
chan->setCORR(true);
} else {
chan->setCORR(false);
}
if (device->hasDCOffsetMode(SOAPY_SDR_RX, i)) {
chan->setHardwareDC(true);
} else {
chan->setHardwareDC(false);
}
std::vector<double> rates = device->listSampleRates(SOAPY_SDR_RX, i);
for (std::vector<double>::iterator i = rates.begin(); i != rates.end(); i++) {
chan->getSampleRates().push_back((long)(*i));
}
ConfigSettings devStreamOpts = cfg->getStreamOpts();
if (devStreamOpts.size()) {
dev->setStreamArgs(devStreamOpts);
}
SoapySDR::ArgInfoList optArgs = device->getStreamArgsInfo(SOAPY_SDR_RX, i);
if (devStreamOpts.size()) {
for (int j = 0, jMax = optArgs.size(); j < jMax; j++) {
if (devStreamOpts.find(optArgs[j].key) != devStreamOpts.end()) {
optArgs[j].value = devStreamOpts[optArgs[j].key];
}
}
}
chan->setStreamArgsInfo(optArgs);
std::vector<std::string> gainNames = device->listGains(SOAPY_SDR_RX, i);
for (std::vector<std::string>::iterator gname = gainNames.begin(); gname!= gainNames.end(); gname++) {
chan->addGain((*gname),device->getGainRange(SOAPY_SDR_RX, i, (*gname)));
}
dev->addChannel(chan);
}
// 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<std::string> freqs = device->listFrequencies(SOAPY_SDR_RX,i);
// if (std::find(freqs.begin(), freqs.end(), "CORR") != freqs.end()) {
// chan->setCORR(true);
// } else {
// chan->setCORR(false);
// }
//
// if (device->hasDCOffsetMode(SOAPY_SDR_RX, i)) {
// chan->setHardwareDC(true);
// } else {
// chan->setHardwareDC(false);
// }
//
// std::vector<double> rates = device->listSampleRates(SOAPY_SDR_RX, i);
// for (std::vector<double>::iterator i = rates.begin(); i != rates.end(); i++) {
// chan->getSampleRates().push_back((long)(*i));
// }
//
// ConfigSettings devStreamOpts = cfg->getStreamOpts();
// if (devStreamOpts.size()) {
// dev->setStreamArgs(devStreamOpts);
// }
//
// SoapySDR::ArgInfoList optArgs = device->getStreamArgsInfo(SOAPY_SDR_RX, i);
//
// if (devStreamOpts.size()) {
// for (int j = 0, jMax = optArgs.size(); j < jMax; j++) {
// if (devStreamOpts.find(optArgs[j].key) != devStreamOpts.end()) {
// optArgs[j].value = devStreamOpts[optArgs[j].key];
// }
// }
// }
// chan->setStreamArgsInfo(optArgs);
//
// std::vector<std::string> gainNames = device->listGains(SOAPY_SDR_RX, i);
//
// for (std::vector<std::string>::iterator gname = gainNames.begin(); gname!= gainNames.end(); gname++) {
// chan->addGain((*gname),device->getGainRange(SOAPY_SDR_RX, i, (*gname)));
// }
//
// dev->addChannel(chan);
// }
SoapySDR::Device::unmake(device);
dev->setAvailable(true);
} catch (const std::exception &ex) {
std::cerr << "Error making device: " << ex.what() << std::endl;

View File

@ -73,7 +73,7 @@ void SDRThread::init() {
wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Initializing device."));
device = SoapySDR::Device::make(args);
device = devInfo->getSoapyDevice();
SoapySDR::Kwargs currentStreamArgs = combineArgs(devInfo->getStreamArgs(),streamArgs);
stream = device->setupStream(SOAPY_SDR_RX,"CF32", std::vector<size_t>(), currentStreamArgs);
@ -90,17 +90,16 @@ void SDRThread::init() {
device->setSampleRate(SOAPY_SDR_RX,0,sampleRate.load());
device->setFrequency(SOAPY_SDR_RX,0,"RF",frequency - offset.load());
device->activateStream(stream);
SDRDeviceChannel *chan = devInfo->getRxChannel();
if (chan->hasCORR()) {
if (devInfo->hasCORR(SOAPY_SDR_RX, 0)) {
hasPPM.store(true);
device->setFrequency(SOAPY_SDR_RX,0,"CORR",ppm.load());
} else {
hasPPM.store(false);
}
if (chan->hasHardwareDC()) {
if (device->hasDCOffsetMode(SOAPY_SDR_RX, 0)) {
hasHardwareDC.store(true);
// wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Found hardware DC offset correction support, internal disabled."));
device->setDCOffsetMode(SOAPY_SDR_RX, chan->getChannel(), true);
device->setDCOffsetMode(SOAPY_SDR_RX, 0, true);
} else {
hasHardwareDC.store(false);
}
@ -139,7 +138,7 @@ void SDRThread::init() {
}
setting_value_changed.store(false);
SoapySDR::ArgInfoList devSettings = deviceInfo.load()->getSettingsArgInfo();
SoapySDR::ArgInfoList devSettings = deviceInfo.load()->getSoapyDevice()->getSettingInfo();
if (devSettings.size()) {
for (size_t j = 0; j < settingsInfo.size(); j++) {
if (settings.find(settingsInfo[j].key) != settings.end()) {
@ -147,7 +146,7 @@ void SDRThread::init() {
}
}
}
deviceInfo.load()->setSettingsInfo(devSettings);
// deviceInfo.load()->setSettingsInfo(devSettings);
setting_busy.unlock();
@ -155,9 +154,10 @@ void SDRThread::init() {
}
void SDRThread::deinit() {
SDRDeviceInfo *devInfo = deviceInfo.load();
device->deactivateStream(stream);
device->closeStream(stream);
SoapySDR::Device::unmake(device);
devInfo->setSoapyDevice(nullptr);
free(buffs[0]);
}
@ -247,10 +247,10 @@ void SDRThread::updateGains() {
gainValues.erase(gainValues.begin(),gainValues.end());
gainChanged.erase(gainChanged.begin(),gainChanged.end());
std::vector<SDRDeviceRange> gains = devInfo->getRxChannel()->getGains();
for (std::vector<SDRDeviceRange>::iterator gi = gains.begin(); gi != gains.end(); gi++) {
gainValues[(*gi).getName()] = device->getGain(SOAPY_SDR_RX, devInfo->getRxChannel()->getChannel(), (*gi).getName());
gainChanged[(*gi).getName()] = false;
SDRRangeMap gains = devInfo->getGains(SOAPY_SDR_RX, 0);
for (SDRRangeMap::iterator gi = gains.begin(); gi != gains.end(); gi++) {
gainValues[gi->first] = device->getGain(SOAPY_SDR_RX, 0, gi->first);
gainChanged[gi->first] = false;
}
gain_value_changed.store(false);
@ -304,9 +304,7 @@ void SDRThread::updateSettings() {
// }
if (agc_mode_changed.load()) {
SDRDeviceInfo *devInfo = deviceInfo.load();
device->setGainMode(SOAPY_SDR_RX,devInfo->getRxChannel()->getChannel(),agc_mode.load());
device->setGainMode(SOAPY_SDR_RX, 0, agc_mode.load());
agc_mode_changed.store(false);
if (!agc_mode.load()) {
updateGains();
@ -314,12 +312,10 @@ void SDRThread::updateSettings() {
}
if (gain_value_changed.load() && !agc_mode.load()) {
SDRDeviceInfo *devInfo = deviceInfo.load();
gain_busy.lock();
for (std::map<std::string,bool>::iterator gci = gainChanged.begin(); gci != gainChanged.end(); gci++) {
if (gci->second) {
device->setGain(SOAPY_SDR_RX, devInfo->getRxChannel()->getChannel(), gci->first, gainValues[gci->first]);
device->setGain(SOAPY_SDR_RX, 0, gci->first, gainValues[gci->first]);
gainChanged[gci->first] = false;
}
}

View File

@ -184,8 +184,8 @@ void GainCanvas::updateGainUI() {
SDRDeviceInfo *devInfo = wxGetApp().getDevice();
std::vector<SDRDeviceRange> &gains = devInfo->getRxChannel()->getGains();
std::vector<SDRDeviceRange>::iterator gi;
SDRRangeMap gains = devInfo->getGains(SOAPY_SDR_RX, 0);
SDRRangeMap::iterator gi;
numGains = gains.size();
float i = 0;
@ -217,9 +217,9 @@ void GainCanvas::updateGainUI() {
GainInfo *gInfo = new GainInfo;
float midPos = -1.0+startPos+spacing*i;
gInfo->name = (*gi).getName();
gInfo->low = (*gi).getLow();
gInfo->high = (*gi).getHigh();
gInfo->name = gi->first;
gInfo->low = gi->second.minimum();
gInfo->high = gi->second.maximum();
gInfo->current = wxGetApp().getGain(gInfo->name);
gInfo->panel.setBorderPx(1);
@ -251,7 +251,7 @@ void GainCanvas::updateGainUI() {
gInfo->labelPanel.setSize(spacing/2.0,(15.0/float(ClientSize.y)));
gInfo->labelPanel.setPosition(midPos, -barHeight-(20.0/float(ClientSize.y)));
gInfo->labelPanel.setText((*gi).getName());
gInfo->labelPanel.setText(gi->first);
gInfo->labelPanel.setFill(GLPanel::GLPANEL_FILL_NONE);
bgPanel.addChild(&(gInfo->labelPanel));