summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-03-10 12:49:05 -0800
committerJosh Blum <josh@joshknows.com>2011-03-10 12:52:13 -0800
commit7d140b0237b3fa4e07b364e912887f68c02839cb (patch)
tree5941c9317559716f23ec548e6dda2615b39aef50 /host/lib
parent5f4e14e87e03d6b69d67e73240b5aa713e337df0 (diff)
downloaduhd-7d140b0237b3fa4e07b364e912887f68c02839cb.tar.gz
uhd-7d140b0237b3fa4e07b364e912887f68c02839cb.tar.bz2
uhd-7d140b0237b3fa4e07b364e912887f68c02839cb.zip
usrp2: created safe call macro and handle usrp2 ~mboard throwing
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index f20d3ab46..92a7b2f93 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -18,6 +18,7 @@
#include "usrp2_impl.hpp"
#include "usrp2_regs.hpp"
#include "fw_common.h"
+#include <uhd/utils/safe_call.hpp>
#include <uhd/usrp/gps_ctrl.hpp>
#include <uhd/usrp/misc_utils.hpp>
#include <uhd/usrp/dsp_utils.hpp>
@@ -169,8 +170,16 @@ usrp2_mboard_impl::usrp2_mboard_impl(
}
usrp2_mboard_impl::~usrp2_mboard_impl(void){
- _iface->poke32(_iface->regs.tx_ctrl_cycles_per_up, 0);
- _iface->poke32(_iface->regs.tx_ctrl_packets_per_up, 0);
+ //Safely destruct all RAII objects in an mboard.
+ //This prevents the mboard deconstructor from throwing,
+ //which allows the device to be safely deconstructed.
+ UHD_SAFE_CALL(_iface->poke32(_iface->regs.tx_ctrl_cycles_per_up, 0);)
+ UHD_SAFE_CALL(_iface->poke32(_iface->regs.tx_ctrl_packets_per_up, 0);)
+ UHD_SAFE_CALL(_dboard_manager.reset();)
+ UHD_SAFE_CALL(_dboard_iface.reset();)
+ UHD_SAFE_CALL(_codec_ctrl.reset();)
+ UHD_SAFE_CALL(_clock_ctrl.reset();)
+ UHD_SAFE_CALL(_gps_ctrl.reset();)
}
/***********************************************************************