summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/examples/benchmark_rx_rate.cpp15
-rw-r--r--host/examples/rx_timed_samples.cpp22
-rw-r--r--host/lib/transport/vrt_packet_handler.hpp3
3 files changed, 29 insertions, 11 deletions
diff --git a/host/examples/benchmark_rx_rate.cpp b/host/examples/benchmark_rx_rate.cpp
index a63337b38..2bde3865d 100644
--- a/host/examples/benchmark_rx_rate.cpp
+++ b/host/examples/benchmark_rx_rate.cpp
@@ -62,13 +62,18 @@ static inline void test_device(
uhd::io_type_t::COMPLEX_FLOAT32,
uhd::device::RECV_MODE_ONE_PACKET
);
- if (num_rx_samps == 0 and md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT){
- std::cerr << "Unexpected timeout on recv, exit test..." << std::endl;
+
+ //handle the error codes
+ switch(md.error_code){
+ case uhd::rx_metadata_t::ERROR_CODE_NONE:
+ case uhd::rx_metadata_t::ERROR_CODE_OVERRUN:
+ break;
+
+ default:
+ std::cerr << "Unexpected error on recv, exit test..." << std::endl;
return;
}
- if (num_rx_samps == 0 and md.error_code != uhd::rx_metadata_t::ERROR_CODE_OVERRUN){
- std::cerr << "Unexpected error on recv, continuing..." << std::endl;
- }
+
if (not md.has_time_spec){
std::cerr << "Metadata missing time spec, exit test..." << std::endl;
return;
diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp
index 95f805007..3b9acbb2c 100644
--- a/host/examples/rx_timed_samples.cpp
+++ b/host/examples/rx_timed_samples.cpp
@@ -92,20 +92,32 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
uhd::io_type_t::COMPLEX_FLOAT32,
uhd::device::RECV_MODE_ONE_PACKET
);
- if (num_rx_samps == 0 and num_acc_samps > 0){
+
+ //handle the error codes
+ switch(md.error_code){
+ case uhd::rx_metadata_t::ERROR_CODE_NONE:
+ break;
+
+ case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT:
+ if (num_acc_samps == 0) continue;
std::cout << boost::format(
- "Got error code 0x%x before all samples received, possible packet loss, exiting loop..."
+ "Got timeout before all samples received, possible packet loss, exiting loop..."
) % md.error_code << std::endl;
- break;
+ goto done_loop;
+
+ default:
+ std::cout << boost::format(
+ "Got error code 0x%x, exiting loop..."
+ ) % md.error_code << std::endl;
+ goto done_loop;
}
- if (num_rx_samps == 0) continue; //wait for packets with contents
if(verbose) std::cout << boost::format(
"Got packet: %u samples, %u full secs, %f frac secs"
) % num_rx_samps % md.time_spec.get_full_secs() % md.time_spec.get_frac_secs() << std::endl;
num_acc_samps += num_rx_samps;
- }
+ } done_loop:
//finished
std::cout << std::endl << "Done!" << std::endl << std::endl;
diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp
index 6623957ac..fdcff24b8 100644
--- a/host/lib/transport/vrt_packet_handler.hpp
+++ b/host/lib/transport/vrt_packet_handler.hpp
@@ -146,6 +146,8 @@ namespace vrt_packet_handler{
const handle_overrun_t &handle_overrun,
size_t vrt_header_offset_words32
){
+ metadata.error_code = uhd::rx_metadata_t::ERROR_CODE_NONE;
+
//perform a receive if no rx data is waiting to be copied
if (state.size_of_copy_buffs == 0){
state.fragment_offset_in_samps = 0;
@@ -171,7 +173,6 @@ namespace vrt_packet_handler{
metadata.has_time_spec = false;
metadata.start_of_burst = false;
metadata.end_of_burst = false;
- metadata.error_code = uhd::rx_metadata_t::ERROR_CODE_NONE;
}
//extract the number of samples available to copy