aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-10-07 10:43:58 -0700
committerJosh Blum <josh@joshknows.com>2010-10-07 10:43:58 -0700
commit0059e62ed067a4844edfb720da73fcdb8e69db6a (patch)
treeb293491af14f6053368c5ccfbee2c38a3b804dc1
parentb40ace72dd1b940fc0ce6e4a5e06346439dd5625 (diff)
downloaduhd-0059e62ed067a4844edfb720da73fcdb8e69db6a.tar.gz
uhd-0059e62ed067a4844edfb720da73fcdb8e69db6a.tar.bz2
uhd-0059e62ed067a4844edfb720da73fcdb8e69db6a.zip
usrp2: moved samples per packet calculation into io_impl
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp19
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp23
2 files changed, 22 insertions, 20 deletions
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 07eda08c3..eba704059 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -197,6 +197,15 @@ static bool get_send_buffs(
return good;
}
+size_t usrp2_impl::get_max_send_samps_per_packet(void) const{
+ static const size_t hdr_size = 0
+ + vrt::max_if_hdr_words32*sizeof(boost::uint32_t)
+ - sizeof(vrt::if_packet_info_t().cid) //no class id ever used
+ ;
+ const size_t bpp = _data_transports.front()->get_send_frame_size() - hdr_size;
+ return bpp/_tx_otw_type.get_sample_size();
+}
+
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,
@@ -217,6 +226,16 @@ size_t usrp2_impl::send(
/***********************************************************************
* Receive Data
**********************************************************************/
+size_t usrp2_impl::get_max_recv_samps_per_packet(void) const{
+ static const size_t hdr_size = 0
+ + vrt::max_if_hdr_words32*sizeof(boost::uint32_t)
+ + sizeof(vrt::if_packet_info_t().tlr) //forced to have trailer
+ - sizeof(vrt::if_packet_info_t().cid) //no class id ever used
+ ;
+ const size_t bpp = _data_transports.front()->get_recv_frame_size() - hdr_size;
+ return bpp/_rx_otw_type.get_sample_size();
+}
+
size_t usrp2_impl::recv(
const std::vector<void *> &buffs, size_t num_samps,
rx_metadata_t &metadata, const io_type_t &io_type,
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index e12c4d6d4..558726a2b 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -184,24 +184,18 @@ public:
~usrp2_impl(void);
//the io interface
- size_t get_max_send_samps_per_packet(void) const{
- const size_t bytes_per_packet = _data_transports.front()->get_send_frame_size() - _max_tx_header_bytes;
- return bytes_per_packet/_tx_otw_type.get_sample_size();
- }
size_t send(
const std::vector<const void *> &, size_t,
const uhd::tx_metadata_t &, const uhd::io_type_t &,
uhd::device::send_mode_t, double
);
- size_t get_max_recv_samps_per_packet(void) const{
- const size_t bytes_per_packet = _data_transports.front()->get_recv_frame_size() - _max_rx_header_bytes;
- return bytes_per_packet/_rx_otw_type.get_sample_size();
- }
size_t recv(
const std::vector<void *> &, size_t,
uhd::rx_metadata_t &, const uhd::io_type_t &,
uhd::device::recv_mode_t, double
);
+ size_t get_max_send_samps_per_packet(void) const;
+ size_t get_max_recv_samps_per_packet(void) const;
bool recv_async_msg(uhd::async_metadata_t &, double);
private:
@@ -215,20 +209,9 @@ private:
//io impl methods and members
std::vector<uhd::transport::udp_zero_copy::sptr> _data_transports;
+ uhd::otw_type_t _rx_otw_type, _tx_otw_type;
UHD_PIMPL_DECL(io_impl) _io_impl;
void io_init(void);
-
- //over-the-wire structs and constants
- uhd::otw_type_t _rx_otw_type, _tx_otw_type;
- static const size_t _max_rx_header_bytes = 0
- + uhd::transport::vrt::max_if_hdr_words32*sizeof(boost::uint32_t)
- + sizeof(uhd::transport::vrt::if_packet_info_t().tlr) //forced to have trailer
- - sizeof(uhd::transport::vrt::if_packet_info_t().cid) //no class id ever used
- ;
- static const size_t _max_tx_header_bytes = 0
- + uhd::transport::vrt::max_if_hdr_words32*sizeof(boost::uint32_t)
- - sizeof(uhd::transport::vrt::if_packet_info_t().cid) //no class id ever used
- ;
};
#endif /* INCLUDED_USRP2_IMPL_HPP */