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:
parent
b411ba5420
commit
8ab3ad3b63
@ -106,6 +106,42 @@ void DevicePlutoSDRBox::set_params(DeviceType devType,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DevicePlutoSDRBox::get_param(DeviceType devType, const std::string ¶m, 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()
|
bool DevicePlutoSDRBox::openRx()
|
||||||
{
|
{
|
||||||
if (!m_chnRx0) {
|
if (!m_chnRx0) {
|
||||||
|
@ -39,6 +39,7 @@ public:
|
|||||||
bool isValid() const { return m_valid; }
|
bool isValid() const { return m_valid; }
|
||||||
|
|
||||||
void set_params(DeviceType devType, const std::vector<std::string> ¶ms);
|
void set_params(DeviceType devType, const std::vector<std::string> ¶ms);
|
||||||
|
bool get_param(DeviceType devType, const std::string ¶m, std::string &value);
|
||||||
bool openRx();
|
bool openRx();
|
||||||
bool openTx();
|
bool openTx();
|
||||||
void closeRx();
|
void closeRx();
|
||||||
|
Loading…
Reference in New Issue
Block a user