aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorMichael West <michael.west@ettus.com>2020-04-29 03:05:35 -0700
committerAaron Rossetto <aaron.rossetto@ni.com>2020-04-30 15:14:28 -0500
commit52fb587373372e1f6024bd4adb7153c79aca3bde (patch)
treeafe69c2f57e4d169d841421718574372ba1e40b9 /host
parent8720f42b33e89ff4df8bca69d7ddca2ba896b69a (diff)
downloaduhd-52fb587373372e1f6024bd4adb7153c79aca3bde.tar.gz
uhd-52fb587373372e1f6024bd4adb7153c79aca3bde.tar.bz2
uhd-52fb587373372e1f6024bd4adb7153c79aca3bde.zip
examples: Update test_messages example
The example assumed that there was always at least one TX and on RX channel. Since that is not always true, this change checks for TX and RX channels and only exucutes tests for what exists on the device. Signed-off-by: Michael West <michael.west@ettus.com>
Diffstat (limited to 'host')
-rw-r--r--host/examples/test_messages.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp
index fb930ac7c..512d22d86 100644
--- a/host/examples/test_messages.cpp
+++ b/host/examples/test_messages.cpp
@@ -316,22 +316,29 @@ int UHD_SAFE_MAIN(int argc, char* argv[])
// create RX and TX streamers
uhd::stream_args_t stream_args("fc32"); // complex floats
- uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
- uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args);
+ uhd::rx_streamer::sptr rx_stream;
+ uhd::tx_streamer::sptr tx_stream;
+ if (usrp->get_rx_num_channels()) {
+ rx_stream = usrp->get_rx_stream(stream_args);
+ }
+ if (usrp->get_tx_num_channels()) {
+ tx_stream = usrp->get_tx_stream(stream_args);
+ }
//------------------------------------------------------------------
// begin messages test
//------------------------------------------------------------------
using test_executor_fn = std::function<bool(
uhd::usrp::multi_usrp::sptr, uhd::rx_streamer::sptr, uhd::tx_streamer::sptr)>;
- // clang-format off
- uhd::dict<std::string, test_executor_fn> tests = boost::assign::map_list_of
- ("Test Burst ACK ", &test_burst_ack_message)
- ("Test Underflow ", &test_underflow_message)
- ("Test Time Error", &test_time_error_message)
- ("Test Late Command", &test_late_command_message)
- ;
- // clang-format on
+ uhd::dict<std::string, test_executor_fn> tests;
+ if (tx_stream) {
+ tests["Test Burst ACK "] = &test_burst_ack_message;
+ tests["Test Underflow "] = &test_underflow_message;
+ tests["Test Time Error"] = &test_time_error_message;
+ }
+ if (rx_stream) {
+ tests["Test Late Command"] = &test_late_command_message;
+ }
if (vm.count("test-chain")) {
tests["Test Broken Chain"] = &test_broken_chain_message;
@@ -350,8 +357,12 @@ int UHD_SAFE_MAIN(int argc, char* argv[])
std::string key = tests.keys()[std::rand() % tests.size()];
bool pass = tests[key](usrp, rx_stream, tx_stream);
- flush_recv(rx_stream);
- flush_async(tx_stream);
+ if (rx_stream) {
+ flush_recv(rx_stream);
+ }
+ if (tx_stream) {
+ flush_async(tx_stream);
+ }
// store result
if (pass)