aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples
diff options
context:
space:
mode:
authorSamuel O'Brien <sam.obrien@ni.com>2020-07-28 13:19:08 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2020-07-31 15:09:33 -0500
commit84c33194ce6056af31393047ea8ce505a3ccf073 (patch)
tree4f04a4d34586d5e6f2480fda6bf6c639d3f3d717 /host/examples
parentae2b9bf7aeea6f8f98f6dacffdfc018d87107927 (diff)
downloaduhd-84c33194ce6056af31393047ea8ce505a3ccf073.tar.gz
uhd-84c33194ce6056af31393047ea8ce505a3ccf073.tar.bz2
uhd-84c33194ce6056af31393047ea8ce505a3ccf073.zip
example: Check for failure in tx_samples_from_file
I was using this example for testing with the simulator. If there is a flow control failure, the original example would just silently finish, outputing the message "Done!" (Not even printing a timeout message). This commit asserts that the number of samples sent is equal to the number of samples provided. Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
Diffstat (limited to 'host/examples')
-rw-r--r--host/examples/tx_samples_from_file.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp
index 89e961b38..695cdf6f4 100644
--- a/host/examples/tx_samples_from_file.cpp
+++ b/host/examples/tx_samples_from_file.cpp
@@ -44,7 +44,13 @@ void send_from_file(
md.end_of_burst = infile.eof();
- tx_stream->send(&buff.front(), num_tx_samps, md);
+ const size_t samples_sent = tx_stream->send(&buff.front(), num_tx_samps, md);
+ if (samples_sent != num_tx_samps) {
+ UHD_LOG_ERROR("TX-STREAM",
+ "The tx_stream timed out sending " << num_tx_samps << " samples ("
+ << samples_sent << " sent).");
+ return;
+ }
}
infile.close();
@@ -179,7 +185,7 @@ int UHD_SAFE_MAIN(int argc, char* argv[])
sensor_names = usrp->get_mboard_sensor_names(0);
if ((ref == "mimo")
and (std::find(sensor_names.begin(), sensor_names.end(), "mimo_locked")
- != sensor_names.end())) {
+ != sensor_names.end())) {
uhd::sensor_value_t mimo_locked = usrp->get_mboard_sensor("mimo_locked", 0);
std::cout << boost::format("Checking TX: %s ...") % mimo_locked.to_pp_string()
<< std::endl;
@@ -187,7 +193,7 @@ int UHD_SAFE_MAIN(int argc, char* argv[])
}
if ((ref == "external")
and (std::find(sensor_names.begin(), sensor_names.end(), "ref_locked")
- != sensor_names.end())) {
+ != sensor_names.end())) {
uhd::sensor_value_t ref_locked = usrp->get_mboard_sensor("ref_locked", 0);
std::cout << boost::format("Checking TX: %s ...") % ref_locked.to_pp_string()
<< std::endl;