From dd9c4f1c6bc7b9c029d72b8e327b3e01631730fc Mon Sep 17 00:00:00 2001 From: Matthieu Cattin Date: Tue, 22 May 2012 18:57:26 +0200 Subject: [PATCH] test23: add write, read, compare eeprom content. --- test/fmcadc100m14b4cha/python/test23.py | 48 ++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/test/fmcadc100m14b4cha/python/test23.py b/test/fmcadc100m14b4cha/python/test23.py index ec73073..385f015 100755 --- a/test/fmcadc100m14b4cha/python/test23.py +++ b/test/fmcadc100m14b4cha/python/test23.py @@ -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) ########################################################################### -- 2.18.1