From 6fdaccea1fba15b754945d9be7da0ed4a3861633 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 18 Feb 2010 17:48:14 -0800 Subject: Added special case for empty dboard slot (none id 0xffff) Added error handling in the dboard base classes for mishandling the none id. Added better to string function for the dboard ids. Added get methods for dboard classes to get their ids. --- host/lib/usrp/dboard/base.cpp | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'host/lib/usrp/dboard/base.cpp') diff --git a/host/lib/usrp/dboard/base.cpp b/host/lib/usrp/dboard/base.cpp index de8db323a..92a886407 100644 --- a/host/lib/usrp/dboard/base.cpp +++ b/host/lib/usrp/dboard/base.cpp @@ -16,6 +16,7 @@ // #include +#include #include using namespace uhd::usrp::dboard; @@ -24,7 +25,7 @@ using namespace uhd::usrp::dboard; * base dboard base class **********************************************************************/ base::base(ctor_args_t const& args){ - boost::tie(_subdev_name, _dboard_interface) = args; + boost::tie(_subdev_name, _dboard_interface, _rx_id, _tx_id) = args; } base::~base(void){ @@ -39,11 +40,28 @@ interface::sptr base::get_interface(void){ return _dboard_interface; } +dboard_id_t base::get_rx_id(void){ + return _rx_id; +} + +dboard_id_t base::get_tx_id(void){ + return _tx_id; +} + /*********************************************************************** * xcvr dboard base class **********************************************************************/ xcvr_base::xcvr_base(ctor_args_t const& args) : base(args){ - /* NOP */ + if (get_rx_id() == ID_NONE){ + throw std::runtime_error(str(boost::format( + "cannot create xcvr board when the rx id is \"%s\"" + ) % id::to_string(ID_NONE))); + } + if (get_tx_id() == ID_NONE){ + throw std::runtime_error(str(boost::format( + "cannot create xcvr board when the tx id is \"%s\"" + ) % id::to_string(ID_NONE))); + } } xcvr_base::~xcvr_base(void){ @@ -54,7 +72,12 @@ xcvr_base::~xcvr_base(void){ * rx dboard base class **********************************************************************/ rx_base::rx_base(ctor_args_t const& args) : base(args){ - /* NOP */ + if (get_tx_id() != ID_NONE){ + throw std::runtime_error(str(boost::format( + "cannot create rx board when the tx id is \"%s\"" + " -> expected a tx id of \"%s\"" + ) % id::to_string(get_tx_id()) % id::to_string(ID_NONE))); + } } rx_base::~rx_base(void){ @@ -73,7 +96,12 @@ void rx_base::tx_set(const wax::obj &, const wax::obj &){ * tx dboard base class **********************************************************************/ tx_base::tx_base(ctor_args_t const& args) : base(args){ - /* NOP */ + if (get_rx_id() != ID_NONE){ + throw std::runtime_error(str(boost::format( + "cannot create tx board when the rx id is \"%s\"" + " -> expected a rx id of \"%s\"" + ) % id::to_string(get_rx_id()) % id::to_string(ID_NONE))); + } } tx_base::~tx_base(void){ -- cgit v1.2.3