aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm/dboard_manager
diff options
context:
space:
mode:
authorAndrej Rode <andrej.rode@ettus.com>2017-03-27 18:03:52 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:45 -0800
commit6a12add1560545438e1bebc05efbafd05aace4f9 (patch)
treec94dbbbd4da0c7ef41fc8849f174875a13f0b511 /mpm/python/usrp_mpm/dboard_manager
parentba4fad345d7489b40a7dab83842ac21d13c4f460 (diff)
downloaduhd-6a12add1560545438e1bebc05efbafd05aace4f9.tar.gz
uhd-6a12add1560545438e1bebc05efbafd05aace4f9.tar.bz2
uhd-6a12add1560545438e1bebc05efbafd05aace4f9.zip
mpm: mpm reorganization
Diffstat (limited to 'mpm/python/usrp_mpm/dboard_manager')
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/CMakeLists.txt1
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/__init__.py10
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/base.py10
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/eiscat.py8
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/magnesium.py32
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/test.py10
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/unknown.py9
7 files changed, 52 insertions, 28 deletions
diff --git a/mpm/python/usrp_mpm/dboard_manager/CMakeLists.txt b/mpm/python/usrp_mpm/dboard_manager/CMakeLists.txt
index b642d506e..9cd65fa08 100644
--- a/mpm/python/usrp_mpm/dboard_manager/CMakeLists.txt
+++ b/mpm/python/usrp_mpm/dboard_manager/CMakeLists.txt
@@ -22,6 +22,7 @@ SET(USRP_MPM_FILES ${USRP_MPM_FILES})
SET(USRP_MPM_DBMGR_FILES
${CMAKE_CURRENT_SOURCE_DIR}/__init__.py
${CMAKE_CURRENT_SOURCE_DIR}/base.py
+ ${CMAKE_CURRENT_SOURCE_DIR}/test.py
${CMAKE_CURRENT_SOURCE_DIR}/magnesium.py
${CMAKE_CURRENT_SOURCE_DIR}/eiscat.py
${CMAKE_CURRENT_SOURCE_DIR}/unknown.py
diff --git a/mpm/python/usrp_mpm/dboard_manager/__init__.py b/mpm/python/usrp_mpm/dboard_manager/__init__.py
index 02746e78f..f21e5258c 100644
--- a/mpm/python/usrp_mpm/dboard_manager/__init__.py
+++ b/mpm/python/usrp_mpm/dboard_manager/__init__.py
@@ -18,12 +18,12 @@
dboards module __init__.py
"""
from .. import libpyusrp_periphs as lib
-from magnesium import magnesium
-from eiscat import eiscat
-from test import test
-from unknown import unknown
+from .magnesium import magnesium
+from .eiscat import eiscat
+from .test import test
+from .unknown import unknown
-hw_pids = {
+HW_PIDS = {
eiscat.hw_pid: eiscat,
magnesium.hw_pid: magnesium,
}
diff --git a/mpm/python/usrp_mpm/dboard_manager/base.py b/mpm/python/usrp_mpm/dboard_manager/base.py
index 257a2424d..37e7dd2b8 100644
--- a/mpm/python/usrp_mpm/dboard_manager/base.py
+++ b/mpm/python/usrp_mpm/dboard_manager/base.py
@@ -17,22 +17,22 @@
"""
dboard base implementation module
"""
-from . import lib
import logging
import struct
-log = logging.Logger("usrp_mpm.dboards")
+LOG = logging.Logger(__name__)
-class dboard_manager(object):
+class DboardManagerBase(object):
"""
Holds shared pointer to wrapped C++ implementation.
Sanitizes arguments before calling C++ functions.
Ties various constants to specific daughterboard class
"""
_eeprom = {}
- def __init__(self, eeprom={}):
- self._eeprom = eeprom
+
+ def __init__(self, eeprom=None):
+ self._eeprom = eeprom or {}
def get_serial(self):
return self._eeprom.get("serial", "")
diff --git a/mpm/python/usrp_mpm/dboard_manager/eiscat.py b/mpm/python/usrp_mpm/dboard_manager/eiscat.py
index f536d307b..101290574 100644
--- a/mpm/python/usrp_mpm/dboard_manager/eiscat.py
+++ b/mpm/python/usrp_mpm/dboard_manager/eiscat.py
@@ -17,12 +17,12 @@
"""
EISCAT rx board implementation module
"""
-from base import dboard_manager
-from base import lib
-from base import log
+from . import lib
+from .base import DboardManagerBase
+from .base import LOG
-class eiscat(dboard_manager):
+class eiscat(DboardManagerBase):
hw_pid = 3
special_eeprom_addrs = {"special0": "something"}
diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py
index d48768208..f13f1de77 100644
--- a/mpm/python/usrp_mpm/dboard_manager/magnesium.py
+++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py
@@ -17,34 +17,52 @@
"""
magnesium dboard implementation module
"""
-from base import dboard_manager
-from base import lib
-from base import log
+from . import lib
+from .base import DboardManagerBase
import struct
+from logging import getLogger
-class magnesium(dboard_manager):
+LOG = getLogger(__name__)
+
+
+class magnesium(DboardManagerBase):
+ """
+ Holds all dboard specific information and methods of the magnesium dboard
+ """
hw_pid = 2
special_eeprom_addrs = {"special0": "something"}
spi_chipselect = {"0": "lmk", "1": "mykonos", "2": "random"}
spidevs = {}
+ lmk = ""
+ mykonos = ""
+ random = ""
def __init__(self, spi_devices, eeprom_data, *args, **kwargs):
# eeprom_data is a tuple (head_dict, raw_data)
if len(spi_devices) != len(self.spi_chipselect):
- log.error("Expected {0} spi devices, found {1} spi devices".format(len(spi_devices), len(self.spi_chipselect)))
+ LOG.error("Expected {0} spi devices, found {1} spi devices".format(len(spi_devices), len(self.spi_chipselect)))
exit(1)
for spi in spi_devices:
device = self.spi_chipselect.get(spi[-1], None)
if self.chipselect is None:
- log.error("Unexpected chipselect {0}".format(spi[-1]))
+ LOG.error("Unexpected chipselect {0}".format(spi[-1]))
exit(1)
setattr(self, device, spi)
super(magnesium, self).__init__(*args, **kwargs)
def init_device(self):
- self._device = lib.db.magnesium(self.lmk, self.mykonos, self.random)
+ """
+ Execute necessary init dance to bring up dboard
+ """
+ LOG.debug("initialize hardware")
+
+ self._device = lib.dboards.magnesium(
+ self.lmk, self.mykonos, self.random)
def read_eeprom_v1(self, data):
+ """
+ read eeprom data version 1
+ """
# magnesium eeprom contains
# nothing
return struct.unpack_from("x", data)
diff --git a/mpm/python/usrp_mpm/dboard_manager/test.py b/mpm/python/usrp_mpm/dboard_manager/test.py
index b2e422bb4..80299ee41 100644
--- a/mpm/python/usrp_mpm/dboard_manager/test.py
+++ b/mpm/python/usrp_mpm/dboard_manager/test.py
@@ -17,8 +17,11 @@
"""
magnesium dboard implementation module
"""
-from base import dboard_manager
-from base import log
+from . import lib
+from .base import DboardManagerBase
+from logging import getLogger
+
+LOG = getLogger(__name__)
class fake_spi(object):
@@ -36,7 +39,7 @@ class test_device(object):
return argument
-class test(dboard_manager):
+class test(DboardManagerBase):
hw_pid = 234
special_eeprom_addrs = {"special0": "something"}
spi_chipselect = {"0": "dev1", "1": "dev2", "2": "dev3"}
@@ -51,6 +54,7 @@ class test(dboard_manager):
self.dev3 = "2"
def init_device(self):
+ LOG.debug("initialize hardware")
self._device = test_device(self.dev1, self.dev2, self.dev3)
diff --git a/mpm/python/usrp_mpm/dboard_manager/unknown.py b/mpm/python/usrp_mpm/dboard_manager/unknown.py
index f33bacc46..de2354f3d 100644
--- a/mpm/python/usrp_mpm/dboard_manager/unknown.py
+++ b/mpm/python/usrp_mpm/dboard_manager/unknown.py
@@ -17,12 +17,13 @@
"""
EISCAT rx board implementation module
"""
-from base import dboard_manager
-from base import lib
-from base import log
+from .base import DboardManagerBase
+from logging import getLogger
+LOG = getLogger(__name__)
-class unknown(dboard_manager):
+
+class unknown(DboardManagerBase):
hw_pid = 0
special_eeprom_addrs = {}