Skip to content

Commit

Permalink
added label option
Browse files Browse the repository at this point in the history
added device option
move hardware info to getHardwareInfo
  • Loading branch information
jocover committed Aug 26, 2017
1 parent 5f41f91 commit 78ff1e1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 25 deletions.
42 changes: 21 additions & 21 deletions PlutoSDR_Registation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ static std::vector<SoapySDR::Kwargs> find_PlutoSDR(const SoapySDR::Kwargs &args)
SoapySDR::Kwargs options;

scan_ctx = iio_create_scan_context(NULL, 0);

char label_str[100];
//Skipping broken USB device
ret = iio_scan_context_get_info_list(scan_ctx, &info);

if(ret < 0) {
SoapySDR_logf(SOAPY_SDR_ERROR, "Unable to scan: %li\n", (long)ret);
iio_scan_context_destroy(scan_ctx);
return results;
}
options["device"] = "plutosdr";
if(ret == 0){

ctx=iio_create_network_context(PLUTOSDR_DEFAULT_IP);
if(ctx !=nullptr){
options["hostname"]=PLUTOSDR_DEFAULT_IP;

}else{
ctx=iio_create_network_context(PLUTOSDR_DEFAULT_HOSTNAME);
if(ctx !=nullptr){
Expand All @@ -29,31 +35,25 @@ static std::vector<SoapySDR::Kwargs> find_PlutoSDR(const SoapySDR::Kwargs &args)
return results;
}
}

}else if (ret == 1){

ctx = iio_create_context_from_uri(iio_context_info_get_uri(info[0]));
if (ctx != nullptr)
options["uri"] = std::string(iio_context_info_get_uri(info[0]));

sprintf(label_str, "%s #%d %s", options["device"].c_str(), 0, options["hostname"].c_str());
options["label"] = label_str;
results.push_back(options);
if (ctx != nullptr)iio_context_destroy(ctx);

}else{

//Multiple contexts found
for (int i = 0; i < ret; i++) {
ctx = iio_create_context_from_uri(iio_context_info_get_uri(info[i]));
if (ctx != nullptr) {
options["uri"] = std::string(iio_context_info_get_uri(info[i]));
sprintf(label_str, "%s #%d %s", options["device"].c_str(), i, options["uri"].c_str());
results.push_back(options);
if (ctx != nullptr)iio_context_destroy(ctx);
}

}

unsigned int nb_ctx_attrs = iio_context_get_attrs_count(ctx);
for (unsigned int i = 0; i < nb_ctx_attrs; i++){
const char *key, *value;
iio_context_get_attr(ctx, i, &key, &value);
options[key]=value;

}

results.push_back(options);

if (ctx!=nullptr)iio_context_destroy(ctx);

return results;
}

Expand Down
24 changes: 20 additions & 4 deletions PlutoSDR_Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,37 @@ SoapyPlutoSDR::~SoapyPlutoSDR(void){

std::string SoapyPlutoSDR::getDriverKey( void ) const
{

return("PlutoSDR");
unsigned int major, minor;
char git_tag[8];
iio_library_get_version(&major, &minor, git_tag);
char key_str[100];
sprintf(key_str, "Library version: %u.%u (git tag: %s)", major, minor, git_tag);
return(key_str);
}

std::string SoapyPlutoSDR::getHardwareKey( void ) const
{

return("PlutoSDR");
unsigned int major, minor;
char git_tag[8];
iio_context_get_version(ctx, &major, &minor, git_tag);
char key_str[100];
sprintf(key_str, "Backend version: %u.%u (git tag: %s)",major, minor, git_tag);
return(key_str);
}

SoapySDR::Kwargs SoapyPlutoSDR::getHardwareInfo( void ) const
{

SoapySDR::Kwargs info;

unsigned int nb_ctx_attrs = iio_context_get_attrs_count(ctx);
for (unsigned int i = 0; i < nb_ctx_attrs; i++) {
const char *key, *value;
iio_context_get_attr(ctx, i, &key, &value);
info[key] = value;

}

return info;
}

Expand Down

0 comments on commit 78ff1e1

Please sign in to comment.