summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp23
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp2
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp4
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp27
4 files changed, 37 insertions, 19 deletions
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 7c9d003ce..de0c76eb1 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -31,10 +31,16 @@ namespace asio = boost::asio;
* Helper Functions
**********************************************************************/
void usrp2_impl::io_init(void){
- //setup otw type
- _otw_type.width = 16;
- _otw_type.shift = 0;
- _otw_type.byteorder = otw_type_t::BO_BIG_ENDIAN;
+ //setup rx otw type
+ _rx_otw_type.width = 16;
+ _rx_otw_type.shift = 0;
+ _rx_otw_type.byteorder = otw_type_t::BO_BIG_ENDIAN;
+
+ //setup tx otw type
+ _tx_otw_type.width = 16;
+ _tx_otw_type.shift = 0;
+ _tx_otw_type.byteorder = otw_type_t::BO_BIG_ENDIAN;
+
//initially empty copy buffer
_rx_copy_buff = asio::buffer("", 0);
@@ -49,7 +55,8 @@ void usrp2_impl::io_init(void){
send_buff->done(sizeof(data));
//setup RX DSP regs
- _iface->poke32(FR_RX_CTRL_NSAMPS_PER_PKT, _max_rx_samples_per_packet);
+ std::cout << "RX samples per packet: " << max_rx_samps_per_packet() << std::endl;
+ _iface->poke32(FR_RX_CTRL_NSAMPS_PER_PKT, max_rx_samps_per_packet());
_iface->poke32(FR_RX_CTRL_NCHANNELS, 1);
_iface->poke32(FR_RX_CTRL_CLEAR_OVERRUN, 1); //reset
_iface->poke32(FR_RX_CTRL_VRT_HEADER, 0
@@ -121,7 +128,7 @@ size_t usrp2_impl::send(
boost::uint32_t *tx_mem = send_buff->cast<boost::uint32_t *>();
size_t num_samps = std::min(std::min(
asio::buffer_size(buff)/io_type.size,
- size_t(_max_tx_samples_per_packet)),
+ size_t(max_tx_samps_per_packet())),
send_buff->size()/io_type.size
);
@@ -148,7 +155,7 @@ size_t usrp2_impl::send(
//copy-convert the samples into the send buffer
convert_io_type_to_otw_type(
asio::buffer_cast<const void*>(buff), io_type,
- (void*)items, _otw_type,
+ (void*)items, _tx_otw_type,
num_samps
);
@@ -192,7 +199,7 @@ size_t usrp2_impl::recv(
//copy-convert the samples from the recv buffer
convert_otw_type_to_io_type(
- (const void*)items, _otw_type,
+ (const void*)items, _rx_otw_type,
asio::buffer_cast<void*>(buff), io_type,
num_samps
);
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 9ae68d158..a10529102 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -111,7 +111,7 @@ void usrp2_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){
//issue the stream command
_iface->poke32(FR_RX_CTRL_STREAM_CMD, FR_RX_CTRL_MAKE_CMD(
- (inst_samps)? stream_cmd.num_samps : ((inst_chain)? _max_rx_samples_per_packet : 1),
+ (inst_samps)? stream_cmd.num_samps : ((inst_chain)? max_rx_samps_per_packet() : 1),
(stream_cmd.stream_now)? 1 : 0,
(inst_chain)? 1 : 0,
(inst_reload)? 1 : 0
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index 2b7bdeea2..3b7156802 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -211,11 +211,11 @@ void usrp2_impl::get(const wax::obj &key_, wax::obj &val){
return;
case DEVICE_PROP_MAX_RX_SAMPLES:
- val = size_t(_max_rx_samples_per_packet);
+ val = max_rx_samps_per_packet();
return;
case DEVICE_PROP_MAX_TX_SAMPLES:
- val = size_t(_max_tx_samples_per_packet);
+ val = max_tx_samps_per_packet();
return;
default: UHD_THROW_PROP_GET_ERROR();
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index c5b6af810..e2d37e512 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -125,21 +125,32 @@ private:
void recv_raw(uhd::rx_metadata_t &);
uhd::dict<boost::uint32_t, size_t> _tx_stream_id_to_packet_seq;
uhd::dict<boost::uint32_t, size_t> _rx_stream_id_to_packet_seq;
+
+ /*******************************************************************
+ * Deal with the rx and tx packet sizes
+ ******************************************************************/
static const size_t _mtu = 1500; //FIXME we have no idea
static const size_t _hdrs = (2 + 14 + 20 + 8); //size of headers (pad, eth, ip, udp)
- static const size_t _max_rx_samples_per_packet =
- (_mtu - _hdrs)/sizeof(boost::uint32_t) -
- USRP2_HOST_RX_VRT_HEADER_WORDS32 -
- USRP2_HOST_RX_VRT_TRAILER_WORDS32
+ static const size_t _max_rx_bytes_per_packet =
+ _mtu - _hdrs -
+ USRP2_HOST_RX_VRT_HEADER_WORDS32*sizeof(boost::uint32_t) -
+ USRP2_HOST_RX_VRT_TRAILER_WORDS32*sizeof(boost::uint32_t)
;
- static const size_t _max_tx_samples_per_packet =
- (_mtu - _hdrs)/sizeof(boost::uint32_t) -
- uhd::transport::vrt::max_header_words32
+ static const size_t _max_tx_bytes_per_packet =
+ _mtu - _hdrs -
+ uhd::transport::vrt::max_header_words32*sizeof(boost::uint32_t)
;
+ size_t max_rx_samps_per_packet(void){
+ return _max_rx_bytes_per_packet/(_rx_otw_type.width*2/8);
+ }
+ size_t max_tx_samps_per_packet(void){
+ return _max_tx_bytes_per_packet/(_tx_otw_type.width*2/8);
+ }
+
uhd::transport::managed_recv_buffer::sptr _rx_smart_buff;
boost::asio::const_buffer _rx_copy_buff;
size_t _fragment_offset_in_samps;
- uhd::otw_type_t _otw_type;
+ uhd::otw_type_t _rx_otw_type, _tx_otw_type;
void io_init(void);
//udp transports for control and data