aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples/test_messages.cpp
diff options
context:
space:
mode:
authorBrent Stapleton <brent.stapleton@ettus.com>2019-06-06 14:37:44 -0700
committerMartin Braun <martin.braun@ettus.com>2019-11-26 12:16:25 -0800
commit9d2748655020a6c1917f69b2988014f65388d23a (patch)
tree03a6b97ad5175f8132fe9fab27184afdae83ddb8 /host/examples/test_messages.cpp
parentc256b9df6502536c2e451e690f1ad5962c664d1a (diff)
downloaduhd-9d2748655020a6c1917f69b2988014f65388d23a.tar.gz
uhd-9d2748655020a6c1917f69b2988014f65388d23a.tar.bz2
uhd-9d2748655020a6c1917f69b2988014f65388d23a.zip
rfnoc: examples: Porting examples to new RFNoC
rfnoc_nullsource_ce_rx, rfnoc_rx_to_file: These examples are modified so they can be run with the new RFNoC API. test_messages: Fixes failures in the time test when it is executed immediately after an underrun test. The DUC considers time specs on a per burst basis, so when the underrun test leaves a burst unfinished, a time spec on the next burst is ignored.
Diffstat (limited to 'host/examples/test_messages.cpp')
-rw-r--r--host/examples/test_messages.cpp70
1 files changed, 41 insertions, 29 deletions
diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp
index 0d0e958b8..fe2293840 100644
--- a/host/examples/test_messages.cpp
+++ b/host/examples/test_messages.cpp
@@ -1,6 +1,7 @@
//
// Copyright 2010-2013 Ettus Research LLC
// Copyright 2018 Ettus Research, a National Instruments Company
+// Copyright 2019 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
@@ -48,14 +49,14 @@ bool test_late_command_message(uhd::usrp::multi_usrp::sptr usrp,
switch (md.error_code) {
case uhd::rx_metadata_t::ERROR_CODE_LATE_COMMAND:
- std::cout << boost::format("success:\n"
- " Got error code late command message.\n")
+ std::cout << "success:\n"
+ << " Got error code late command message.\n"
<< std::endl;
return true;
case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT:
- std::cout << boost::format("failed:\n"
- " Inline message recv timed out.\n")
+ std::cout << "failed:\n"
+ << " Inline message recv timed out.\n"
<< std::endl;
return false;
@@ -141,16 +142,16 @@ bool test_burst_ack_message(
uhd::async_metadata_t async_md;
if (not tx_stream->recv_async_msg(async_md)) {
- std::cout << boost::format("failed:\n"
- " Async message recv timed out.\n")
+ std::cout << "failed:\n"
+ << " Async message recv timed out.\n"
<< std::endl;
return false;
}
switch (async_md.event_code) {
case uhd::async_metadata_t::EVENT_CODE_BURST_ACK:
- std::cout << boost::format("success:\n"
- " Got event code burst ack message.\n")
+ std::cout << "success:\n"
+ << " Got event code burst ack message.\n"
<< std::endl;
return true;
@@ -182,27 +183,35 @@ bool test_underflow_message(
tx_stream->send(&buff.front(), buff.size(), md);
uhd::async_metadata_t async_md;
+ bool result = false;
if (not tx_stream->recv_async_msg(async_md, 1)) {
std::cout << boost::format("failed:\n"
" Async message recv timed out.\n")
<< std::endl;
- return false;
+ } else {
+ switch (async_md.event_code) {
+ case uhd::async_metadata_t::EVENT_CODE_UNDERFLOW:
+ std::cout << boost::format("success:\n"
+ " Got event code underflow message.\n")
+ << std::endl;
+ result = true;
+ break;
+
+ default:
+ std::cout << boost::format("failed:\n"
+ " Got unexpected event code 0x%x.\n")
+ % async_md.event_code
+ << std::endl;
+ break;
+ }
}
- switch (async_md.event_code) {
- case uhd::async_metadata_t::EVENT_CODE_UNDERFLOW:
- std::cout << boost::format("success:\n"
- " Got event code underflow message.\n")
- << std::endl;
- return true;
-
- default:
- std::cout << boost::format("failed:\n"
- " Got unexpected event code 0x%x.\n")
- % async_md.event_code
- << std::endl;
- return false;
- }
+ // Finish the burst to avoid affecting other tests. The DUC only considers
+ // time specs from the beginning of a burst, if other tests need a time
+ // spec they would be affected by an unfinished burst.
+ md.end_of_burst = true;
+ tx_stream->send(&buff.front(), buff.size(), md);
+ return result;
}
/*!
@@ -314,12 +323,15 @@ int UHD_SAFE_MAIN(int argc, char* argv[])
//------------------------------------------------------------------
// begin messages test
//------------------------------------------------------------------
- static uhd::dict<std::string,
- boost::function<bool(
- uhd::usrp::multi_usrp::sptr, uhd::rx_streamer::sptr, uhd::tx_streamer::sptr)>>
- 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);
+ 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
if (vm.count("test-chain")) {
tests["Test Broken Chain"] = &test_broken_chain_message;