Commit d4cb4ab1 authored by Matthieu Cattin's avatar Matthieu Cattin

test23: Add check of manufacturing date in EEPROM.

If manufacturing date doesn't exist in EEPROM, take the current date.
parent 9b17fdb9
......@@ -86,8 +86,8 @@ def main (default_directory='.'):
now_date = datetime.datetime.now()
ref_date = datetime.datetime(1996, 1, 1)
diff_date = now_date - ref_date
minutes = int(diff_date.total_seconds()//60)
print "Mfg date/time: %d minutes (since 0:00 1/1/96)\n" % minutes
current_date = int(diff_date.total_seconds()//60)
print "Mfg date/time: %d minutes (since 0:00 1/1/96)\n" % current_date
#==================================================
# Read calibration data from file
......@@ -102,21 +102,44 @@ def main (default_directory='.'):
for data in calibr_data:
print "0x%02X" % (data)
#==================================================
# 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.
# EEPROM clear code used to test the test!
#eeprom_data = [0x0] * EEPROM_SIZE
#fmc.sys_i2c_eeprom_write(eeprom_data)
# Read entire EEPROM
print "Read EEPROM content."
eeprom_data_read = fmc.sys_i2c_eeprom_read(0, EEPROM_SIZE)
# Write EEPROM data to binary file
print "Write EEPROM content to file (binary)."
f_eeprom = open(EEPROM_BIN_FILENAME, "wb")
for byte in eeprom_data_read:
f_eeprom.write(chr(byte))
f_eeprom.close()
# Get manufacturing date from EEPROM data, if exists
print "Get manufacturing date from binary file."
eeprom_data = open(EEPROM_BIN_FILENAME, "rb").read()
mfg_date = ipmi_get_mfg_date(eeprom_data)
# No manufacturiing date present in EEPROM, put the current date
if(mfg_date == 0):
print "No manufacturing date found in the EEPROM, taking current date: %d" % current_date
mfg_date = current_date
else:
print "Manufacturing date found in EEPROM: %d" % mfg_date
print mfg_date
#==================================================
# Create Board Info Area
# 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")
bia = BoardInfoArea(mfg_date, "CERN", "FmcAdc100m14b4cha", serial, "part number", "fru")
#==================================================
# Multirecords Area
......
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