SoapySDR 0.4.0 updates

- Requires up-to-date SoapySDR 0.4.x and re-built modules
This commit is contained in:
Charles J. Cliffe 2015-10-23 02:53:51 -04:00
parent 8e29fd5a98
commit b89d606af3
9 changed files with 96 additions and 85 deletions

View File

@ -82,7 +82,7 @@ find_package(wxWidgets COMPONENTS gl core base REQUIRED)
set(wxWidgets_CONFIGURATION mswu) set(wxWidgets_CONFIGURATION mswu)
include(${wxWidgets_USE_FILE}) include(${wxWidgets_USE_FILE})
find_package(SoapySDR NO_MODULE REQUIRED) find_package(SoapySDR "0.4.0" NO_MODULE REQUIRED)
include_directories(${SOAPY_SDR_INCLUDE_DIR}) include_directories(${SOAPY_SDR_INCLUDE_DIR})
SET(OTHER_LIBRARIES ${SOAPY_SDR_LIBRARY} ${OTHER_LIBRARIES}) SET(OTHER_LIBRARIES ${SOAPY_SDR_LIBRARY} ${OTHER_LIBRARIES})
ADD_DEFINITIONS( ADD_DEFINITIONS(
@ -181,7 +181,7 @@ ENDIF(USE_AUDIO_OSS)
ENDIF(UNIX AND NOT APPLE) ENDIF(UNIX AND NOT APPLE)
IF (APPLE) IF (APPLE)
SET(CMAKE_OSX_DEPLOYMENT_TARGET, "10.9") SET(CMAKE_OSX_DEPLOYMENT_TARGET, "10.10")
SET(FFTW_LIB fftw3f) SET(FFTW_LIB fftw3f)
SET(LIQUID_LIB liquid) SET(LIQUID_LIB liquid)
@ -415,7 +415,7 @@ ENDIF(MSVC)
IF (APPLE) IF (APPLE)
ADD_DEFINITIONS( ADD_DEFINITIONS(
-DHAVE_TYPE_TRAITS=1 -DHAVE_TYPE_TRAITS=1
-mmacosx-version-min=10.9 -mmacosx-version-min=10.10
) )
ENDIF(APPLE) ENDIF(APPLE)

View File

@ -363,13 +363,13 @@ int CubicSDR::getDirectSampling() {
} }
void CubicSDR::setSwapIQ(bool swapIQ) { void CubicSDR::setSwapIQ(bool swapIQ) {
sdrPostThread->setSwapIQ(swapIQ); sdrThread->setIQSwap(swapIQ);
SDRDeviceInfo *dev = getDevice(); SDRDeviceInfo *dev = getDevice();
config.getDevice(dev->getDeviceId())->setIQSwap(swapIQ); config.getDevice(dev->getDeviceId())->setIQSwap(swapIQ);
} }
bool CubicSDR::getSwapIQ() { bool CubicSDR::getSwapIQ() {
return sdrPostThread->getSwapIQ(); return sdrThread->getIQSwap();
} }
long long CubicSDR::getFrequency() { long long CubicSDR::getFrequency() {

View File

@ -111,8 +111,6 @@ void SDRDeviceChannel::setHardwareDC(const bool& hardware) {
hardwareDC = hardware; hardwareDC = hardware;
} }
const bool& SDRDeviceChannel::hasCORR() const { const bool& SDRDeviceChannel::hasCORR() const {
return hasCorr; return hasCorr;
} }
@ -121,6 +119,22 @@ void SDRDeviceChannel::setCORR(const bool& hasCorr) {
this->hasCorr = 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) { SDRDeviceInfo::SDRDeviceInfo() : name(""), serial(""), available(false) {
@ -232,6 +246,23 @@ SoapySDR::Kwargs SDRDeviceInfo::getStreamArgs() {
return streamArgs; 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);
}
return names;
}
void SDRDeviceInfo::addChannel(SDRDeviceChannel *chan) { void SDRDeviceInfo::addChannel(SDRDeviceChannel *chan) {
channels.push_back(chan); channels.push_back(chan);
} }

View File

@ -78,13 +78,17 @@ public:
const bool& hasCORR() const; const bool& hasCORR() const;
void setCORR(const bool& corr); void setCORR(const bool& corr);
void setStreamArgsInfo(SoapySDR::ArgInfoList streamArgs);
SoapySDR::ArgInfoList getStreamArgsInfo();
std::vector<std::string> getStreamArgNames();
private: private:
int channel; int channel;
bool fullDuplex, tx, rx, hardwareDC, hasCorr; bool fullDuplex, tx, rx, hardwareDC, hasCorr;
SDRDeviceRange rangeGain, rangeLNA, rangeFull, rangeRF; SDRDeviceRange rangeGain, rangeLNA, rangeFull, rangeRF;
std::vector<long> sampleRates; std::vector<long> sampleRates;
std::vector<long long> filterBandwidths; std::vector<long long> filterBandwidths;
SoapySDR::ArgInfoList streamArgInfo;
}; };
@ -135,6 +139,11 @@ public:
void setStreamArgs(SoapySDR::Kwargs deviceArgs); void setStreamArgs(SoapySDR::Kwargs deviceArgs);
SoapySDR::Kwargs getStreamArgs(); SoapySDR::Kwargs getStreamArgs();
void setSettingsInfo(SoapySDR::ArgInfoList settingsArgs);
SoapySDR::ArgInfoList getSettingsArgInfo();
std::vector<std::string> getSettingNames();
private: private:
int index; int index;
std::string name, serial, product, manufacturer, tuner; std::string name, serial, product, manufacturer, tuner;
@ -142,5 +151,6 @@ private:
bool timestamps, available; bool timestamps, available;
SoapySDR::Kwargs deviceArgs, streamArgs; SoapySDR::Kwargs deviceArgs, streamArgs;
SoapySDR::ArgInfoList settingInfo;
std::vector<SDRDeviceChannel *> channels; std::vector<SDRDeviceChannel *> channels;
}; };

