diff options
Diffstat (limited to 'mpm/python/usrp_mpm/bist.py')
-rw-r--r-- | mpm/python/usrp_mpm/bist.py | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/mpm/python/usrp_mpm/bist.py b/mpm/python/usrp_mpm/bist.py index bd0dbb8d3..6678b132d 100644 --- a/mpm/python/usrp_mpm/bist.py +++ b/mpm/python/usrp_mpm/bist.py @@ -18,6 +18,7 @@ from datetime import datetime import argparse import subprocess from six import iteritems +from usrp_mpm.sys_utils import ectool ############################################################################## # Aurora/SFP BIST code @@ -220,6 +221,7 @@ def get_product_id_from_eeprom(valid_ids, cmd='eeprom-id'): """Return the mboard product ID Returns something like n300, n310, e320... + the eeprom parameter is needed if there are several eeprom within the system """ output = subprocess.check_output( [cmd], @@ -268,13 +270,24 @@ def gpio_set_all(gpio_bank, value, gpio_size, ddr_mask): ############################################################################## # Common tests ############################################################################## -def test_ddr3_with_usrp_probe(): +def test_ddr3_with_usrp_probe(extra_args=None): """ Run uhd_usrp_probe and scrape the output to see if the DRAM FIFO block is reporting a good throughput. This is a bit of a roundabout way of testing the DDR3, but it uses existing software and also tests the RFNoC pathways. """ - ddr3_bist_executor = 'uhd_usrp_probe --args addr=127.0.0.1' + dflt_args = {'addr':'127.0.0.1', 'rfnoc_num_blocks':1} + extra_args = extra_args or {} + # merge args dicts, extra_args overrides dflt_args if keys exists in both dicts + args = {**dflt_args, **extra_args} + args_str = ",".join( + ['{k}={v}'.format(k=k, v=v) for k, v in iteritems(args)]) + cmd = [ + 'uhd_usrp_probe', + '--args', + '{e}'.format(e=args_str) + ] + ddr3_bist_executor = ' '.join(cmd) try: output = subprocess.check_output( ddr3_bist_executor, @@ -335,15 +348,19 @@ def get_ref_clock_prop(clock_source, time_source, extra_args=None): - <sensor-name>: - locked: Boolean lock status """ + dflt_args = {'addr':'127.0.0.1'} extra_args = extra_args or {} + # merge args dicts, extra_args overrides dflt_args if keys exists in both dicts + args = {**dflt_args, **extra_args} result = {} - extra_args_str = ",".join( - ['{k}={v}'.format(k=k, v=v) for k, v in iteritems(extra_args)]) + + args_str = ",".join( + ['{k}={v}'.format(k=k, v=v) for k, v in iteritems(args)]) cmd = [ 'uhd_usrp_probe', '--args', - 'addr=127.0.0.1,clock_source={c},time_source={t},{e}'.format( - c=clock_source, t=time_source, e=extra_args_str), + 'clock_source={c},time_source={t},{e}'.format( + c=clock_source, t=time_source, e=args_str), '--sensor' ] sensor_path = '/mboards/0/sensors/ref_locked' @@ -382,6 +399,33 @@ def get_temp_sensor_value(temp_sensor_map): and device.attributes.get('temp') is not None } + +def get_iio_temp_sensor_values(): + """ + Read all devices in the IIO subsystem that can report a temperature and + returns dictionary containing {name: temperature}, where name is the + temperature device name and the temperature is a value in mC. + """ + import pyudev + context = pyudev.Context() + iio_devs = context.list_devices(subsystem='iio') + + def is_temp_dev(dev): + return 'in_temp_raw' in dev.attributes.available_attributes + + def get_temp(dev): + raw = float(dev.attributes.get('in_temp_raw').decode('ascii')) + offset = float(dev.attributes.get('in_temp_offset').decode('ascii')) + scale = float(dev.attributes.get('in_temp_scale').decode('ascii')) + return int(scale * (raw + offset)) + + def get_name(dev): + return dev.attributes.get('name').decode('ascii') + + temp_devs = [dev for dev in iio_devs if is_temp_dev(dev)] + return {get_name(dev): get_temp(dev) for dev in temp_devs} + + def get_fan_values(): """ Return a dict of fan name -> fan speed key/values. @@ -395,6 +439,14 @@ def get_fan_values(): and device.attributes.get('cur_state') is not None } +def get_ectool_fan_values(): + try: + return ectool.get_fan_rpm() + except RuntimeError as ex: + return { + 'error_msg': "{}".format(str(ex)) + } + def get_link_up(if_name): """ Return a dictionary {if_name: IFLA_OPERSTATE} |