Skip to content

Commit

Permalink
refactor(scan-session) Replace reset with leave_session
Browse files Browse the repository at this point in the history
  • Loading branch information
fkglr committed Nov 28, 2023
1 parent 6cda9b0 commit 0cfc92a
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/gallia/commands/scan/uds/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,8 @@ def configure_parser(self) -> None:
)
self.parser.add_argument(
"--reset",
nargs="?",
default=None,
const=0x01,
type=lambda x: int(x, 0),
help="Reset the ECU after each iteration with the optionally given reset level",
action="store_true",
help="Reset and if necessary power cycle the ECU after each iteration",
)
self.parser.add_argument(
"--fast",
Expand Down Expand Up @@ -158,22 +155,15 @@ async def main(self, args: Namespace) -> None:
if args.reset:
try:
logger.info("Resetting the ECU")
resp: UDSResponse = await self.ecu.ecu_reset(args.reset)
success = await self.ecu.leave_session(session)

if isinstance(resp, NegativeResponse):
if not success:
logger.warning(
f"Could not reset ECU with {EcuResetSubFuncs(args.reset).name if args.reset in iter(EcuResetSubFuncs) else args.reset}: {resp}"
f"; continuing without reset"
f"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)
except (asyncio.TimeoutError, ConnectionError):
logger.warning(
"Lost connection to the ECU after performing a reset. "
"Attempting to reconnect…"
)
await self.ecu.reconnect()

if not (await self.ecu.leave_session(session)):
logger.error("Could not change to default session")
Expand Down

0 comments on commit 0cfc92a

Please sign in to comment.