summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-05-24 14:38:25 -0700
committerJosh Blum <josh@joshknows.com>2010-05-24 14:38:25 -0700
commit71169b8e030d984220eadde83c4b40481f97cf6b (patch)
tree2d488a0408934fbddc0a49c245f26adc1101306c
parent830e34fe30737432a5bfa4b19cc4bad5b4e425ee (diff)
downloaduhd-71169b8e030d984220eadde83c4b40481f97cf6b.tar.gz
uhd-71169b8e030d984220eadde83c4b40481f97cf6b.tar.bz2
uhd-71169b8e030d984220eadde83c4b40481f97cf6b.zip
Added timeout error message to timed samples example.
Added try catch to recv helper because vrt unpack can throw.
-rw-r--r--host/examples/rx_timed_samples.cpp4
-rw-r--r--host/lib/transport/vrt_packet_handler.hpp11
2 files changed, 12 insertions, 3 deletions
diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp
index d2306c7c4..64da260d5 100644
--- a/host/examples/rx_timed_samples.cpp
+++ b/host/examples/rx_timed_samples.cpp
@@ -86,6 +86,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
md, uhd::io_type_t::COMPLEX_FLOAT32,
uhd::device::RECV_MODE_ONE_PACKET
);
+ if (num_rx_samps == 0 and num_acc_samps > 0){
+ std::cout << "Got timeout before all samples received, possible packet loss, exiting loop..." << std::endl;
+ break;
+ }
if (num_rx_samps == 0) continue; //wait for packets with contents
std::cout << boost::format("Got packet: %u samples, %u secs, %u nsecs")
diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp
index 2a7f995a1..81420b39e 100644
--- a/host/lib/transport/vrt_packet_handler.hpp
+++ b/host/lib/transport/vrt_packet_handler.hpp
@@ -122,9 +122,14 @@ namespace vrt_packet_handler{
state.fragment_offset_in_samps = 0;
state.managed_buff = zc_iface->get_recv_buff();
recv_cb(state.managed_buff); //callback before vrt unpack
- _recv1_helper(
- state, metadata, tick_rate, vrt_header_offset_words32
- );
+ try{
+ _recv1_helper(
+ state, metadata, tick_rate, vrt_header_offset_words32
+ );
+ }catch(const std::exception &e){
+ std::cerr << "Error (recv): " << e.what() << std::endl;
+ return 0;
+ }
}
//extract the number of samples available to copy