diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2018-02-06 09:35:48 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-02-07 17:21:43 +0100 |
commit | d9366ba7d4b72f9e277ca7055842160dd6d32256 (patch) | |
tree | 4fb06516797e9fc82fbe740457729068a3a46c54 /mpm | |
parent | 31f9d3dce799ce86c903dd3e377d3f4038086ef7 (diff) | |
download | uhd-d9366ba7d4b72f9e277ca7055842160dd6d32256.tar.gz uhd-d9366ba7d4b72f9e277ca7055842160dd6d32256.tar.bz2 uhd-d9366ba7d4b72f9e277ca7055842160dd6d32256.zip |
mpm: Fixup for argument parsing in N310
Adding helper function to parse strings to a boolean value. We can
then use that function to parse MPM's default_args, and set enable_gps
and enable_fp_gpio. This replaces the usages of the Python builtin
bool(), which returns True for any non-empty string.
Diffstat (limited to 'mpm')
-rw-r--r-- | mpm/python/usrp_mpm/mpmutils.py | 2 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/n310.py | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/mpm/python/usrp_mpm/mpmutils.py b/mpm/python/usrp_mpm/mpmutils.py index 49d6cb39d..08eb54798 100644 --- a/mpm/python/usrp_mpm/mpmutils.py +++ b/mpm/python/usrp_mpm/mpmutils.py @@ -140,3 +140,5 @@ def assert_compat_number( raise RuntimeError(err_msg) return +def str2bool(value): + return value.lower() in ("yes", "true", "t", "1") diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py index 417b88d30..daa53f4ef 100644 --- a/mpm/python/usrp_mpm/periph_manager/n310.py +++ b/mpm/python/usrp_mpm/periph_manager/n310.py @@ -21,7 +21,7 @@ from builtins import object from usrp_mpm.gpsd_iface import GPSDIface from usrp_mpm.periph_manager import PeriphManagerBase from usrp_mpm.mpmtypes import SID -from usrp_mpm.mpmutils import assert_compat_number +from usrp_mpm.mpmutils import assert_compat_number, str2bool from usrp_mpm.rpc_server import no_rpc from usrp_mpm.sys_utils import dtoverlay from usrp_mpm.sys_utils.sysfs_gpio import SysFSGPIO, GPIOBank @@ -537,12 +537,12 @@ class n310(PeriphManagerBase): self._gpios.set("PWREN-CLK-MGT156MHz") self.enable_1g_ref_clock() self.enable_gps( - enable=bool( + enable=str2bool( args.default_args.get('enable_gps', N3XX_DEFAULT_ENABLE_GPS) ) ) self.enable_fp_gpio( - enable=bool( + enable=str2bool( args.default_args.get( 'enable_fp_gpio', N3XX_DEFAULT_ENABLE_FPGPIO |