View File

@ -88,30 +88,6 @@ std::vector<SDRDeviceInfo *> *SDREnumerator::enumerate_devices(std::string remot
results = SoapySDR::Device::enumerate(); results = SoapySDR::Device::enumerate();
} }
// Remote driver test..
/* * /
SDRDeviceInfo *remoteDev = new SDRDeviceInfo();
remoteDev->setDriver("remote");
remoteDev->setName("SoapySDR Remote Test");
SoapySDR::Kwargs remoteArgs;
remoteArgs["driver"] = "remote";
// remoteArgs["remote"] = "127.0.0.1";
remoteArgs["remote"] = "192.168.1.103";
remoteArgs["remote:driver"] = "rtlsdr";
remoteArgs["buffers"] = "6";
remoteArgs["buflen"] = "16384";
remoteDev->setDeviceArgs(remoteArgs);
SoapySDR::Kwargs streamArgs;
streamArgs["remote:mtu"] = "8192";
streamArgs["remote:format"] = "CS8";
streamArgs["remote:window"] = "16384000";
remoteDev->setStreamArgs(streamArgs);
SDRThread::devs.push_back(remoteDev);
// */
if (isRemote) { if (isRemote) {
wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Opening remote server ") + remoteAddr + ".."); wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Opening remote server ") + remoteAddr + "..");
} }
@ -134,11 +110,6 @@ std::vector<SDRDeviceInfo *> *SDREnumerator::enumerate_devices(std::string remot
wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Found local device #") + std::to_string(i)); wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Found local device #") + std::to_string(i));
} }
if (deviceArgs.count("rtl") != 0 || (deviceArgs.count("driver") != 0 && (deviceArgs["driver"] == "rtl" || deviceArgs["driver"] == "rtlsdr"))) {
streamArgs["buffers"] = "6";
streamArgs["buflen"] = "16384";
}
for (SoapySDR::Kwargs::const_iterator it = deviceArgs.begin(); it != deviceArgs.end(); ++it) { for (SoapySDR::Kwargs::const_iterator it = deviceArgs.begin(); it != deviceArgs.end(); ++it) {
std::cout << " " << it->first << " = " << it->second << std::endl; std::cout << " " << it->first << " = " << it->second << std::endl;
if (it->first == "driver") { if (it->first == "driver") {
@ -149,7 +120,7 @@ std::vector<SDRDeviceInfo *> *SDREnumerator::enumerate_devices(std::string remot
} }
dev->setDeviceArgs(deviceArgs); dev->setDeviceArgs(deviceArgs);
dev->setStreamArgs(deviceArgs); dev->setStreamArgs(streamArgs);
std::cout << "Make device " << i << std::endl; std::cout << "Make device " << i << std::endl;
try { try {
@ -193,10 +164,13 @@ std::vector<SDRDeviceInfo *> *SDREnumerator::enumerate_devices(std::string remot
for (std::vector<double>::iterator i = rates.begin(); i != rates.end(); i++) { for (std::vector<double>::iterator i = rates.begin(); i != rates.end(); i++) {
chan->getSampleRates().push_back((long)(*i)); chan->getSampleRates().push_back((long)(*i));
} }
chan->setStreamArgsInfo(device->getStreamArgsInfo(SOAPY_SDR_RX, i));
dev->addChannel(chan); dev->addChannel(chan);
} }
dev->setSettingsInfo(device->getSettingInfo());
SoapySDR::Device::unmake(device); SoapySDR::Device::unmake(device);

View File

@ -10,7 +10,6 @@ SDRPostThread::SDRPostThread() : IOThread() {
iqDataOutQueue = NULL; iqDataOutQueue = NULL;
iqVisualQueue = NULL; iqVisualQueue = NULL;
swapIQ.store(false);
numChannels = 0; numChannels = 0;
channelizer = NULL; channelizer = NULL;
@ -49,14 +48,6 @@ void SDRPostThread::removeDemodulator(DemodulatorInstance *demod) {
busy_demod.unlock(); busy_demod.unlock();
} }
void SDRPostThread::setSwapIQ(bool swapIQ) {
this->swapIQ.store(swapIQ);
}
bool SDRPostThread::getSwapIQ() {
return this->swapIQ.load();
}
void SDRPostThread::initPFBChannelizer() { void SDRPostThread::initPFBChannelizer() {
// std::cout << "Initializing post-process FIR polyphase filterbank channelizer with " << numChannels << " channels." << std::endl; // std::cout << "Initializing post-process FIR polyphase filterbank channelizer with " << numChannels << " channels." << std::endl;
if (channelizer) { if (channelizer) {
@ -191,17 +182,6 @@ void SDRPostThread::run() {
if (outSize != dataOut.size()) { if (outSize != dataOut.size()) {
dataOut.resize(outSize); dataOut.resize(outSize);
} }
// if (swapIQ) {
// for (int i = 0; i < dataSize; i++) {
// fpData[i] = _lut_swap[*((uint16_t*)&data_in->data[2*i])];
// }
// } else {
// for (int i = 0; i < dataSize; i++) {
// fpData[i] = _lut[*((uint16_t*)&data_in->data[2*i])];
// }
// }
int activeVisChannel = -1; int activeVisChannel = -1;
// if (visBandwidth.load() && visBandwidth.load() < (chanBw/2)) { // if (visBandwidth.load() && visBandwidth.load() < (chanBw/2)) {

View File

@ -14,9 +14,6 @@ public:
void bindDemodulator(DemodulatorInstance *demod); void bindDemodulator(DemodulatorInstance *demod);
void removeDemodulator(DemodulatorInstance *demod); void removeDemodulator(DemodulatorInstance *demod);
void setSwapIQ(bool swapIQ);
bool getSwapIQ();
void run(); void run();
void terminate(); void terminate();
@ -31,7 +28,6 @@ protected:
std::mutex busy_demod; std::mutex busy_demod;
std::vector<DemodulatorInstance *> demodulators; std::vector<DemodulatorInstance *> demodulators;
std::atomic_bool swapIQ;
private: private:
void initPFBChannelizer(); void initPFBChannelizer();

View File

@ -25,12 +25,14 @@ SDRThread::SDRThread() : IOThread() {
ppm_changed .store(false); ppm_changed .store(false);
direct_sampling_changed.store(false); direct_sampling_changed.store(false);
device_changed.store(false); device_changed.store(false);
iq_swap.store(false);
iq_swap_changed.store(false);
hasPPM.store(false); hasPPM.store(false);
hasHardwareDC.store(false); hasHardwareDC.store(false);
numChannels.store(8); numChannels.store(8);
hasDirectSampling.store(false);
// dcFilter = iirfilt_crcf_create_dc_blocker(0.0005); hasIQSwap.store(false);
} }
SDRThread::~SDRThread() { SDRThread::~SDRThread() {
@ -43,26 +45,20 @@ void SDRThread::init() {
DeviceConfig *devConfig = deviceConfig.load(); DeviceConfig *devConfig = deviceConfig.load();
ppm.store(devConfig->getPPM()); ppm.store(devConfig->getPPM());
ppm_changed.store(true);
direct_sampling_mode.store(devConfig->getDirectSampling()); direct_sampling_mode.store(devConfig->getDirectSampling());
direct_sampling_changed.store(true);
iq_swap.store(devConfig->getIQSwap());
iq_swap_changed.store(true);
std::string driverName = devInfo->getDriver(); std::string driverName = devInfo->getDriver();
offset = devConfig->getOffset(); offset = devConfig->getOffset();
wxGetApp().setSwapIQ(devConfig->getIQSwap());
SoapySDR::Kwargs args = devInfo->getDeviceArgs(); SoapySDR::Kwargs args = devInfo->getDeviceArgs();
args["direct_samp"] = std::to_string(devConfig->getDirectSampling());
if (driverName == "rtl" || driverName == "rtlsdr") {
args["iq_swap"] = std::to_string(devConfig->getIQSwap()?1:0);
args["buffers"] = "6";
args["buflen"] = "16384";
hasPPM = true;
} else {
hasPPM = false;
}
wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Initializing device.")); wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Initializing device."));
device = SoapySDR::Device::make(args); device = SoapySDR::Device::make(args);
stream = device->setupStream(SOAPY_SDR_RX,"CF32", std::vector<size_t>(), devInfo->getStreamArgs()); stream = device->setupStream(SOAPY_SDR_RX,"CF32", std::vector<size_t>(), devInfo->getStreamArgs());
@ -86,6 +82,14 @@ void SDRThread::init() {
hasHardwareDC.store(false); hasHardwareDC.store(false);
} }
std::vector<std::string> settingNames = devInfo->getSettingNames();
if (std::find(settingNames.begin(), settingNames.end(), "direct_samp") != settingNames.end()) {
hasDirectSampling.store(true);
}
if (std::find(settingNames.begin(), settingNames.end(), "iq_swap") != settingNames.end()) {
hasIQSwap.store(true);
}
device->setGainMode(SOAPY_SDR_RX,0,true); device->setGainMode(SOAPY_SDR_RX,0,true);
numChannels.store(getOptimalChannelCount(sampleRate.load())); numChannels.store(getOptimalChannelCount(sampleRate.load()));
@ -168,14 +172,19 @@ void SDRThread::readLoop() {
} }
if (ppm_changed.load() && hasPPM.load()) { if (ppm_changed.load() && hasPPM.load()) {
device->setFrequency(SOAPY_SDR_RX,0,"CORR",ppm.load()); device->setFrequency(SOAPY_SDR_RX,0,"CORR",ppm.load());
direct_sampling_changed.store(false); ppm_changed.store(false);
} }
if (freq_changed.load()) { if (freq_changed.load()) {
device->setFrequency(SOAPY_SDR_RX,0,"RF",frequency.load() - offset.load()); device->setFrequency(SOAPY_SDR_RX,0,"RF",frequency.load() - offset.load());
freq_changed.store(false); freq_changed.store(false);
} }
if (direct_sampling_changed.load()) { if (hasDirectSampling.load() && direct_sampling_changed.load()) {
// rtlsdr_set_direct_sampling(dev, direct_sampling_mode); device->writeSetting("direct_samp", std::to_string(direct_sampling_mode));
direct_sampling_changed.store(false);
}
if (hasIQSwap.load() && iq_swap_changed.load()) {
device->writeSetting("iq_swap", iq_swap.load()?"true":"false");
iq_swap_changed.store(false);
} }
readStream(iqDataOutQueue); readStream(iqDataOutQueue);
@ -302,3 +311,12 @@ void SDRThread::setDirectSampling(int dsMode) {
int SDRThread::getDirectSampling() { int SDRThread::getDirectSampling() {
return direct_sampling_mode.load(); return direct_sampling_mode.load();
} }
void SDRThread::setIQSwap(bool iqSwap) {
iq_swap.store(iqSwap);
iq_swap_changed.store(true);
}
bool SDRThread::getIQSwap() {
return iq_swap.load();
}

View File

@ -71,6 +71,9 @@ public:
void setDirectSampling(int dsMode); void setDirectSampling(int dsMode);
int getDirectSampling(); int getDirectSampling();
void setIQSwap(bool iqSwap);
bool getIQSwap();
protected: protected:
SoapySDR::Stream *stream; SoapySDR::Stream *stream;
@ -84,8 +87,7 @@ protected:
std::atomic<uint32_t> sampleRate; std::atomic<uint32_t> sampleRate;
std::atomic_llong frequency, offset; std::atomic_llong frequency, offset;
std::atomic_int ppm, direct_sampling_mode, numElems, numChannels; std::atomic_int ppm, direct_sampling_mode, numElems, numChannels;
std::atomic_bool hasPPM, hasHardwareDC; std::atomic_bool hasPPM, hasHardwareDC, hasDirectSampling, hasIQSwap;
std::atomic_bool iq_swap, rate_changed, freq_changed, offset_changed,
std::atomic_bool rate_changed, freq_changed, offset_changed, ppm_changed, direct_sampling_changed, device_changed, iq_swap_changed;
ppm_changed, direct_sampling_changed, device_changed;
}; };