aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-07-20 10:58:22 -0700
committerJosh Blum <josh@joshknows.com>2010-07-20 10:58:22 -0700
commit5a4545d3f9689dcddd88f9316ad7bd9c489a3925 (patch)
tree58bbb5606f7d392a941fb001c9cc9541c9bf05d0 /host
parentc75bde36c670d66ba049df23747caa8d1f967c39 (diff)
downloaduhd-5a4545d3f9689dcddd88f9316ad7bd9c489a3925.tar.gz
uhd-5a4545d3f9689dcddd88f9316ad7bd9c489a3925.tar.bz2
uhd-5a4545d3f9689dcddd88f9316ad7bd9c489a3925.zip
uhd: bring timeout parameter to the device::recv call, implement in usrp2
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/device.hpp10
-rw-r--r--host/include/uhd/device.ipp5
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp18
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp8
4 files changed, 22 insertions, 19 deletions
diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp
index a19d22880..ee297ec8a 100644
--- a/host/include/uhd/device.hpp
+++ b/host/include/uhd/device.hpp
@@ -42,6 +42,9 @@ public:
typedef boost::function<device_addrs_t(const device_addr_t &)> find_t;
typedef boost::function<sptr(const device_addr_t &)> make_t;
+ //! A reasonable default timeout for receive
+ static const size_t default_recv_timeout_ms = 100;
+
/*!
* Register a device into the discovery and factory system.
*
@@ -174,6 +177,7 @@ public:
* \param metadata data to fill describing the buffer
* \param io_type the type of data to fill into the buffer
* \param recv_mode tells recv how to load the buffer
+ * \param timeout_ms the timeout in milliseconds to wait for a packet
* \return the number of samples received or 0 on error
*/
virtual size_t recv(
@@ -181,7 +185,8 @@ public:
size_t nsamps_per_buff,
rx_metadata_t &metadata,
const io_type_t &io_type,
- recv_mode_t recv_mode
+ recv_mode_t recv_mode,
+ size_t timeout_ms = default_recv_timeout_ms
) = 0;
/*!
@@ -192,7 +197,8 @@ public:
size_t nsamps_per_buff,
rx_metadata_t &metadata,
const io_type_t &io_type,
- recv_mode_t recv_mode
+ recv_mode_t recv_mode,
+ size_t timeout_ms = default_recv_timeout_ms
);
//! Deprecated
diff --git a/host/include/uhd/device.ipp b/host/include/uhd/device.ipp
index c38a2e43e..603c52859 100644
--- a/host/include/uhd/device.ipp
+++ b/host/include/uhd/device.ipp
@@ -52,12 +52,13 @@ namespace uhd{
size_t nsamps_per_buff,
rx_metadata_t &metadata,
const io_type_t &io_type,
- recv_mode_t recv_mode
+ recv_mode_t recv_mode,
+ size_t timeout_ms
){
return this->recv(
std::vector<void *>(1, buff),
nsamps_per_buff, metadata,
- io_type, recv_mode
+ io_type, recv_mode, timeout_ms
);
}
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 430f28390..1071dc3db 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -57,7 +57,7 @@ struct usrp2_impl::io_impl{
bool get_recv_buffs(vrt_packet_handler::managed_recv_buffs_t &buffs){
boost::this_thread::disable_interruption di; //disable because the wait can throw
- return recv_pirate_booty->pop_elems_with_timed_wait(buffs, boost::posix_time::milliseconds(100));
+ return recv_pirate_booty->pop_elems_with_timed_wait(buffs, boost::posix_time::milliseconds(recv_timeout_ms));
}
//state management for the vrt packet handler code
@@ -69,6 +69,7 @@ struct usrp2_impl::io_impl{
boost::thread_group recv_pirate_crew;
bool recv_pirate_crew_raiding;
alignment_buffer_type::sptr recv_pirate_booty;
+ size_t recv_timeout_ms;
};
/***********************************************************************
@@ -164,10 +165,8 @@ bool get_send_buffs(
}
size_t usrp2_impl::send(
- const std::vector<const void *> &buffs,
- size_t num_samps,
- const tx_metadata_t &metadata,
- const io_type_t &io_type,
+ const std::vector<const void *> &buffs, size_t num_samps,
+ const tx_metadata_t &metadata, const io_type_t &io_type,
send_mode_t send_mode
){
return vrt_packet_handler::send(
@@ -186,12 +185,11 @@ size_t usrp2_impl::send(
* Receive Data
**********************************************************************/
size_t usrp2_impl::recv(
- const std::vector<void *> &buffs,
- size_t num_samps,
- rx_metadata_t &metadata,
- const io_type_t &io_type,
- recv_mode_t recv_mode
+ const std::vector<void *> &buffs, size_t num_samps,
+ rx_metadata_t &metadata, const io_type_t &io_type,
+ recv_mode_t recv_mode, size_t timeout_ms
){
+ _io_impl->recv_timeout_ms = timeout_ms;
return vrt_packet_handler::recv(
_io_impl->packet_handler_recv_state, //last state of the recv handler
buffs, num_samps, //buffer to fill
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index ab23830c0..cae1b21d6 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -224,8 +224,7 @@ public:
}
size_t send(
const std::vector<const void *> &, size_t,
- const uhd::tx_metadata_t &,
- const uhd::io_type_t &,
+ const uhd::tx_metadata_t &, const uhd::io_type_t &,
uhd::device::send_mode_t
);
size_t get_max_recv_samps_per_packet(void) const{
@@ -233,9 +232,8 @@ public:
}
size_t recv(
const std::vector<void *> &, size_t,
- uhd::rx_metadata_t &,
- const uhd::io_type_t &,
- uhd::device::recv_mode_t
+ uhd::rx_metadata_t &, const uhd::io_type_t &,
+ uhd::device::recv_mode_t, size_t
);
private: