Skip to content

Commit 959146c

Browse files
committed
Handle more eeprom errors
While trying to run OLAF on more people's laptops we ran into another type of eeprom read error, where it could read the eeprom but the contents were not a string. This handles that specific case but really we shouldn't be trying to read arbitrary eeproms if hardware is being mocked. I could add a specific eeprom value to look for but that's not yet common across other projects so this turns it off if any hardware is mocked.
1 parent 7e45912 commit 959146c

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

olaf/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,13 @@ def olaf_setup(name: str, args: Optional[Namespace] = None) -> tuple[Namespace,
129129
od["flight_mode"].value = False
130130

131131
version = "0.0"
132-
try:
133-
eeprom = Eeprom()
134-
version = f"{eeprom.major}.{eeprom.minor}"
135-
logger.info(f"detected v{version} card")
136-
except (PermissionError, FileNotFoundError, OSError):
137-
logger.warning("could not read hardware info from eeprom")
132+
if not args.mock_hw:
133+
try:
134+
eeprom = Eeprom()
135+
version = f"{eeprom.major}.{eeprom.minor}"
136+
logger.info(f"detected v{version} card")
137+
except (PermissionError, FileNotFoundError, OSError, UnicodeDecodeError):
138+
logger.warning("could not read hardware info from eeprom")
138139
if args.hardware_version != "0.0":
139140
version = args.hardware_version
140141
od["versions"]["hw_version"].value = version

0 commit comments

Comments
 (0)