Skip to content

Commit

Permalink
feat(scan-reset): Power cycle ECU after timeout to recover state
Browse files Browse the repository at this point in the history
  • Loading branch information
peckto committed Jul 14, 2023
1 parent 1555b89 commit 158d117
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/gallia/command/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,10 @@ def configure_class_parser(self) -> None:
"--power-cycle",
action=argparse.BooleanOptionalAction,
default=self.config.get_value("gallia.scanner.power_cycle", False),
help="trigger a powercycle before starting the scan",
help=(
"use the configured power supply to power-cycle the ECU when needed "
"(e.g. before starting the scan, or to recover bad state during scanning)"
),
)
group.add_argument(
"--power-cycle-sleep",
Expand Down
16 changes: 13 additions & 3 deletions src/gallia/commands/scan/uds/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,20 @@ async def main(self, args: Namespace) -> None:
await self.ecu.wait_for_ecu()

except asyncio.TimeoutError:
self.logger.error(
f"ECU did not respond after reset level {g_repr(sub_func)}; exiting…"
l_timeout[session].append(sub_func)
if not args.power_cycle:
self.logger.error(f"ECU did not respond after reset level {g_repr(sub_func)}; exit")
sys.exit(1)

self.logger.warning(
f"ECU did not respond after reset level {g_repr(sub_func)}; try power cycle…"
)
sys.exit(1)
try:
await self.ecu.power_cycle()
await self.ecu.wait_for_ecu()
except (ConnectionError, asyncio.TimeoutError) as e:
self.logger.error(f"Failed to recover ECU: {g_repr(e)}; exit")
sys.exit(1)
except ConnectionError:
msg = f"{g_repr(sub_func)}: lost connection to ECU (post), current session: {g_repr(session)}"
self.logger.warning(msg)
Expand Down

0 comments on commit 158d117

Please sign in to comment.