aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorBen Hilburn <ben.hilburn@ettus.com>2014-03-14 10:52:59 -0700
committerBen Hilburn <ben.hilburn@ettus.com>2014-03-14 10:52:59 -0700
commitc34a548633d6e53479083175e99b127e638839b4 (patch)
tree17fc2c4111fa1031ff5c43f6100518161e56af61 /host/lib
parent973b47c48339dbae2e125a8c8d84ef67fedc4bdf (diff)
parent2a185eee04a4b7f7414392bd3cc10ad7db621014 (diff)
downloaduhd-c34a548633d6e53479083175e99b127e638839b4.tar.gz
uhd-c34a548633d6e53479083175e99b127e638839b4.tar.bz2
uhd-c34a548633d6e53479083175e99b127e638839b4.zip
Merge remote-tracking branch 'origin/mwest/gain_name_check'
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/multi_usrp.cpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp
index 182e774fc..d8322a39f 100644
--- a/host/lib/usrp/multi_usrp.cpp
+++ b/host/lib/usrp/multi_usrp.cpp
@@ -35,14 +35,20 @@ using namespace uhd::usrp;
const std::string multi_usrp::ALL_GAINS = "";
-UHD_INLINE std::string string_vector_to_string(std::vector<std::string> values, std::string delimeter = std::string(" "))
+UHD_INLINE std::string string_vector_to_string(std::vector<std::string> values, std::string delimiter = std::string(" "))
{
std::string out = "";
for (std::vector<std::string>::iterator iter = values.begin(); iter != values.end(); iter++)
- out += delimeter + *iter;
+ {
+ out += (iter != values.begin() ? delimiter : "") + *iter;
+ }
return out;
}
+#define THROW_GAIN_NAME_ERROR(name,chan,dir) throw uhd::exception::runtime_error( \
+ (boost::format("%s: gain \"%s\" not found for channel %d.\nAvailable gains: %s\n") % \
+ __FUNCTION__ % name % chan % string_vector_to_string(get_##dir##_gain_names(chan))).str());
+
/***********************************************************************
* Helper methods
**********************************************************************/
@@ -671,10 +677,7 @@ public:
try {
return rx_gain_group(chan)->set_value(gain, name);
} catch (uhd::key_error &e) {
- std::stringstream err;
- err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" <<
- "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl;
- throw uhd::exception::runtime_error(err.str());
+ THROW_GAIN_NAME_ERROR(name,chan,rx);
}
}
@@ -682,10 +685,7 @@ public:
try {
return rx_gain_group(chan)->get_value(name);
} catch (uhd::key_error &e) {
- std::stringstream err;
- err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" <<
- "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl;
- throw uhd::exception::runtime_error(err.str());
+ THROW_GAIN_NAME_ERROR(name,chan,rx);
}
}
@@ -693,10 +693,7 @@ public:
try {
return rx_gain_group(chan)->get_range(name);
} catch (uhd::key_error &e) {
- std::stringstream err;
- err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" <<
- "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl;
- throw uhd::exception::runtime_error(err.str());
+ THROW_GAIN_NAME_ERROR(name,chan,rx);
}
}
@@ -861,10 +858,7 @@ public:
try {
return tx_gain_group(chan)->set_value(gain, name);
} catch (uhd::key_error &e) {
- std::stringstream err;
- err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" <<
- "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl;
- throw uhd::exception::runtime_error(err.str());
+ THROW_GAIN_NAME_ERROR(name,chan,tx);
}
}
@@ -872,10 +866,7 @@ public:
try {
return tx_gain_group(chan)->get_value(name);
} catch (uhd::key_error &e) {
- std::stringstream err;
- err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" <<
- "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl;
- throw uhd::exception::runtime_error(err.str());
+ THROW_GAIN_NAME_ERROR(name,chan,tx);
}
}
@@ -883,10 +874,7 @@ public:
try {
return tx_gain_group(chan)->get_range(name);
} catch (uhd::key_error &e) {
- std::stringstream err;
- err << __FUNCTION__ << "(\"" << name << "\"): gain not found.\n" <<
- "Available gains: " << string_vector_to_string(get_rx_gain_names(chan)) << std::endl;
- throw uhd::exception::runtime_error(err.str());
+ THROW_GAIN_NAME_ERROR(name,chan,tx);
}
}