Skip to content

Commit

Permalink
feat(scan-reset): added option to power-cycle on timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
fkglr committed Nov 17, 2022
1 parent c64542a commit 8a56554
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/gallia/commands/scan/uds/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ def configure_parser(self) -> None:
action="store_true",
help="skip check current session",
)
self.parser.add_argument(
"--power-cycle-on-timeout",
action="store_true",
help="power-cycle ECU in case of a timeout",
)

async def main(self, args: Namespace) -> None:
l_ok: dict[int, list[int]] = {}
Expand Down Expand Up @@ -142,10 +147,29 @@ 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…"
)
sys.exit(1)
if args.power_cycle_on_timeout:
try:
self.logger.warning(
f"ECU did not respond after reset level {g_repr(sub_func)}; trying power-cycle..."
)
await self.ecu.power_cycle()
await self.ecu.wait_for_ecu()
except asyncio.TimeoutError:
self.logger.error(
f"ECU did not respond after power-cycle {g_repr(sub_func)}; exiting…"
)
sys.exit(1)
except ConnectionError:
msg = f"{g_repr(sub_func)}: lost connection to ECU (post), current session: " \
f"{g_repr(session)}"
self.logger.warning(msg)
await self.ecu.reconnect()
continue
else:
self.logger.error(
f"ECU did not respond after reset level {g_repr(sub_func)}; exiting…"
)
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 8a56554

Please sign in to comment.