From ed72347d53b11b01aa4a7b84eac90bd878950ca6 Mon Sep 17 00:00:00 2001 From: steviez Date: Wed, 19 Feb 2020 12:55:08 -0600 Subject: 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 --- host/examples/gpio.cpp | 21 ++++++++++++++------- 1 file 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 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[]) -- cgit v1.2.3