Skip to content

Commit

Permalink
fixup! feat(scan-sessions): Greatly speed up scan by recovering stack…
Browse files Browse the repository at this point in the history
… on need
  • Loading branch information
ferdinandjarisch committed Feb 6, 2025
1 parent 85f7862 commit 9b72859
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/gallia/commands/scan/uds/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ async def main(self) -> None:
if stack:
logger.info(f"Starting from session: {g_repr(stack[-1])}")

# Recover stack in first loop iteration and afterwards only if needed
recover_stack = True

for session in sessions:
if session in self.config.skip:
logger.info(f"Skipping testing for session {g_repr(session)} as requested")
Expand All @@ -168,13 +171,15 @@ async def main(self) -> None:
"Lost connection to the ECU after performing a reset. Attempting to reconnect…"
)
await self.ecu.reconnect()
recover_stack = True

# Recover stack in first loop iteration and afterwards only if needed
if session == sessions[0]:
if recover_stack is True:
logger.info("Recovering the stack starting from default session")
if not await self.recover_stack_from_default_session(
stack, self.config.with_hooks
):
sys.exit(1)
recover_stack = False

logger.debug(f"Attempting to change to session {session:#04x}")
try:
Expand Down Expand Up @@ -217,11 +222,7 @@ async def main(self) -> None:
logger.warning(f"Mamma mia: {repr(e)}")

# If the loop is not `continue`d early, recover stack, e.g. on successful session change
logger.info("Recovering the stack starting from default session")
if not await self.recover_stack_from_default_session(
stack, self.config.with_hooks
):
sys.exit(1)
recover_stack = True

logger.result("Scan finished; Found the following sessions:")
previous_session = 0
Expand Down

0 comments on commit 9b72859

Please sign in to comment.