Skip to content

Commit

Permalink
scan-session: Fix logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fkglr committed Mar 20, 2024
1 parent f91fe2c commit e2ca6ba
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/gallia/commands/scan/uds/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ def configure_parser(self) -> None:
action="store_true",
help="Use hooks in case of a ConditionsNotCorrect error",
)
self.parser.add_argument(
"--reset",
action="store_true",
help="Reset and if necessary power cycle the ECU after each iteration",
)
self.parser.add_argument(
"--fast",
action="store_true",
Expand Down Expand Up @@ -141,22 +136,14 @@ async def main(self, args: Namespace) -> None:
if stack:
logger.info(f"Starting from session: {g_repr(stack[-1])}")

current_session = 1

for session in sessions:
if session in args.skip:
logger.info(f"Skipping session {g_repr(session)} as requested")
continue

if args.reset:
logger.info("Resetting the ECU")
success = await self.ecu.leave_session(session)

if not success:
logger.warning("Could not reset ECU; continuing without reset")
else:
logger.info("Waiting for the ECU to recover…")
await self.ecu.wait_for_ecu(timeout=args.timeout)

if not (await self.ecu.leave_session(session)):
if not (await self.ecu.leave_session(current_session)):
logger.error("Could not change to default session")
sys.exit(1)

Expand All @@ -167,6 +154,8 @@ async def main(self, args: Namespace) -> None:
if not await self.recover_stack(stack, args.with_hooks):
sys.exit(1)

current_session = stack[-1]

try:
logger.debug(f"Attempting to change to session {session:#04x}")
resp = await self.set_session_with_hooks_handling(session, args.with_hooks)
Expand All @@ -192,6 +181,8 @@ async def main(self, args: Namespace) -> None:
positive_results.append(
{"session": session, "stack": stack, "error": None}
)

current_session = session
else:
negative_results.append(
{
Expand Down

0 comments on commit e2ca6ba

Please sign in to comment.