aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples
diff options
context:
space:
mode:
authorsteviez <steve.czabaniuk@ni.com>2020-02-19 12:55:08 -0600
committeratrnati <54334261+atrnati@users.noreply.github.com>2020-02-19 16:00:46 -0600
commited72347d53b11b01aa4a7b84eac90bd878950ca6 (patch)
tree386d8bbc05157185797c8c56dadce93ae45457a9 /host/examples
parentbdcb95c56bdd213af534d312a1abd8ab69dcc214 (diff)
downloaduhd-ed72347d53b11b01aa4a7b84eac90bd878950ca6.tar.gz
uhd-ed72347d53b11b01aa4a7b84eac90bd878950ca6.tar.bz2
uhd-ed72347d53b11b01aa4a7b84eac90bd878950ca6.zip
examples: Wrap get_gpio_src() with try/catch block
Non-RFNoC devices do not support get_gpio_src() entrypoing so wrap call with a try/catch block
Diffstat (limited to 'host/examples')
-rw-r--r--host/examples/gpio.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/host/examples/gpio.cpp b/host/examples/gpio.cpp
index 779fc1fa0..103060908 100644
--- a/host/examples/gpio.cpp
+++ b/host/examples/gpio.cpp
@@ -123,7 +123,7 @@ void output_reg_values(const std::string bank,
{
const std::vector<std::string> attrs = {
"CTRL", "DDR", "ATR_0X", "ATR_RX", "ATR_TX", "ATR_XX", "OUT", "READBACK"};
- std::cout << (boost::format("%10s ") % "Bit");
+ std::cout << (boost::format("%10s:") % "Bit");
for (int i = num_bits - 1; i >= 0; i--)
std::cout << (boost::format(" %2d") % i);
std::cout << std::endl;
@@ -133,13 +133,20 @@ void output_reg_values(const std::string bank,
% to_bit_string(gpio_bits, num_bits))
<< std::endl;
}
- // GPIO Src
- const auto gpio_src = usrp->get_gpio_src(bank);
- std::cout << boost::format("%10s:") % "SRC: ";
- for (auto src : gpio_src) {
- std::cout << " " << src;
+
+ // GPIO Src - get_gpio_src() not supported for all devices
+ try {
+ const auto gpio_src = usrp->get_gpio_src(bank);
+ std::cout << boost::format("%10s:") % "SRC";
+ for (auto src : gpio_src) {
+ std::cout << " " << src;
+ }
+ std::cout << std::endl;
+ } catch (const uhd::not_implemented_error& e) {
+ std::cout << "Ignoring " << e.what() << std::endl;
+ } catch (...) {
+ throw;
}
- std::cout << std::endl;
}
int UHD_SAFE_MAIN(int argc, char* argv[])