diff options
author | Josh Blum <josh@joshknows.com> | 2010-06-01 17:51:26 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-06-01 17:51:26 -0700 |
commit | 212159ca3bc00d233464cd6f9f454e5ac6e08f88 (patch) | |
tree | 26ba4df4c4e692face9145c6cc1e77fff8056076 /host/lib/transport | |
parent | f78cae4911148470f1b5fbf2ff8ea795250419a1 (diff) | |
download | uhd-212159ca3bc00d233464cd6f9f454e5ac6e08f88.tar.gz uhd-212159ca3bc00d233464cd6f9f454e5ac6e08f88.tar.bz2 uhd-212159ca3bc00d233464cd6f9f454e5ac6e08f88.zip |
Implemented pirate thread, moved io impl details into io impl cpp file. Fixed bug in bounded buffer push with pop on full.
Diffstat (limited to 'host/lib/transport')
-rw-r--r-- | host/lib/transport/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/lib/transport/udp_zero_copy_asio.cpp | 2 | ||||
-rw-r--r-- | host/lib/transport/vrt_packet_handler.hpp | 29 | ||||
-rw-r--r-- | host/lib/transport/vrt_packet_handler_state.hpp | 56 |
4 files changed, 29 insertions, 59 deletions
diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index 32644a6c0..a74f7d527 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -50,6 +50,5 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_SOURCE_DIR}/lib/transport/udp_simple.cpp ${CMAKE_SOURCE_DIR}/lib/transport/udp_zero_copy_asio.cpp ${CMAKE_SOURCE_DIR}/lib/transport/vrt_packet_handler.hpp - ${CMAKE_SOURCE_DIR}/lib/transport/vrt_packet_handler_state.hpp ${CMAKE_SOURCE_DIR}/lib/transport/zero_copy.cpp ) diff --git a/host/lib/transport/udp_zero_copy_asio.cpp b/host/lib/transport/udp_zero_copy_asio.cpp index 4402437f3..190e3f9ce 100644 --- a/host/lib/transport/udp_zero_copy_asio.cpp +++ b/host/lib/transport/udp_zero_copy_asio.cpp @@ -28,7 +28,7 @@ using namespace uhd::transport; * Constants **********************************************************************/ static const size_t MIN_SOCK_BUFF_SIZE = size_t(100e3); -static const size_t MAX_DGRAM_SIZE = 2048; //assume max size on send and recv +static const size_t MAX_DGRAM_SIZE = 1500; //assume max size on send and recv static const double RECV_TIMEOUT = 0.1; // 100 ms /*********************************************************************** diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp index a179731ca..d6b863040 100644 --- a/host/lib/transport/vrt_packet_handler.hpp +++ b/host/lib/transport/vrt_packet_handler.hpp @@ -18,7 +18,6 @@ #ifndef INCLUDED_LIBUHD_TRANSPORT_VRT_PACKET_HANDLER_HPP #define INCLUDED_LIBUHD_TRANSPORT_VRT_PACKET_HANDLER_HPP -#include "vrt_packet_handler_state.hpp" #include <uhd/config.hpp> #include <uhd/device.hpp> #include <uhd/types/io_type.hpp> @@ -37,6 +36,24 @@ namespace vrt_packet_handler{ /*********************************************************************** * vrt packet handler for recv **********************************************************************/ + struct recv_state{ + //init the expected seq number + size_t next_packet_seq; + + //state variables to handle fragments + uhd::transport::managed_recv_buffer::sptr managed_buff; + boost::asio::const_buffer copy_buff; + size_t fragment_offset_in_samps; + + recv_state(void){ + //first expected seq is zero + next_packet_seq = 0; + + //initially empty copy buffer + copy_buff = boost::asio::buffer("", 0); + } + }; + typedef boost::function<uhd::transport::managed_recv_buffer::sptr(void)> get_recv_buff_t; typedef boost::function<void(uhd::transport::managed_recv_buffer::sptr)> recv_cb_t; @@ -106,6 +123,7 @@ namespace vrt_packet_handler{ if (boost::asio::buffer_size(state.copy_buff) == 0){ state.fragment_offset_in_samps = 0; state.managed_buff = get_recv_buff(); + if (state.managed_buff.get() == NULL) return 0; recv_cb(state.managed_buff); //callback before vrt unpack try{ _recv1_helper( @@ -210,6 +228,15 @@ namespace vrt_packet_handler{ /*********************************************************************** * vrt packet handler for send **********************************************************************/ + struct send_state{ + //init the expected seq number + size_t next_packet_seq; + + send_state(void){ + next_packet_seq = 0; + } + }; + typedef boost::function<uhd::transport::managed_send_buffer::sptr(void)> get_send_buff_t; typedef boost::function<void(uhd::transport::managed_send_buffer::sptr)> send_cb_t; diff --git a/host/lib/transport/vrt_packet_handler_state.hpp b/host/lib/transport/vrt_packet_handler_state.hpp deleted file mode 100644 index 2320a3b8e..000000000 --- a/host/lib/transport/vrt_packet_handler_state.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#ifndef INCLUDED_LIBUHD_TRANSPORT_VRT_PACKET_HANDLER_STATE_HPP -#define INCLUDED_LIBUHD_TRANSPORT_VRT_PACKET_HANDLER_STATE_HPP - -#include <uhd/config.hpp> -#include <uhd/transport/zero_copy.hpp> -#include <boost/asio/buffer.hpp> - -namespace vrt_packet_handler{ - - struct recv_state{ - //init the expected seq number - size_t next_packet_seq; - - //state variables to handle fragments - uhd::transport::managed_recv_buffer::sptr managed_buff; - boost::asio::const_buffer copy_buff; - size_t fragment_offset_in_samps; - - recv_state(void){ - //first expected seq is zero - next_packet_seq = 0; - - //initially empty copy buffer - copy_buff = boost::asio::buffer("", 0); - } - }; - - struct send_state{ - //init the expected seq number - size_t next_packet_seq; - - send_state(void){ - next_packet_seq = 0; - } - }; - -} //namespace vrt_packet_handler - -#endif /* INCLUDED_LIBUHD_TRANSPORT_VRT_PACKET_HANDLER_STATE_HPP */ |