From 7d140b0237b3fa4e07b364e912887f68c02839cb Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 10 Mar 2011 12:49:05 -0800 Subject: usrp2: created safe call macro and handle usrp2 ~mboard throwing --- host/lib/usrp/usrp2/mboard_impl.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'host/lib') 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 #include #include #include @@ -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();) } /*********************************************************************** -- cgit v1.2.3