Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/SoapyRateTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void runRateTestStreamLoop(
std::cout << "Starting stream loop, press Ctrl+C to exit..." << std::endl;
device->activateStream(stream);
signal(SIGINT, sigIntHandler);
while (not loopDone)
while (!loopDone)
{
int ret(0);
int flags(0);
Expand Down Expand Up @@ -129,8 +129,8 @@ int SoapySDRRateTest(

//parse the direction to the integer enum
int direction(-1);
if (directionStr == "RX" or directionStr == "rx") direction = SOAPY_SDR_RX;
if (directionStr == "TX" or directionStr == "tx") direction = SOAPY_SDR_TX;
if (directionStr == "RX" || directionStr == "rx") direction = SOAPY_SDR_RX;
if (directionStr == "TX" || directionStr == "tx") direction = SOAPY_SDR_TX;
if (direction == -1) throw std::invalid_argument("direction not in RX/TX: " + directionStr);

//build channels list, using KwargsFromString is a easy parsing hack
Expand Down
58 changes: 29 additions & 29 deletions apps/SoapySDRProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ std::string toString(const std::vector<Type> &options)
if (options.empty()) return "";
for (size_t i = 0; i < options.size(); i++)
{
if (not ss.str().empty()) ss << ", ";
if (!ss.str().empty()) ss << ", ";
ss << options[i];
}
return ss.str();
Expand All @@ -34,12 +34,12 @@ std::string toString(const SoapySDR::RangeList &range, const double scale)
std::stringstream ss;
for (size_t i = 0; i < range.size(); i++)
{
if (range.size() >= MAXRLEN and i >= MAXRLEN/2 and i < (range.size()-MAXRLEN/2))
if (range.size() >= MAXRLEN && i >= MAXRLEN/2 && i < (range.size()-MAXRLEN/2))
{
if (i == MAXRLEN) ss << ", ...";
continue;
}
if (not ss.str().empty()) ss << ", ";
if (!ss.str().empty()) ss << ", ";
if (range[i].minimum() == range[i].maximum()) ss << (range[i].minimum()/scale);
else ss << "[" << (range[i].minimum()/scale) << ", " << (range[i].maximum()/scale) << "]";
}
Expand All @@ -58,7 +58,7 @@ std::string toString(const std::vector<double> &nums, const double scale)

for (size_t i = 0; i < nums.size(); i++)
{
if (not ss.str().empty()) ss << ", ";
if (!ss.str().empty()) ss << ", ";
ss << (nums[i]/scale);
}
return "[" + ss.str() + "]";
Expand All @@ -80,12 +80,12 @@ std::string toString(const SoapySDR::ArgInfo &argInfo, const std::string indent
{
desc.replace(pos, 1, replace);
}
if (not desc.empty()) ss << " - " << desc << std::endl << indent << " ";
if (!desc.empty()) ss << " - " << desc << std::endl << indent << " ";

//other fields
ss << " [key=" << argInfo.key;
if (not argInfo.units.empty()) ss << ", units=" << argInfo.units;
if (not argInfo.value.empty()) ss << ", default=" << argInfo.value;
if (!argInfo.units.empty()) ss << ", units=" << argInfo.units;
if (!argInfo.value.empty()) ss << ", default=" << argInfo.value;

//type
switch (argInfo.type)
Expand All @@ -98,7 +98,7 @@ std::string toString(const SoapySDR::ArgInfo &argInfo, const std::string indent

//optional range/enumeration
if (argInfo.range.minimum() < argInfo.range.maximum()) ss << ", range=" << toString(argInfo.range);
if (not argInfo.options.empty()) ss << ", options=(" << toString(argInfo.options) << ")";
if (!argInfo.options.empty()) ss << ", options=(" << toString(argInfo.options) << ")";

ss << "]";

Expand Down Expand Up @@ -133,14 +133,14 @@ std::string sensorReadings(SoapySDR::Device *device)
std::string reading = device->readSensor(key);

ss << " * " << sensors[i];
if (not info.name.empty()) ss << " (" << info.name << ")";
if (!info.name.empty()) ss << " (" << info.name << ")";
ss << ":";
if (info.range.maximum() > std::numeric_limits<double>::min()) ss << toString(info.range);
ss << toString(info.options);
ss << " " << reading;
if (not info.units.empty()) ss << " " << info.units;
if (!info.units.empty()) ss << " " << info.units;
ss << std::endl;
if (not info.description.empty()) ss << " " << info.description << std::endl;
if (!info.description.empty()) ss << " " << info.description << std::endl;
}

return ss.str();
Expand All @@ -162,14 +162,14 @@ std::string channelSensorReadings(SoapySDR::Device *device, const int dir, const
std::string reading = device->readSensor(dir, chan, key);

ss << " * " << sensors[i];
if (not info.name.empty()) ss << " (" << info.name << ")";
if (!info.name.empty()) ss << " (" << info.name << ")";
ss << ":";
if (info.range.maximum() > std::numeric_limits<double>::min()) ss << toString(info.range);
ss << toString(info.options);
ss << " " << reading;
if (not info.units.empty()) ss << " " << info.units;
if (!info.units.empty()) ss << " " << info.units;
ss << std::endl;
if (not info.description.empty()) ss << " " << info.description << std::endl;
if (!info.description.empty()) ss << " " << info.description << std::endl;
}

return ss.str();
Expand Down Expand Up @@ -201,7 +201,7 @@ static std::string probeChannel(SoapySDR::Device *device, const int dir, const s

//formats
std::string formats = toString(device->getStreamFormats(dir, chan));
if (not formats.empty()) ss << " Stream formats: " << formats << std::endl;
if (!formats.empty()) ss << " Stream formats: " << formats << std::endl;

//native
double fullScale = 0.0;
Expand All @@ -210,19 +210,19 @@ static std::string probeChannel(SoapySDR::Device *device, const int dir, const s

//stream args
std::string streamArgs = toString(device->getStreamArgsInfo(dir, chan));
if (not streamArgs.empty()) ss << " Stream args:" << std::endl << streamArgs;
if (!streamArgs.empty()) ss << " Stream args:" << std::endl << streamArgs;

//antennas
std::string antennas = toString(device->listAntennas(dir, chan));
if (not antennas.empty()) ss << " Antennas: " << antennas << std::endl;
if (!antennas.empty()) ss << " Antennas: " << antennas << std::endl;

//corrections
std::vector<std::string> correctionsList;
if (device->hasDCOffsetMode(dir, chan)) correctionsList.push_back("DC removal");
if (device->hasDCOffset(dir, chan)) correctionsList.push_back("DC offset");
if (device->hasIQBalance(dir, chan)) correctionsList.push_back("IQ balance");
std::string corrections = toString(correctionsList);
if (not corrections.empty()) ss << " Corrections: " << corrections << std::endl;
if (!corrections.empty()) ss << " Corrections: " << corrections << std::endl;

//gains
ss << " Full gain range: " << toString(device->getGainRange(dir, chan)) << " dB" << std::endl;
Expand All @@ -244,23 +244,23 @@ static std::string probeChannel(SoapySDR::Device *device, const int dir, const s

//freq args
std::string freqArgs = toString(device->getFrequencyArgsInfo(dir, chan));
if (not freqArgs.empty()) ss << " Tune args:" << std::endl << freqArgs;
if (!freqArgs.empty()) ss << " Tune args:" << std::endl << freqArgs;

//rates
ss << " Sample rates: " << toString(device->getSampleRateRange(dir, chan), 1e6) << " MSps" << std::endl;

//bandwidths
const auto bws = device->getBandwidthRange(dir, chan);
if (not bws.empty()) ss << " Filter bandwidths: " << toString(bws, 1e6) << " MHz" << std::endl;
if (!bws.empty()) ss << " Filter bandwidths: " << toString(bws, 1e6) << " MHz" << std::endl;

//sensors
std::string sensors = toString(device->listSensors(dir, chan));
if (not sensors.empty()) ss << " Sensors: " << sensors << std::endl;
if (!sensors.empty()) ss << " Sensors: " << sensors << std::endl;
ss << channelSensorReadings(device, dir, chan);

//settings
std::string settings = toString(device->getSettingInfo(dir, chan));
if (not settings.empty()) ss << " Other Settings:" << std::endl << settings;
if (!settings.empty()) ss << " Other Settings:" << std::endl << settings;

return ss.str();
}
Expand Down Expand Up @@ -299,26 +299,26 @@ std::string SoapySDRDeviceProbe(SoapySDR::Device *device)
ss << " Timestamps: " << (device->hasHardwareTime()?"YES":"NO") << std::endl;

std::string clockSources = toString(device->listClockSources());
if (not clockSources.empty()) ss << " Clock sources: " << clockSources << std::endl;
if (!clockSources.empty()) ss << " Clock sources: " << clockSources << std::endl;

std::string timeSources = toString(device->listTimeSources());
if (not timeSources.empty()) ss << " Time sources: " << timeSources << std::endl;
if (!timeSources.empty()) ss << " Time sources: " << timeSources << std::endl;

std::string sensors = toString(device->listSensors());
if (not sensors.empty()) ss << " Sensors: " << sensors << std::endl;
if (!sensors.empty()) ss << " Sensors: " << sensors << std::endl;
ss << sensorReadings(device);

std::string registers = toString(device->listRegisterInterfaces());
if (not registers.empty()) ss << " Registers: " << registers << std::endl;
if (!registers.empty()) ss << " Registers: " << registers << std::endl;

std::string settings = toString(device->getSettingInfo());
if (not settings.empty()) ss << " Other Settings:" << std::endl << settings;
if (!settings.empty()) ss << " Other Settings:" << std::endl << settings;

std::string gpios = toString(device->listGPIOBanks());
if (not gpios.empty()) ss << " GPIOs: " << gpios << std::endl;
if (!gpios.empty()) ss << " GPIOs: " << gpios << std::endl;

std::string uarts = toString(device->listUARTs());
if (not uarts.empty()) ss << " UARTs: " << uarts << std::endl;
if (!uarts.empty()) ss << " UARTs: " << uarts << std::endl;

/*******************************************************************
* Per-channel info
Expand Down
16 changes: 8 additions & 8 deletions apps/SoapySDRUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ static int printInfo(void)
{
std::cout << "Module found: " << mod;
const auto &errMsg = SoapySDR::loadModule(mod);
if (not errMsg.empty()) std::cout << "\n " << errMsg;
if (!errMsg.empty()) std::cout << "\n " << errMsg;
const auto version = SoapySDR::getModuleVersion(mod);
if (not version.empty()) std::cout << std::string(maxPathLen-mod.size(), ' ') << " (" << version << ")";
if (!version.empty()) std::cout << std::string(maxPathLen-mod.size(), ' ') << " (" << version << ")";
std::cout << std::endl;
}
if (modules.empty()) std::cout << "No modules found!" << std::endl;
Expand All @@ -118,7 +118,7 @@ static int printInfo(void)
std::string factories;
for (const auto &it : SoapySDR::Registry::listFindFunctions())
{
if (not factories.empty()) factories += ", ";
if (!factories.empty()) factories += ", ";
factories += it.first;
}
if (factories.empty()) factories = "No factories found!";
Expand All @@ -130,7 +130,7 @@ static int printInfo(void)
std::string targets;
for (const auto &target : SoapySDR::ConverterRegistry::listTargetFormats(source))
{
if (not targets.empty()) targets += ", ";
if (!targets.empty()) targets += ", ";
targets += target;
}
std::cout << " - " << std::setw(5) << source << " -> [" << targets << "]" << std::endl;
Expand Down Expand Up @@ -235,7 +235,7 @@ static int watchDevice(const std::string &argStr)
try
{
auto device = SoapySDR::Device::make(argStr);
while (not loopDone)
while (!loopDone)
{
std::cout << sensorReadings(device) << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
Expand Down Expand Up @@ -374,15 +374,15 @@ int main(int argc, char *argv[])
}

//use serial if provided
if (not serial.empty())
if (!serial.empty())
{
auto args = SoapySDR::KwargsFromString(argStr);
args["serial"] = serial;
argStr = SoapySDR::KwargsToString(args);
}

if (not sparsePrintFlag) printBanner();
if (not driverName.empty()) return checkDriver(driverName);
if (!sparsePrintFlag) printBanner();
if (!driverName.empty()) return checkDriver(driverName);
if (findDevicesFlag) return findDevices(argStr, sparsePrintFlag);
if (makeDeviceFlag) return makeDevice(argStr);
if (probeDeviceFlag) return probeDevice(argStr);
Expand Down
6 changes: 0 additions & 6 deletions include/SoapySDR/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,3 @@

#pragma once
#include <SoapySDR/Config.h>

#if (defined(_MSVC_LANG) || __cplusplus < 201703L)
// For old or nonconforming compilers,
// using the alternative operator representations may require including this header.
#include <ciso646>
#endif
8 changes: 4 additions & 4 deletions include/SoapySDR/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ namespace Detail {
template <typename Type>
typename std::enable_if<std::is_same<Type, bool>::value, Type>::type StringToSetting(const std::string &s)
{
if (s.empty() or s == SOAPY_SDR_FALSE) {
if (s.empty() || s == SOAPY_SDR_FALSE) {
return false;
}
if (s == SOAPY_SDR_TRUE) {
Expand All @@ -189,21 +189,21 @@ typename std::enable_if<std::is_same<Type, bool>::value, Type>::type StringToSet

// Either the input wasn't numeric, so str_end should point to the front of the string,
// or the whole string was consumed and the resulting number is non-zero.
return (s == str_end) or ((d != 0.0) and (std::strlen(str_end) == 0));
return (s == str_end) || ((d != 0.0) && (std::strlen(str_end) == 0));
} catch (std::invalid_argument&) {
}
// other values are true
return true;
}

template <typename Type>
typename std::enable_if<not std::is_same<Type, bool>::value and std::is_integral<Type>::value and std::is_signed<Type>::value, Type>::type StringToSetting(const std::string &s)
typename std::enable_if<!std::is_same<Type, bool>::value && std::is_integral<Type>::value && std::is_signed<Type>::value, Type>::type StringToSetting(const std::string &s)
{
return Type(std::stoll(s));
}

template <typename Type>
typename std::enable_if<not std::is_same<Type, bool>::value and std::is_integral<Type>::value and std::is_unsigned<Type>::value, Type>::type StringToSetting(const std::string &s)
typename std::enable_if<!std::is_same<Type, bool>::value && std::is_integral<Type>::value && std::is_unsigned<Type>::value, Type>::type StringToSetting(const std::string &s)
{
return Type(std::stoull(s));
}
Expand Down
12 changes: 6 additions & 6 deletions lib/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ bool SoapySDR::Device::getFullDuplex(const int, const size_t) const
{
auto numRxChs = this->getNumChannels(SOAPY_SDR_RX);
auto numTxChs = this->getNumChannels(SOAPY_SDR_TX);
if (numRxChs > 0 and numTxChs == 0) return false; //no tx channels
if (numRxChs == 0 and numTxChs > 0) return false; //no rx channels
if (numRxChs > 0 && numTxChs == 0) return false; //no tx channels
if (numRxChs == 0 && numTxChs > 0) return false; //no rx channels
return true; //assume full duplex (usually true minus some tdd devices)
}

Expand Down Expand Up @@ -373,11 +373,11 @@ void SoapySDR::Device::setFrequency(const int dir, const size_t chan, double fre
//add offset for RF element (first element)
if (comp_i == 0) freq += offset;

if (args.count(name) != 0 and args.at(name) == "IGNORE")
if (args.count(name) != 0 && args.at(name) == "IGNORE")
{
//do nothing, dont change component
}
else if (args.count(name) != 0 and args.at(name) != "DEFAULT")
else if (args.count(name) != 0 && args.at(name) != "DEFAULT")
{
//specific frequency for component specified
const double f(std::atof(args.at(name).c_str()));
Expand Down Expand Up @@ -485,7 +485,7 @@ SoapySDR::ArgInfoList SoapySDR::Device::getFrequencyArgsInfo(const int dir, cons
info.type = SoapySDR::ArgInfo::FLOAT;
info.description = "Tune the LO with an offset and compensate with the baseband CORDIC.";
SoapySDR::RangeList ranges = this->getFrequencyRange(dir, chan, comps.at(1));
if (not ranges.empty()) info.range = ranges.front();
if (!ranges.empty()) info.range = ranges.front();
args.push_back(info);
}

Expand All @@ -503,7 +503,7 @@ SoapySDR::ArgInfoList SoapySDR::Device::getFrequencyArgsInfo(const int dir, cons
info.options.push_back("IGNORE");
info.optionNames.push_back("Ignore");
SoapySDR::RangeList ranges = this->getFrequencyRange(dir, chan, comps.at(comp_i));
if (not ranges.empty()) info.range = ranges.front();
if (!ranges.empty()) info.range = ranges.front();
args.push_back(info);
}

Expand Down
Loading