From 4357f5d3c043245b5c086b20742795624af9f432 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 24 Feb 2011 16:35:29 -0800 Subject: uhd: replaced instanced of std::exception with the uhd exceptions --- host/lib/convert/gen_convert_pred.py | 9 +++++---- host/lib/device.cpp | 4 ++-- host/lib/exception.cpp | 1 + host/lib/ic_reg_maps/common.py | 4 ++-- host/lib/transport/gen_vrt_if_packet.py | 6 +++--- host/lib/transport/libusb1_base.cpp | 8 ++++---- host/lib/transport/usb_dummy_impl.cpp | 6 +++--- host/lib/types/device_addr.cpp | 2 +- host/lib/types/mac_addr.cpp | 4 ++-- host/lib/types/ranges.cpp | 8 ++++---- host/lib/usrp/dboard/db_basic_and_lf.cpp | 4 ++-- host/lib/usrp/dboard_base.cpp | 16 ++++++++-------- host/lib/usrp/dboard_manager.cpp | 6 +++--- host/lib/usrp/gps_ctrl.cpp | 2 +- host/lib/usrp/misc_utils.cpp | 8 ++++---- host/lib/usrp/multi_usrp.cpp | 3 +-- host/lib/usrp/subdev_spec.cpp | 4 ++-- host/lib/usrp/usrp1/dboard_iface.cpp | 2 +- host/lib/usrp/usrp1/mboard_impl.cpp | 6 +++--- host/lib/usrp/usrp2/codec_ctrl.cpp | 4 ++-- host/lib/usrp/usrp2/io_impl.cpp | 1 + host/lib/usrp/usrp2/mboard_impl.cpp | 12 ++++++------ host/lib/usrp/usrp2/usrp2_iface.cpp | 7 +++---- host/lib/usrp/usrp2/usrp2_impl.cpp | 3 ++- host/lib/usrp/usrp_e100/clock_ctrl.cpp | 2 +- host/lib/usrp/usrp_e100/dboard_iface.cpp | 2 +- host/lib/usrp/usrp_e100/fpga_downloader.cpp | 4 ++-- host/lib/usrp/usrp_e100/mboard_impl.cpp | 6 +++--- host/lib/usrp/usrp_e100/usrp_e100_iface.cpp | 6 +++--- host/lib/usrp/usrp_e100/usrp_e100_impl.cpp | 6 +++--- host/lib/utils/images.cpp | 4 ++-- host/lib/utils/load_modules.cpp | 10 +++++----- host/lib/utils/paths.cpp | 1 - host/lib/utils/thread_priority.cpp | 14 +++++++------- host/lib/utils/warning.cpp | 4 ++-- host/lib/wax.cpp | 9 +++++---- 36 files changed, 100 insertions(+), 98 deletions(-) (limited to 'host/lib') diff --git a/host/lib/convert/gen_convert_pred.py b/host/lib/convert/gen_convert_pred.py index d2f90bf41..360fbcf44 100644 --- a/host/lib/convert/gen_convert_pred.py +++ b/host/lib/convert/gen_convert_pred.py @@ -21,11 +21,11 @@ TMPL_TEXT = """ /*********************************************************************** * This file was generated by $file on $time.strftime("%c") **********************************************************************/ +\#include \#include \#include \#include \#include -\#include \#include \#include @@ -37,9 +37,10 @@ enum dir_type{ DIR_CPU_TO_OTW = 1 }; -struct pred_error : std::runtime_error{ - pred_error(const std::string &what) - :std::runtime_error("convert::make_pred: " + what){ +struct pred_error : uhd::value_error{ + pred_error(const std::string &what): + uhd::value_error("convert::make_pred: " + what) + { /* NOP */ } }; diff --git a/host/lib/device.cpp b/host/lib/device.cpp index 51c66680a..ad37743c1 100644 --- a/host/lib/device.cpp +++ b/host/lib/device.cpp @@ -105,14 +105,14 @@ device::sptr device::make(const device_addr_t &hint, size_t which){ //check that we found any devices if (dev_addr_makers.size() == 0){ - throw std::runtime_error(str( + throw uhd::key_error(str( boost::format("No devices found for ----->\n%s") % hint.to_pp_string() )); } //check that the which index is valid if (dev_addr_makers.size() <= which){ - throw std::runtime_error(str( + throw uhd::index_error(str( boost::format("No device at index %d for ----->\n%s") % which % hint.to_pp_string() )); } diff --git a/host/lib/exception.cpp b/host/lib/exception.cpp index 2299aa93f..e0d33bf48 100644 --- a/host/lib/exception.cpp +++ b/host/lib/exception.cpp @@ -38,6 +38,7 @@ make_exception_impl("AssertionError", assertion_error, exception) make_exception_impl("LookupError", lookup_error, exception) make_exception_impl("IndexError", index_error, lookup_error) make_exception_impl("KeyError", key_error, lookup_error) +make_exception_impl("TypeError", type_error, exception) make_exception_impl("ValueError", value_error, exception) make_exception_impl("RuntimeError", runtime_error, exception) make_exception_impl("NotImplementedError", not_implemented_error, runtime_error) diff --git a/host/lib/ic_reg_maps/common.py b/host/lib/ic_reg_maps/common.py index 986093004..a509936b4 100644 --- a/host/lib/ic_reg_maps/common.py +++ b/host/lib/ic_reg_maps/common.py @@ -30,8 +30,8 @@ COMMON_TMPL = """\ \#define INCLUDED_$(name.upper())_HPP \#include +\#include \#include -\#include \#include class $(name)_t{ @@ -69,7 +69,7 @@ public: } template std::set get_changed_addrs(void){ - if (_state == NULL) throw std::runtime_error("no saved state"); + if (_state == NULL) throw uhd::runtime_error("no saved state"); //check each register for changes std::set addrs; #for $reg in $regs 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 \#include \#include \#include -\#include \#include //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 aea1a2360..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 @@ -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/usb_dummy_impl.cpp b/host/lib/transport/usb_dummy_impl.cpp index 419a52279..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 @@ -28,12 +28,12 @@ std::vector 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/types/device_addr.cpp b/host/lib/types/device_addr.cpp index 7f2031272..193f76f8c 100644 --- a/host/lib/types/device_addr.cpp +++ b/host/lib/types/device_addr.cpp @@ -48,7 +48,7 @@ device_addr_t::device_addr_t(const std::string &args){ goto continue_next_arg; } } - throw std::runtime_error("invalid args string: "+args); + throw uhd::value_error("invalid args string: "+args); continue_next_arg: continue; } } diff --git a/host/lib/types/mac_addr.cpp b/host/lib/types/mac_addr.cpp index a65c8a45d..a5cb90f97 100644 --- a/host/lib/types/mac_addr.cpp +++ b/host/lib/types/mac_addr.cpp @@ -39,7 +39,7 @@ mac_addr_t mac_addr_t::from_string(const std::string &mac_addr_str){ try{ if (mac_addr_str.size() != 17){ - throw std::runtime_error("expected exactly 17 characters"); + throw uhd::value_error("expected exactly 17 characters"); } //split the mac addr hex string at the colons @@ -54,7 +54,7 @@ mac_addr_t mac_addr_t::from_string(const std::string &mac_addr_str){ } catch(std::exception const& e){ - throw std::runtime_error(str( + throw uhd::value_error(str( boost::format("Invalid mac address: %s\n\t%s") % mac_addr_str % e.what() )); } diff --git a/host/lib/types/ranges.cpp b/host/lib/types/ranges.cpp index 4a0d05d80..6e39bc688 100644 --- a/host/lib/types/ranges.cpp +++ b/host/lib/types/ranges.cpp @@ -16,10 +16,10 @@ // #include +#include #include #include #include -#include #include using namespace uhd; @@ -48,7 +48,7 @@ range_t::range_t( _impl(UHD_PIMPL_MAKE(impl, (start, stop, step))) { if (stop < start){ - throw std::invalid_argument("cannot make range where stop < start"); + throw uhd::value_error("cannot make range where stop < start"); } } @@ -78,11 +78,11 @@ const std::string range_t::to_pp_string(void) const{ **********************************************************************/ void check_meta_range_monotonic(const meta_range_t &mr){ if (mr.empty()){ - throw std::runtime_error("meta-range cannot be empty"); + throw uhd::value_error("meta-range cannot be empty"); } for (size_t i = 1; i < mr.size(); i++){ if (mr.at(i).start() < mr.at(i-1).stop()){ - throw std::runtime_error("meta-range is not monotonic"); + throw uhd::value_error("meta-range is not monotonic"); } } } diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp index 3de9adbec..3fffeab0c 100644 --- a/host/lib/usrp/dboard/db_basic_and_lf.cpp +++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp @@ -193,7 +193,7 @@ void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){ case SUBDEV_PROP_ANTENNA: if (val.as().empty()) return; - throw std::runtime_error("no selectable antennas on this board"); + throw uhd::value_error("no selectable antennas on this board"); case SUBDEV_PROP_FREQ: return; // it wont do you much good, but you can set it @@ -300,7 +300,7 @@ void basic_tx::tx_set(const wax::obj &key_, const wax::obj &val){ case SUBDEV_PROP_ANTENNA: if (val.as().empty()) return; - throw std::runtime_error("no selectable antennas on this board"); + throw uhd::value_error("no selectable antennas on this board"); case SUBDEV_PROP_FREQ: return; // it wont do you much good, but you can set it diff --git a/host/lib/usrp/dboard_base.cpp b/host/lib/usrp/dboard_base.cpp index 6c4e29d9e..999dd9ffc 100644 --- a/host/lib/usrp/dboard_base.cpp +++ b/host/lib/usrp/dboard_base.cpp @@ -59,12 +59,12 @@ dboard_id_t dboard_base::get_tx_id(void){ **********************************************************************/ xcvr_dboard_base::xcvr_dboard_base(ctor_args_t args) : dboard_base(args){ if (get_rx_id() == dboard_id_t::none()){ - throw std::runtime_error(str(boost::format( + throw uhd::runtime_error(str(boost::format( "cannot create xcvr board when the rx id is \"%s\"" ) % dboard_id_t::none().to_pp_string())); } if (get_tx_id() == dboard_id_t::none()){ - throw std::runtime_error(str(boost::format( + throw uhd::runtime_error(str(boost::format( "cannot create xcvr board when the tx id is \"%s\"" ) % dboard_id_t::none().to_pp_string())); } @@ -79,7 +79,7 @@ xcvr_dboard_base::~xcvr_dboard_base(void){ **********************************************************************/ rx_dboard_base::rx_dboard_base(ctor_args_t args) : dboard_base(args){ if (get_tx_id() != dboard_id_t::none()){ - throw std::runtime_error(str(boost::format( + throw uhd::runtime_error(str(boost::format( "cannot create rx board when the tx id is \"%s\"" " -> expected a tx id of \"%s\"" ) % get_tx_id().to_pp_string() % dboard_id_t::none().to_pp_string())); @@ -91,11 +91,11 @@ rx_dboard_base::~rx_dboard_base(void){ } void rx_dboard_base::tx_get(const wax::obj &, wax::obj &){ - throw std::runtime_error("cannot call tx_get on a rx dboard"); + throw uhd::runtime_error("cannot call tx_get on a rx dboard"); } void rx_dboard_base::tx_set(const wax::obj &, const wax::obj &){ - throw std::runtime_error("cannot call tx_set on a rx dboard"); + throw uhd::runtime_error("cannot call tx_set on a rx dboard"); } /*********************************************************************** @@ -103,7 +103,7 @@ void rx_dboard_base::tx_set(const wax::obj &, const wax::obj &){ **********************************************************************/ tx_dboard_base::tx_dboard_base(ctor_args_t args) : dboard_base(args){ if (get_rx_id() != dboard_id_t::none()){ - throw std::runtime_error(str(boost::format( + throw uhd::runtime_error(str(boost::format( "cannot create tx board when the rx id is \"%s\"" " -> expected a rx id of \"%s\"" ) % get_rx_id().to_pp_string() % dboard_id_t::none().to_pp_string())); @@ -115,9 +115,9 @@ tx_dboard_base::~tx_dboard_base(void){ } void tx_dboard_base::rx_get(const wax::obj &, wax::obj &){ - throw std::runtime_error("cannot call rx_get on a tx dboard"); + throw uhd::runtime_error("cannot call rx_get on a tx dboard"); } void tx_dboard_base::rx_set(const wax::obj &, const wax::obj &){ - throw std::runtime_error("cannot call rx_set on a tx dboard"); + throw uhd::runtime_error("cannot call rx_set on a tx dboard"); } diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index f9d43901d..9055905b1 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -50,7 +50,7 @@ void dboard_manager::register_dboard( ){ //std::cout << "registering: " << name << std::endl; if (get_id_to_args_map().has_key(dboard_id)){ - throw std::runtime_error(str(boost::format( + throw uhd::key_error(str(boost::format( "The dboard id %s is already registered to %s." ) % dboard_id.to_string() % dboard_id.to_pp_string())); } @@ -315,7 +315,7 @@ prop_names_t dboard_manager_impl::get_tx_subdev_names(void){ } wax::obj dboard_manager_impl::get_rx_subdev(const std::string &subdev_name){ - if (not _rx_dboards.has_key(subdev_name)) throw std::invalid_argument( + if (not _rx_dboards.has_key(subdev_name)) throw uhd::key_error( str(boost::format("Unknown rx subdev name %s") % subdev_name) ); //get a link to the rx subdev proxy @@ -323,7 +323,7 @@ wax::obj dboard_manager_impl::get_rx_subdev(const std::string &subdev_name){ } wax::obj dboard_manager_impl::get_tx_subdev(const std::string &subdev_name){ - if (not _tx_dboards.has_key(subdev_name)) throw std::invalid_argument( + if (not _tx_dboards.has_key(subdev_name)) throw uhd::key_error( str(boost::format("Unknown tx subdev name %s") % subdev_name) ); //get a link to the tx subdev proxy diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index e868568a0..e0ab6de90 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -167,7 +167,7 @@ public: break; case GPS_TYPE_NONE: default: - throw std::runtime_error("get_time(): Unsupported GPS or no GPS detected\n"); + throw uhd::runtime_error("get_time(): Unsupported GPS or no GPS detected\n"); break; } return now; diff --git a/host/lib/usrp/misc_utils.cpp b/host/lib/usrp/misc_utils.cpp index 9074c3fe6..6fcbdfe3d 100644 --- a/host/lib/usrp/misc_utils.cpp +++ b/host/lib/usrp/misc_utils.cpp @@ -167,7 +167,7 @@ static void verify_xx_subdev_spec( BOOST_FOREACH(subdev_spec_pair_t &pair, subdev_spec){ //empty db name means select dboard automatically if (pair.db_name.empty()){ - if (dboard_names.size() != 1) throw std::runtime_error( + if (dboard_names.size() != 1) throw uhd::value_error( "A daughterboard name must be provided for multi-slot motherboards: " + subdev_spec.to_string() ); pair.db_name = dboard_names.front(); @@ -178,7 +178,7 @@ static void verify_xx_subdev_spec( //empty sd name means select the subdev automatically if (pair.sd_name.empty()){ - if (subdev_names.size() != 1) throw std::runtime_error( + if (subdev_names.size() != 1) throw uhd::value_error( "A subdevice name must be provided for multi-subdev daughterboards: " + subdev_spec.to_string() ); pair.sd_name = subdev_names.front(); @@ -186,7 +186,7 @@ static void verify_xx_subdev_spec( uhd::assert_has(subdev_names, pair.sd_name, xx_type + " subdev name"); } }catch(const std::exception &e){ - throw std::runtime_error(str(boost::format( + throw uhd::value_error(str(boost::format( "Validate %s subdev spec failed: %s\n %s" ) % xx_type % subdev_spec.to_string() % e.what())); } @@ -200,7 +200,7 @@ static void verify_xx_subdev_spec( dboard[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)][SUBDEV_PROP_ENABLED] = enable; } catch(const std::exception &e){ - throw std::runtime_error(str(boost::format( + throw uhd::runtime_error(str(boost::format( "Cannot set enabled property on subdevice %s:%s\n %s" ) % db_name % sd_name % e.what())); } diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 3329ea4fe..0acc53397 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include using namespace uhd; @@ -153,7 +152,7 @@ public: while(true){ if (get_time_last_pps() != time_start_last_pps) break; if ((get_time_now() - time_start) > time_spec_t(1.1)){ - throw std::runtime_error( + throw uhd::runtime_error( "Board 0 may not be getting a PPS signal!\n" "No PPS detected within the time interval.\n" "See the application notes for your device.\n" diff --git a/host/lib/usrp/subdev_spec.cpp b/host/lib/usrp/subdev_spec.cpp index d5d950f1f..6912afec8 100644 --- a/host/lib/usrp/subdev_spec.cpp +++ b/host/lib/usrp/subdev_spec.cpp @@ -16,11 +16,11 @@ // #include +#include #include //for split #include #include #include -#include #include #include @@ -51,7 +51,7 @@ subdev_spec_t::subdev_spec_t(const std::string &markup){ switch(db_sd.size()){ case 1: this->push_back(subdev_spec_pair_t("", db_sd.front())); break; case 2: this->push_back(subdev_spec_pair_t(db_sd.front(), db_sd.back())); break; - default: throw std::runtime_error("invalid subdev-spec markup string: "+markup); + default: throw uhd::value_error("invalid subdev-spec markup string: "+markup); } } } diff --git a/host/lib/usrp/usrp1/dboard_iface.cpp b/host/lib/usrp/usrp1/dboard_iface.cpp index 67da51ee9..53ccd4d55 100644 --- a/host/lib/usrp/usrp1/dboard_iface.cpp +++ b/host/lib/usrp/usrp1/dboard_iface.cpp @@ -329,7 +329,7 @@ static boost::uint32_t unit_to_otw_spi_dev(dboard_iface::unit_t unit, else break; } - throw std::invalid_argument("unknown unit type"); + UHD_THROW_INVALID_CODE_PATH(); } void usrp1_dboard_iface::write_spi(unit_t unit, diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp index 9f0512d6d..4e2fad6e5 100644 --- a/host/lib/usrp/usrp1/mboard_impl.cpp +++ b/host/lib/usrp/usrp1/mboard_impl.cpp @@ -161,7 +161,7 @@ static boost::uint32_t calc_tx_mux( //sanity check, only 1 channel per slot slot_to_chan_count[pair.db_name]++; if (slot_to_chan_count[pair.db_name] > 1){ - throw std::runtime_error(str(boost::format( + throw uhd::value_error(str(boost::format( "dboard slot %s assigned to multiple channels in subdev spec %s" ) % pair.db_name % subdev_spec.to_string())); } @@ -343,7 +343,7 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val) case MBOARD_PROP_RX_SUBDEV_SPEC: _rx_subdev_spec = val.as(); if (_rx_subdev_spec.size() > this->get_num_ddcs()){ - throw std::runtime_error(str(boost::format( + throw uhd::value_error(str(boost::format( "USRP1 suports up to %u RX channels.\n" "However, this RX subdev spec requires %u channels\n" ) % this->get_num_ddcs() % _rx_subdev_spec.size())); @@ -356,7 +356,7 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val) case MBOARD_PROP_TX_SUBDEV_SPEC: _tx_subdev_spec = val.as(); if (_tx_subdev_spec.size() > this->get_num_ducs()){ - throw std::runtime_error(str(boost::format( + throw uhd::value_error(str(boost::format( "USRP1 suports up to %u TX channels.\n" "However, this TX subdev spec requires %u channels\n" ) % this->get_num_ducs() % _tx_subdev_spec.size())); diff --git a/host/lib/usrp/usrp2/codec_ctrl.cpp b/host/lib/usrp/usrp2/codec_ctrl.cpp index 0756c7971..be5c2c899 100644 --- a/host/lib/usrp/usrp2/codec_ctrl.cpp +++ b/host/lib/usrp/usrp2/codec_ctrl.cpp @@ -19,10 +19,10 @@ #include "ad9777_regs.hpp" #include "ads62p44_regs.hpp" #include "usrp2_regs.hpp" +#include #include #include #include -#include static const bool codec_ctrl_debug = false; @@ -118,7 +118,7 @@ public: case 2: _ad9777_regs.modulation_mode = ad9777_regs_t::MODULATION_MODE_FS_2; break; case 4: _ad9777_regs.modulation_mode = ad9777_regs_t::MODULATION_MODE_FS_4; break; case 8: _ad9777_regs.modulation_mode = ad9777_regs_t::MODULATION_MODE_FS_8; break; - default: throw std::runtime_error("unknown modulation mode for ad9777"); + default: throw uhd::value_error("unknown modulation mode for ad9777"); } this->send_ad9777_reg(0x01); //set the register diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index b4f3e0873..082d77d3e 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -18,6 +18,7 @@ #include "../../transport/vrt_packet_handler.hpp" #include "usrp2_impl.hpp" #include "usrp2_regs.hpp" +#include #include #include #include diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index f59b7b7dd..9049d4025 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -17,12 +17,12 @@ #include "usrp2_impl.hpp" #include "usrp2_regs.hpp" +#include #include #include #include #include #include -#include #include #include #include @@ -118,7 +118,7 @@ usrp2_mboard_impl::usrp2_mboard_impl( else if (device_addr["mimo_mode"] == "slave"){ _mimo_clocking_mode_is_master = false; } - else throw std::runtime_error( + else throw uhd::value_error( "mimo_mode must be set to master or slave" ); } @@ -170,14 +170,14 @@ void usrp2_mboard_impl::update_clock_config(void){ //translate pps source enums switch(_clock_config.pps_source){ case clock_config_t::PPS_SMA: pps_flags |= U2_FLAG_TIME64_PPS_SMA; break; - default: throw std::runtime_error("unhandled clock configuration pps source"); + default: throw uhd::value_error("unhandled clock configuration pps source"); } //translate pps polarity enums switch(_clock_config.pps_polarity){ case clock_config_t::PPS_POS: pps_flags |= U2_FLAG_TIME64_PPS_POSEDGE; break; case clock_config_t::PPS_NEG: pps_flags |= U2_FLAG_TIME64_PPS_NEGEDGE; break; - default: throw std::runtime_error("unhandled clock configuration pps polarity"); + default: throw uhd::value_error("unhandled clock configuration pps polarity"); } //set the pps flags @@ -190,7 +190,7 @@ void usrp2_mboard_impl::update_clock_config(void){ switch(_clock_config.ref_source){ case clock_config_t::REF_INT : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x12); break; case clock_config_t::REF_SMA : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x1C); break; - default: throw std::runtime_error("unhandled clock configuration reference source"); + default: throw uhd::value_error("unhandled clock configuration reference source"); } _clock_ctrl->enable_external_ref(true); //USRP2P has an internal 10MHz TCXO break; @@ -200,7 +200,7 @@ void usrp2_mboard_impl::update_clock_config(void){ switch(_clock_config.ref_source){ case clock_config_t::REF_INT : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x10); break; case clock_config_t::REF_SMA : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x1C); break; - default: throw std::runtime_error("unhandled clock configuration reference source"); + default: throw uhd::value_error("unhandled clock configuration reference source"); } _clock_ctrl->enable_external_ref(_clock_config.ref_source != clock_config_t::REF_INT); break; diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 462ebab16..3a7ed8351 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include using namespace uhd; @@ -63,7 +62,7 @@ public: //check the fpga compatibility number const boost::uint32_t fpga_compat_num = this->peek32(this->regs.compat_num_rb); if (fpga_compat_num != USRP2_FPGA_COMPAT_NUM){ - throw std::runtime_error(str(boost::format( + throw uhd::runtime_error(str(boost::format( "Expected fpga compatibility number %d, but got %d:\n" "The fpga build is not compatible with the host code build." ) % int(USRP2_FPGA_COMPAT_NUM) % fpga_compat_num)); @@ -245,7 +244,7 @@ public: while(true){ size_t len = _ctrl_transport->recv(boost::asio::buffer(usrp2_ctrl_data_in_mem), CTRL_RECV_TIMEOUT); if(len >= sizeof(boost::uint32_t) and ntohl(ctrl_data_in->proto_ver) != USRP2_FW_COMPAT_NUM){ - throw std::runtime_error(str(boost::format( + throw uhd::runtime_error(str(boost::format( "Expected protocol compatibility number %d, but got %d:\n" "The firmware build is not compatible with the host code build." ) % int(USRP2_FW_COMPAT_NUM) % ntohl(ctrl_data_in->proto_ver))); @@ -256,7 +255,7 @@ public: if (len == 0) break; //timeout //didnt get seq or bad packet, continue looking... } - throw std::runtime_error("no control response"); + throw uhd::runtime_error("no control response"); } rev_type get_rev(void){ diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index afd73401f..0a23e3eff 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -16,6 +16,7 @@ // #include "usrp2_impl.hpp" +#include #include #include #include @@ -47,7 +48,7 @@ static device_addrs_t usrp2_find(const device_addr_t &hint_){ device_addrs_t found_devices; BOOST_FOREACH(const device_addr_t &hint_i, hints){ device_addrs_t found_devices_i = usrp2_find(hint_i); - if (found_devices_i.size() != 1) throw std::runtime_error(str(boost::format( + if (found_devices_i.size() != 1) throw uhd::value_error(str(boost::format( "Could not resolve device hint \"%s\" to a single device." ) % hint_i.to_string())); found_devices.push_back(found_devices_i[0]); diff --git a/host/lib/usrp/usrp_e100/clock_ctrl.cpp b/host/lib/usrp/usrp_e100/clock_ctrl.cpp index 6128894cc..b4ddcd271 100644 --- a/host/lib/usrp/usrp_e100/clock_ctrl.cpp +++ b/host/lib/usrp/usrp_e100/clock_ctrl.cpp @@ -158,7 +158,7 @@ static clock_settings_type get_clock_settings(double rate){ } } - throw std::runtime_error(str(boost::format( + throw uhd::value_error(str(boost::format( "USRP-E100 clock control: could not calculate settings for clock rate %fMHz" ) % (rate/1e6))); } diff --git a/host/lib/usrp/usrp_e100/dboard_iface.cpp b/host/lib/usrp/usrp_e100/dboard_iface.cpp index ee6ca3933..ee1b852bf 100644 --- a/host/lib/usrp/usrp_e100/dboard_iface.cpp +++ b/host/lib/usrp/usrp_e100/dboard_iface.cpp @@ -235,7 +235,7 @@ static boost::uint32_t unit_to_otw_spi_dev(dboard_iface::unit_t unit){ case dboard_iface::UNIT_TX: return UE_SPI_SS_TX_DB; case dboard_iface::UNIT_RX: return UE_SPI_SS_RX_DB; } - throw std::invalid_argument("unknown unit type"); + UHD_THROW_INVALID_CODE_PATH(); } void usrp_e100_dboard_iface::write_spi( diff --git a/host/lib/usrp/usrp_e100/fpga_downloader.cpp b/host/lib/usrp/usrp_e100/fpga_downloader.cpp index 9836cbc02..95665da83 100644 --- a/host/lib/usrp/usrp_e100/fpga_downloader.cpp +++ b/host/lib/usrp/usrp_e100/fpga_downloader.cpp @@ -87,7 +87,7 @@ gpio::gpio(unsigned int gpio_num, gpio_direction pin_direction) std::fstream export_file; export_file.open("/sys/class/gpio/export", std::ios::out); - if (not export_file.is_open()) throw std::runtime_error( + if (not export_file.is_open()) throw uhd::os_error( "Failed to open gpio export file." ); @@ -211,7 +211,7 @@ static void send_file_to_fpga(const std::string &file_name, gpio &error, gpio &d std::ifstream bitstream; bitstream.open(file_name.c_str(), std::ios::binary); - if (!bitstream.is_open()) throw std::runtime_error( + if (!bitstream.is_open()) throw uhd::os_error( "Coult not open the file: " + file_name ); diff --git a/host/lib/usrp/usrp_e100/mboard_impl.cpp b/host/lib/usrp/usrp_e100/mboard_impl.cpp index 07476bd6c..cec4fd0ad 100644 --- a/host/lib/usrp/usrp_e100/mboard_impl.cpp +++ b/host/lib/usrp/usrp_e100/mboard_impl.cpp @@ -17,9 +17,9 @@ #include "usrp_e100_impl.hpp" #include "usrp_e100_regs.hpp" +#include #include #include -#include #include #include #include @@ -53,7 +53,7 @@ void usrp_e100_impl::update_clock_config(void){ switch(_clock_config.pps_polarity){ case clock_config_t::PPS_POS: pps_flags |= UE_FLAG_TIME64_PPS_POSEDGE; break; case clock_config_t::PPS_NEG: pps_flags |= UE_FLAG_TIME64_PPS_NEGEDGE; break; - default: throw std::runtime_error("unhandled clock configuration pps polarity"); + default: throw uhd::value_error("unhandled clock configuration pps polarity"); } //set the pps flags @@ -64,7 +64,7 @@ void usrp_e100_impl::update_clock_config(void){ case clock_config_t::REF_AUTO: _clock_ctrl->use_auto_ref(); break; case clock_config_t::REF_INT: _clock_ctrl->use_internal_ref(); break; case clock_config_t::REF_SMA: _clock_ctrl->use_auto_ref(); break; - default: throw std::runtime_error("unhandled clock configuration ref source"); + default: throw uhd::value_error("unhandled clock configuration ref source"); } } diff --git a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp index 687008df8..076ec2fd6 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp @@ -37,7 +37,7 @@ class i2c_dev_iface : public i2c_iface{ public: i2c_dev_iface(const std::string &node){ if ((_node_fd = ::open(node.c_str(), O_RDWR)) < 0){ - throw std::runtime_error("Failed to open " + node); + throw uhd::io_error("Failed to open " + node); } } @@ -106,7 +106,7 @@ public: { //open the device node and check file descriptor if ((_node_fd = ::open(node.c_str(), O_RDWR)) < 0){ - throw std::runtime_error("Failed to open " + node); + throw uhd::io_error("Failed to open " + node); } //very first thing, reset all the wishbone, always do first! @@ -127,7 +127,7 @@ public: boost::mutex::scoped_lock lock(_ctrl_mutex); if (::ioctl(_node_fd, request, mem) < 0){ - throw std::runtime_error(str( + throw uhd::os_error(str( boost::format("ioctl failed with request %d") % request )); } diff --git a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp b/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp index d4404fc88..1385688e0 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_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 @@ -103,7 +103,7 @@ static device::sptr usrp_e100_make(const device_addr_t &device_addr){ size_t fpga_hash = 0; { std::ifstream file(usrp_e100_fpga_image.c_str()); - if (not file.good()) throw std::runtime_error( + if (not file.good()) throw uhd::io_error( "cannot open fpga file for read: " + usrp_e100_fpga_image ); do{ @@ -132,7 +132,7 @@ static device::sptr usrp_e100_make(const device_addr_t &device_addr){ //check that the compatibility is correct fpga_compat_num = iface->peek16(UE_REG_MISC_COMPAT); if (fpga_compat_num != USRP_E_COMPAT_NUM){ - throw std::runtime_error(str(boost::format( + throw uhd::runtime_error(str(boost::format( "Expected fpga compatibility number 0x%x, but got 0x%x:\n" "The fpga build is not compatible with the host code build." ) % USRP_E_COMPAT_NUM % fpga_compat_num)); diff --git a/host/lib/utils/images.cpp b/host/lib/utils/images.cpp index 395e542c1..3756f035a 100644 --- a/host/lib/utils/images.cpp +++ b/host/lib/utils/images.cpp @@ -16,9 +16,9 @@ // #include +#include #include #include -#include #include namespace fs = boost::filesystem; @@ -36,5 +36,5 @@ std::string uhd::find_image_path(const std::string &image_name){ fs::path image_path = path / image_name; if (fs::exists(image_path)) return image_path.file_string(); } - throw std::runtime_error("Could not find path for image: " + image_name); + throw uhd::io_error("Could not find path for image: " + image_name); } diff --git a/host/lib/utils/load_modules.cpp b/host/lib/utils/load_modules.cpp index fa9b22438..ad39960bb 100644 --- a/host/lib/utils/load_modules.cpp +++ b/host/lib/utils/load_modules.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,11 +16,11 @@ // #include +#include #include #include #include #include -#include #include #include @@ -33,7 +33,7 @@ namespace fs = boost::filesystem; #include static void load_module(const std::string &file_name){ if (dlopen(file_name.c_str(), RTLD_LAZY) == NULL){ - throw std::runtime_error(str( + throw uhd::os_error(str( boost::format("dlopen failed to load \"%s\"") % file_name )); } @@ -45,7 +45,7 @@ static void load_module(const std::string &file_name){ #include static void load_module(const std::string &file_name){ if (LoadLibrary(file_name.c_str()) == NULL){ - throw std::runtime_error(str( + throw uhd::os_error(str( boost::format("LoadLibrary failed to load \"%s\"") % file_name )); } @@ -55,7 +55,7 @@ static void load_module(const std::string &file_name){ #ifdef HAVE_LOAD_MODULES_DUMMY static void load_module(const std::string &file_name){ - throw std::runtime_error(str( + throw uhd::not_implemented_error(str( boost::format("Module loading not supported: Cannot load \"%s\"") % file_name )); } diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 8d604d849..329695873 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include diff --git a/host/lib/utils/thread_priority.cpp b/host/lib/utils/thread_priority.cpp index 18f372ec0..bd34055e8 100644 --- a/host/lib/utils/thread_priority.cpp +++ b/host/lib/utils/thread_priority.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 @@ -17,8 +17,8 @@ #include #include +#include #include -#include #include bool uhd::set_thread_priority_safe(float priority, bool realtime){ @@ -59,13 +59,13 @@ static void check_priority_range(float priority){ //get the priority bounds for the selected policy int min_pri = sched_get_priority_min(policy); int max_pri = sched_get_priority_max(policy); - if (min_pri == -1 or max_pri == -1) throw std::runtime_error("error in sched_get_priority_min/max"); + if (min_pri == -1 or max_pri == -1) throw uhd::os_error("error in sched_get_priority_min/max"); //set the new priority and policy sched_param sp; sp.sched_priority = int(priority*(max_pri - min_pri)) + min_pri; int ret = pthread_setschedparam(pthread_self(), policy, &sp); - if (ret != 0) throw std::runtime_error("error in pthread_setschedparam"); + if (ret != 0) throw uhd::os_error("error in pthread_setschedparam"); } #endif /* HAVE_PTHREAD_SETSCHEDPARAM */ @@ -81,7 +81,7 @@ static void check_priority_range(float priority){ //set the priority class on the process int pri_class = (realtime)? REALTIME_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS; if (SetPriorityClass(GetCurrentProcess(), pri_class) == 0) - throw std::runtime_error("error in SetPriorityClass"); + throw uhd::os_error("error in SetPriorityClass"); //scale the priority value to the constants int priorities[] = { @@ -92,7 +92,7 @@ static void check_priority_range(float priority){ //set the thread priority on the thread if (SetThreadPriority(GetCurrentThread(), priorities[pri_index]) == 0) - throw std::runtime_error("error in SetThreadPriority"); + throw uhd::os_error("error in SetThreadPriority"); } #endif /* HAVE_WIN_SETTHREADPRIORITY */ @@ -101,7 +101,7 @@ static void check_priority_range(float priority){ **********************************************************************/ #ifdef HAVE_LOAD_MODULES_DUMMY void uhd::set_thread_priority(float, bool){ - throw std::runtime_error("set thread priority not implemented"); + throw uhd::not_implemented_error("set thread priority not implemented"); } #endif /* HAVE_LOAD_MODULES_DUMMY */ diff --git a/host/lib/utils/warning.cpp b/host/lib/utils/warning.cpp index bc4c79b6e..6a94a0a2c 100644 --- a/host/lib/utils/warning.cpp +++ b/host/lib/utils/warning.cpp @@ -16,12 +16,12 @@ // #include +#include #include #include #include #include #include -#include #include #include @@ -76,7 +76,7 @@ void warning::register_handler( } warning::handler_t warning::unregister_handler(const std::string &name){ - if (not get_registry().has_key(name)) throw std::runtime_error( + if (not get_registry().has_key(name)) throw uhd::key_error( "The warning registry does not have a handler registered to " + name ); return get_registry().pop(name); diff --git a/host/lib/wax.cpp b/host/lib/wax.cpp index 0e2e82a3a..5f658acd8 100644 --- a/host/lib/wax.cpp +++ b/host/lib/wax.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,6 +16,7 @@ // #include +#include #include #include @@ -97,7 +98,7 @@ wax::obj wax::obj::operator[](const obj &key){ return val.as()()[key]; } //unknown obj - throw std::runtime_error("cannot use [] on non wax::obj link"); + throw uhd::type_error("cannot use [] on non wax::obj link"); } else{ return proxy_args_t(this, key); @@ -142,9 +143,9 @@ boost::any wax::obj::resolve(void) const{ } void wax::obj::get(const obj &, obj &){ - throw std::runtime_error("Cannot call get on wax obj base class"); + throw uhd::type_error("Cannot call get on wax obj base class"); } void wax::obj::set(const obj &, const obj &){ - throw std::runtime_error("Cannot call set on wax obj base class"); + throw uhd::type_error("Cannot call set on wax obj base class"); } -- cgit v1.2.3