Skip to content

Commit

Permalink
Fix cmis eeprom validate
Browse files Browse the repository at this point in the history
CMIS_5.0 starts to support the checksum of page 04h
  • Loading branch information
chiourung committed Oct 8, 2024
1 parent 93fe42f commit 0c5162f
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,19 @@ def __validate_eeprom_cmis(self):
if checksum_test != eeprom_raw[127]:
return False

checksum_test = 0
eeprom_raw = self.read_eeprom(640, 128)
if eeprom_raw is None:
return None

for i in range(0, 127):
checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF
else:
if checksum_test != eeprom_raw[127]:
return False
# CMIS_5.0 starts to support the checksum of page 04h
cmis_rev = float(api.get_cmis_rev())
if cmis_rev >= 5.0:
checksum_test = 0
eeprom_raw = self.read_eeprom(640, 128)
if eeprom_raw is None:
return None

for i in range(0, 127):
checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF
else:
if checksum_test != eeprom_raw[127]:
return False

return True

Expand Down

0 comments on commit 0c5162f

Please sign in to comment.