diff options
Diffstat (limited to 'mpm/python/usrp_mpm/e31x_legacy_eeprom.py')
-rw-r--r-- | mpm/python/usrp_mpm/e31x_legacy_eeprom.py | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/mpm/python/usrp_mpm/e31x_legacy_eeprom.py b/mpm/python/usrp_mpm/e31x_legacy_eeprom.py index 4c0fb19a5..70e6632ae 100644 --- a/mpm/python/usrp_mpm/e31x_legacy_eeprom.py +++ b/mpm/python/usrp_mpm/e31x_legacy_eeprom.py @@ -1,18 +1,17 @@ # -# Copyright 2017 Ettus Research, a National Instruments Company +# Copyright 2019 Ettus Research, a National Instruments Brand # # SPDX-License-Identifier: GPL-3.0-or-later # """ -EEPROM management code +E310 EEPROM management code """ import struct -import zlib from builtins import zip from builtins import object - +# pylint: disable=too-few-public-methods class MboardEEPROM(object): """ Given a nvmem path, read out EEPROM values from the motherboard's EEPROM. @@ -33,10 +32,17 @@ class MboardEEPROM(object): to know the MAC address of an interface, we can fish it out the raw data, or ask the system. """ - # Refer e300_eeprom_manager.hpp. eeprom_header_format = "<H H 6s H H 7s 12s 8s" - eeprom_header_keys = ('data_version_major', 'data_version_minor', 'mac_address', 'pid', 'rev', 'serial', 'pad', 'user_name') + eeprom_header_keys = ( + 'data_version_major', + 'data_version_minor', + 'mac_address', + 'pid', + 'rev', + 'serial', + 'pad', + 'user_name') class DboardEEPROM(object): """ @@ -52,13 +58,19 @@ class DboardEEPROM(object): - 8 bytes serial number (zero-terminated string of 7 characters) - 12 bytes padding """ - # Refer e300_eeprom_manager.hpp. eeprom_header_format = "<H H H H 7s 12s" - eeprom_header_keys = ('data_version_major', 'data_version_minor', 'pid', 'rev', 'serial', 'pad') + eeprom_header_keys = ( + 'data_version_major', + 'data_version_minor', + 'pid', + 'rev', + 'serial', + 'pad') +# pylint: disable=too-few-public-methods def read_eeprom( - isMotherboard, + is_motherboard, nvmem_path, offset, eeprom_header_format, @@ -75,7 +87,6 @@ def read_eeprom( eeprom_header_keys -- List of keys for the entries in the EEPROM max_size -- Max number of bytes to be read. If omitted, will read the full file. """ - max_size = max_size or -1 with open(nvmem_path, "rb") as nvmem_file: data = nvmem_file.read(max_size)[offset:] @@ -83,7 +94,7 @@ def read_eeprom( eeprom_keys = eeprom_header_keys parsed_data = eeprom_parser.unpack_from(data) - if isMotherboard: # E310 MB. + if is_motherboard: # E310 MB. # Rectify the PID and REV parsing. Reverse the bytes. # PID and REV are the 4th and 5th elements in the tuple. parsed_data_list = list(parsed_data) @@ -99,5 +110,5 @@ def read_eeprom( parsed_data_list[3] = struct.unpack("<H", struct.pack(">H", parsed_data_list[3]))[0] parsed_data = tuple(parsed_data_list) - ret_val = (dict(list(zip(eeprom_keys, parsed_data))),data) - return ret_val
\ No newline at end of file + ret_val = (dict(list(zip(eeprom_keys, parsed_data))), data) + return ret_val |