diff options
Diffstat (limited to 'host/lib/transport')
-rwxr-xr-x | host/lib/transport/gen_vrt_if_packet.py | 6 | ||||
-rw-r--r-- | host/lib/transport/libusb1_base.cpp | 10 | ||||
-rw-r--r-- | host/lib/transport/libusb1_zero_copy.cpp | 15 | ||||
-rw-r--r-- | host/lib/transport/usb_dummy_impl.cpp | 8 | ||||
-rw-r--r-- | host/lib/transport/vrt_packet_handler.hpp | 6 |
5 files changed, 23 insertions, 22 deletions
diff --git a/host/lib/transport/gen_vrt_if_packet.py b/host/lib/transport/gen_vrt_if_packet.py index 427217eb6..8481932ed 100755 --- a/host/lib/transport/gen_vrt_if_packet.py +++ b/host/lib/transport/gen_vrt_if_packet.py @@ -31,10 +31,10 @@ TMPL_TEXT = """ * This file was generated by $file on $time.strftime("%c") **********************************************************************/ +\#include <uhd/exception.hpp> \#include <uhd/transport/vrt_if_packet.hpp> \#include <uhd/utils/byteswap.hpp> \#include <boost/detail/endian.hpp> -\#include <stdexcept> \#include <vector> //define the endian macros to convert integers @@ -157,7 +157,7 @@ void vrt::if_hdr_unpack_$(suffix)( //failure case if (if_packet_info.num_packet_words32 < packet_words32) - throw std::runtime_error("bad vrt header or packet fragment"); + throw uhd::value_error("bad vrt header or packet fragment"); */ //Fix for short packets sent from the fpga: // Use the num_packet_words32 passed in as input, @@ -223,7 +223,7 @@ void vrt::if_hdr_unpack_$(suffix)( ########## Variables ########## //another failure case if (packet_words32 < $($num_header_words + $num_trailer_words)) - throw std::runtime_error("bad vrt header or invalid packet length"); + throw uhd::value_error("bad vrt header or invalid packet length"); if_packet_info.num_header_words32 = $num_header_words; if_packet_info.num_payload_words32 = packet_words32 - $($num_header_words + $num_trailer_words); break; diff --git a/host/lib/transport/libusb1_base.cpp b/host/lib/transport/libusb1_base.cpp index cfa77d9ca..6d4df7875 100644 --- a/host/lib/transport/libusb1_base.cpp +++ b/host/lib/transport/libusb1_base.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -16,7 +16,7 @@ // #include "libusb1_base.hpp" -#include <uhd/utils/assert.hpp> +#include <uhd/exception.hpp> #include <uhd/types/dict.hpp> #include <boost/weak_ptr.hpp> #include <boost/foreach.hpp> @@ -93,7 +93,7 @@ public: //allocate a new list of devices libusb_device** dev_list; ssize_t ret = libusb_get_device_list(sess->get_context(), &dev_list); - if (ret < 0) throw std::runtime_error("cannot enumerate usb devices"); + if (ret < 0) throw uhd::os_error("cannot enumerate usb devices"); //fill the vector of device references for (size_t i = 0; i < size_t(ret); i++) _devs.push_back( @@ -206,9 +206,9 @@ libusb::device_handle::sptr libusb::device_handle::get_cached_handle(device::spt handles[dev->get()] = new_handle; return new_handle; } - catch(const std::exception &e){ + catch(const uhd::exception &e){ std::cerr << "USB open failed: see the application notes for your device." << std::endl; - throw std::runtime_error(e.what()); + throw; } } diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index 87adece45..6dee69711 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -20,7 +20,7 @@ #include <uhd/transport/bounded_buffer.hpp> #include <uhd/transport/buffer_pool.hpp> #include <uhd/utils/thread_priority.hpp> -#include <uhd/utils/assert.hpp> +#include <uhd/exception.hpp> #include <boost/function.hpp> #include <boost/foreach.hpp> #include <boost/thread/thread.hpp> @@ -33,6 +33,11 @@ using namespace uhd::transport; static const size_t DEFAULT_NUM_XFERS = 16; //num xfers static const size_t DEFAULT_XFER_SIZE = 32*512; //bytes +//! helper function: handles all async callbacks +static void libusb_async_cb(libusb_transfer *lut){ + (*static_cast<boost::function<void()> *>(lut->user_data))(); +} + /*********************************************************************** * Reusable managed receiver buffer: * - Associated with a particular libusb transfer struct. @@ -79,7 +84,8 @@ public: void commit(size_t len){ if (_expired) return; _lut->length = len; - UHD_ASSERT_THROW(libusb_submit_transfer(_lut) == 0); + if(len == 0) libusb_async_cb(_lut); + else UHD_ASSERT_THROW(libusb_submit_transfer(_lut) == 0); _expired = true; } @@ -100,11 +106,6 @@ private: bool _expired; }; -//! helper function: handles all async callbacks -static void libusb_async_cb(libusb_transfer *lut){ - (*static_cast<boost::function<void()> *>(lut->user_data))(); -} - /*********************************************************************** * USB zero_copy device class **********************************************************************/ diff --git a/host/lib/transport/usb_dummy_impl.cpp b/host/lib/transport/usb_dummy_impl.cpp index 8a9772e7f..930678405 100644 --- a/host/lib/transport/usb_dummy_impl.cpp +++ b/host/lib/transport/usb_dummy_impl.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -18,7 +18,7 @@ #include <uhd/transport/usb_device_handle.hpp> #include <uhd/transport/usb_control.hpp> #include <uhd/transport/usb_zero_copy.hpp> -#include <uhd/utils/exception.hpp> +#include <uhd/exception.hpp> using namespace uhd; using namespace uhd::transport; @@ -28,12 +28,12 @@ std::vector<usb_device_handle::sptr> usb_device_handle::get_device_list(boost::u } usb_control::sptr usb_control::make(usb_device_handle::sptr){ - throw std::runtime_error("no usb support -> usb_control::make not implemented"); + throw uhd::not_implemented_error("no usb support -> usb_control::make not implemented"); } usb_zero_copy::sptr usb_zero_copy::make( usb_device_handle::sptr, size_t, size_t, const device_addr_t & ){ - throw std::runtime_error("no usb support -> usb_zero_copy::make not implemented"); + throw uhd::not_implemented_error("no usb support -> usb_zero_copy::make not implemented"); } diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp index 6f3ac0421..d74b2c13c 100644 --- a/host/lib/transport/vrt_packet_handler.hpp +++ b/host/lib/transport/vrt_packet_handler.hpp @@ -20,7 +20,7 @@ #include <uhd/config.hpp> #include <uhd/device.hpp> -#include <uhd/utils/assert.hpp> +#include <uhd/exception.hpp> #include <uhd/utils/byteswap.hpp> #include <uhd/types/io_type.hpp> #include <uhd/types/otw_type.hpp> @@ -300,18 +300,18 @@ template <typename T> UHD_INLINE T get_context_code( typedef boost::function<bool(managed_send_buffs_t &)> get_send_buffs_t; typedef boost::function<void(boost::uint32_t *, uhd::transport::vrt::if_packet_info_t &)> vrt_packer_t; + static const boost::uint64_t zeros = 0; + struct send_state{ //init the expected seq number size_t next_packet_seq; managed_send_buffs_t managed_buffs; - const boost::uint64_t zeros; std::vector<const void *> zero_buffs; std::vector<const void *> io_buffs; send_state(size_t width = 1): next_packet_seq(0), managed_buffs(width), - zeros(0), zero_buffs(width, &zeros), io_buffs(0) //resized later { |