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:49:05 -0800
commite2847fd99c83dab4c3ba08b1b31edf6d459c9e2e (patch)
treef6afccb36603338e71ec66df7614f6458f8e01b3 /host/lib
parentaa619a76943c2c66060eb0673cd74d601caa08ba (diff)
downloaduhd-e2847fd99c83dab4c3ba08b1b31edf6d459c9e2e.tar.gz
uhd-e2847fd99c83dab4c3ba08b1b31edf6d459c9e2e.tar.bz2
uhd-e2847fd99c83dab4c3ba08b1b31edf6d459c9e2e.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 0a6fefca6..40fc5098b 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/exception.hpp>
#include <uhd/usrp/gps_ctrl.hpp>
#include <uhd/usrp/misc_utils.hpp>
@@ -158,8 +159,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();)
}
/***********************************************************************