From 306fd9187c61d0fbe24dbb432048d279b8201e55 Mon Sep 17 00:00:00 2001 From: fabian Date: Wed, 20 Mar 2024 19:54:24 +0100 Subject: [PATCH] scan-session: Fix logic --- src/gallia/commands/scan/uds/sessions.py | 26 ++++++++---------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/gallia/commands/scan/uds/sessions.py b/src/gallia/commands/scan/uds/sessions.py index 98d38fccc..ed19bd16c 100644 --- a/src/gallia/commands/scan/uds/sessions.py +++ b/src/gallia/commands/scan/uds/sessions.py @@ -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", @@ -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) @@ -167,14 +154,15 @@ 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) # do not ignore NCR subFunctionNotSupportedInActiveSession in this case if ( - isinstance(resp, NegativeResponse) - and resp.response_code == UDSErrorCodes.subFunctionNotSupported + isinstance(resp, NegativeResponse) and resp.response_code == UDSErrorCodes.subFunctionNotSupported ): logger.info(f"Could not change to session {g_repr(session)}: {resp}") continue @@ -192,6 +180,8 @@ async def main(self, args: Namespace) -> None: positive_results.append( {"session": session, "stack": stack, "error": None} ) + + current_session = session else: negative_results.append( {