From ba6e9e801cb45b060c4d33351dd6aed1a7cf08c8 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 17 Nov 2017 12:04:02 -0800 Subject: mpm: n310: Made n310.__init__() more exception-safe --- mpm/python/usrp_mpm/periph_manager/n310.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'mpm/python') diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py index ecce1bd77..08f6b8c22 100644 --- a/mpm/python/usrp_mpm/periph_manager/n310.py +++ b/mpm/python/usrp_mpm/periph_manager/n310.py @@ -482,7 +482,21 @@ class n310(PeriphManagerBase): def __init__(self, args): super(n310, self).__init__(args) - self.sid_endpoints = {} + self._device_initialized = False + self._ext_clock_freq = None + self._clock_source = None + self._time_source = None + try: + self._init_peripherals(args) + self._device_initialized = True + except Exception as ex: + self.log.error("Failed to initialize motherboard: %s", str(ex)) + + def _init_peripherals(self, args): + """ + Turn on all peripherals. This may throw an error on failure, so make + sure to catch it. + """ # Init peripherals self.log.trace("Initializing TCA6424 port expander controls...") self._gpios = TCA6424(int(self.mboard_info['rev'])) -- cgit v1.2.3