aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-10-12 18:23:37 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:04:02 -0800
commite212936218481b99a3f2e6283501ee6beaaa4d5a (patch)
treed227af5f6fadf7d7ae9c97ea381985124459c6a7 /mpm
parentbe7e72ed1dc8d46583c2ed7f5a1824e3efee4e23 (diff)
downloaduhd-e212936218481b99a3f2e6283501ee6beaaa4d5a.tar.gz
uhd-e212936218481b99a3f2e6283501ee6beaaa4d5a.tar.bz2
uhd-e212936218481b99a3f2e6283501ee6beaaa4d5a.zip
mpm: mg: Minor cleanup in __init__
- Moved AD9371 API generation around - Fixed some PyLint warnings
Diffstat (limited to 'mpm')
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/magnesium.py32
1 files changed, 26 insertions, 6 deletions
diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py
index 7ee840761..48934af1f 100644
--- a/mpm/python/usrp_mpm/dboard_manager/magnesium.py
+++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py
@@ -220,10 +220,13 @@ class Magnesium(DboardManagerBase):
def __init__(self, slot_idx, **kwargs):
super(Magnesium, self).__init__(slot_idx, **kwargs)
self.log = get_logger("Magnesium-{}".format(slot_idx))
- self.log.trace("Initializing Magnesium daughterboard, slot index {}".format(self.slot_idx))
+ self.log.trace("Initializing Magnesium daughterboard, slot index %d",
+ self.slot_idx)
self.rev = int(self.device_info['rev'])
self.log.trace("This is a rev: {}".format(chr(65 + self.rev)))
- self.ref_clock_freq = 10e6 # TODO: make this not fixed
+ # This is a default ref clock freq, it must be updated before init() is
+ # called!
+ self.ref_clock_freq = 10e6
self._power_on()
self.log.debug("Loading C++ drivers...")
self._device = lib.dboards.magnesium_manager(
@@ -231,14 +234,31 @@ class Magnesium(DboardManagerBase):
)
self.mykonos = self._device.get_radio_ctrl()
self.log.debug("Loaded C++ drivers.")
-
- for mykfuncname in [x for x in dir(self.mykonos) if not x.startswith("_") and callable(getattr(self.mykonos, x))]:
- self.log.trace("adding {}".format(mykfuncname))
- setattr(self, mykfuncname, self._get_mykonos_function(mykfuncname))
+ self._init_myk_api(self.mykonos)
self.eeprom_fs, self.eeprom_path = self._init_user_eeprom(
self.user_eeprom[self.rev]
)
+ def _init_myk_api(self, myk):
+ """
+ Propagate the C++ Mykonos API into Python land.
+ """
+ def export_method(obj, method):
+ " Export a method object, including docstring "
+ meth_obj = getattr(obj, method)
+ def func(*args):
+ " Functor for storing docstring too "
+ return meth_obj(*args)
+ func.__doc__ = meth_obj.__doc__
+ return func
+ self.log.trace("Forwarding AD9371 methods to Magnesium class...")
+ for method in [
+ x for x in dir(self.mykonos)
+ if not x.startswith("_") and \
+ callable(getattr(self.mykonos, x))]:
+ self.log.trace("adding {}".format(method))
+ setattr(self, method, export_method(myk, method))
+
def _init_user_eeprom(self, eeprom_info):
"""
Reads out user-data EEPROM, and intializes a BufferFS object from that.