Commit dd9c4f1c authored by Matthieu Cattin's avatar Matthieu Cattin

test23: add write, read, compare eeprom content.

parent 3fd85a76
......@@ -44,6 +44,7 @@ def main (default_directory='.'):
SERIAL_FILENAME = os.path.join(default_directory, SERIAL_FILENAME)
CALIBR_FILENAME = "calibration_data.txt"
CALIBR_FILENAME = os.path.join(default_directory, CALIBR_FILENAME)
EEPROM_BIN_FILENAME = "eeprom_content.out"
......@@ -103,6 +104,14 @@ def main (default_directory='.'):
#==================================================
# Create Board Info Area
################################################################################
# CHECK IF A MANUFACTURING DATE IS PRESENT IN THE EEPROM.
# IF NOT, PUT THE CURRENT DATE (IT MEANS IT'S THE FIRST TIME THE TEST IS RUN).
# IF A DATE IS PRESENT, KEEP IT.
# FRU field is used to store the date of generation of the eeprom content
# This could be used later to determine if the content has to be udated (bug fix, ...)
bia = BoardInfoArea(minutes, "CERN", "FmcAdc100m14b4cha", serial, "part number", "fru")
#==================================================
......@@ -139,14 +148,45 @@ def main (default_directory='.'):
iua = InternalUseArea(calibr_data)
#==================================================
# Open, set, write, close!
ipmi_open_file("eeprom_content.out")
# Write eeprom content to a binary file
ipmi_open_file(EEPROM_BIN_FILENAME)
ipmi_set(bia, dcload, dcout, oem, iua)
ipmi_write()
ipmi_close_file()
except:
raise PtsError("test failed: " % e)
#==================================================
# Read eeprom content from binary file
f_eeprom = open(EEPROM_BIN_FILENAME, "rb")
eeprom_data = []
byte = f_eeprom.read(1) # reads one byte
while byte:
eeprom_data.append(ord(byte))
byte = f_eeprom.read(1) # reads one byte
f_eeprom.close()
#print "Raw EEPROM data:"
#for data in eeprom_data:
# print "0x%02X" % (data)
#==================================================
# Write content to EEPROM via I2C
fmc.sys_i2c_eeprom_write(eeprom_data)
#==================================================
# Read back EEPROM content via I2C
eeprom_data_read = fmc.sys_i2c_eeprom_read(0, len(eeprom_data))
print "EEPROM content comparision"
for i in range(len(eeprom_data)):
wr_data = eeprom_data[i]
rd_data = eeprom_data_read[i]
if wr_data == rd_data:
check = "OK"
else:
check = "FAILED"
print "0x%02X 0x%02X => %s" % (wr_data, rd_data, check)
except FmcAdc100mOperationError as e:
raise PtsError("test failed: %s" % e)
###########################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment