1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

PlutoSDR: added read param method to device box

This commit is contained in:
f4exb 2017-09-05 15:06:40 +02:00
parent b411ba5420
commit 8ab3ad3b63
2 changed files with 37 additions and 0 deletions

View File

@ -106,6 +106,42 @@ void DevicePlutoSDRBox::set_params(DeviceType devType,
}
}
bool DevicePlutoSDRBox::get_param(DeviceType devType, const std::string &param, std::string &value)
{
struct iio_channel *chn = 0;
const char *attr = 0;
char valuestr[256];
int ret;
ssize_t nchars;
ret = iio_device_identify_filename(dev, param.c_str(), &chn, &attr);
if (ret)
{
std::cerr << "PlutoSDRDevice::get_param: Parameter not recognized: " << param << std::endl;
return false;
}
if (chn) {
nchars = iio_channel_attr_read(chn, attr, valuestr, 256);
} else if (iio_device_find_attr(dev, attr)) {
nchars = iio_device_attr_read(dev, attr, valuestr, 256);
} else {
nchars = iio_device_debug_attr_read(dev, attr, valuestr, 256);
}
if (nchars < 0)
{
std::cerr << "PlutoSDRDevice::get_param: Unable to read attribute " << param << ": " << nchars << std::endl;
return false;
}
else
{
value.assign(valuestr);
return true;
}
}
bool DevicePlutoSDRBox::openRx()
{
if (!m_chnRx0) {

View File

@ -39,6 +39,7 @@ public:
bool isValid() const { return m_valid; }
void set_params(DeviceType devType, const std::vector<std::string> &params);
bool get_param(DeviceType devType, const std::string &param, std::string &value);
bool openRx();
bool openTx();
void closeRx();