aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/dboard/base.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-02-18 17:48:14 -0800
committerJosh Blum <josh@joshknows.com>2010-02-18 17:48:14 -0800
commit6fdaccea1fba15b754945d9be7da0ed4a3861633 (patch)
treea5822f02409cc2d69f0566b4ea6e787b0d8ca43d /host/lib/usrp/dboard/base.cpp
parentb4e5df4080b276ff1bf7cf896bd60630cdaab652 (diff)
downloaduhd-6fdaccea1fba15b754945d9be7da0ed4a3861633.tar.gz
uhd-6fdaccea1fba15b754945d9be7da0ed4a3861633.tar.bz2
uhd-6fdaccea1fba15b754945d9be7da0ed4a3861633.zip
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.
Diffstat (limited to 'host/lib/usrp/dboard/base.cpp')
-rw-r--r--host/lib/usrp/dboard/base.cpp36
1 files changed, 32 insertions, 4 deletions
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 <uhd/usrp/dboard/base.hpp>
+#include <boost/format.hpp>
#include <stdexcept>
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){