Beispiel #1
0
def test_get_eeprom_by_name():
    #test eeprom
    base_board_eeprom = Profile.get_eeprom_by_name('TB_EEPROM')
    assert base_board_eeprom['bus'] == '/dev/AXI4_EEPROM_IIC'
    assert base_board_eeprom['addr'] == int('0x50', 16)
    assert base_board_eeprom['partno'] == 'CAT24C08'
    assert base_board_eeprom['switch_channel'] == 'TB'

    datalogger_eeprom = Profile.get_eeprom_by_name('datalogger')
    assert datalogger_eeprom['bus'] == '/dev/AXI4_EEPROM_IIC'
    assert datalogger_eeprom['addr'] == int('0x53', 16)
    assert datalogger_eeprom['partno'] == 'CAT24C08'
    assert datalogger_eeprom['switch_channel'] == 'Datalogger-1'

    eload_1_eeprom = Profile.get_eeprom_by_name('ELOAD1')
    assert eload_1_eeprom['bus'] == '/dev/AXI4_ELOAD_IIC'
    assert eload_1_eeprom['addr'] == int('0x53', 16)
    assert eload_1_eeprom['partno'] == 'CAT24C08'
    assert eload_1_eeprom['switch_channel'] == "none"

    try:
        Profile.get_eeprom_by_name('SPAM')['bus']
    except KeyError:
        assert True
    else:
        assert False
Beispiel #2
0
def eeprom_write(module_name, addr, data):
    """ write  a list data  by the defined profile
        
        Args:
            module_name: the key of Dictionary which can get the hardware profile.for example: "dmm-module-1"
            addr: which  addr will be write data in. 
            data: data type is list.
            
        Returns:
            bool: The return value. True for success, False otherwise.
            
    """
    try:
        profile = Profile.get_eeprom_by_name(module_name)
        result = Eeprom.write(profile, addr, data)
    except Exception as e:
        logger.error("execute module  eeprom_write  False:" + repr(e))
        return False
    return result
Beispiel #3
0
def eeprom_read(module_name, addr, length):
    """ read   data  by  the defined profile
        
        Args:
            module_name: the key of Dictionary which can get the hardware profile.for example: "dmm-module-1"
            addr:  read data from this addr.
            length: read data length.
            
        Returns:
            list: success  return data which beed  saved in a list. False otherwise.
            
    """
    try:
        profile = Profile.get_eeprom_by_name(module_name)
        result = Eeprom.read(profile, addr, length)
    except Exception as e:
        logger.error("execute module  eeprom_read  False:" + repr(e))
        return False
    return result