Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(db): Update ecu state after reconnect #220

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/gallia/uds/core/client.py
Original file line number Diff line number Diff line change
@@ -42,7 +42,8 @@ def __init__(
self.logger = Logger("uds", flush=True)

async def reconnect(self, timeout: Optional[int] = None) -> None:
"""Calls the underlying transport to trigger a reconnect"""
"""Calls the underlying transport to trigger a reconnect.
Be aware, that this might change the state of the ECU! Always restore desired state after reconnect."""
await self.transport.reconnect(timeout)

async def _read(
6 changes: 6 additions & 0 deletions src/gallia/udscan/scanner/fuzz_payloads.py
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import asyncio
import binascii
import random
import sys
from argparse import Namespace

from gallia.transports.base import TargetURI
@@ -176,6 +177,11 @@ async def main(self, args: Namespace) -> None:
)
flow_control_miss += 1
await self.ecu.reconnect()
if not self.ecu.check_and_set_session(session):
self.logger.log_error(
f"Could not change to session 0x{session:02x} after reconnect; exit"
)
sys.exit(1)

self.logger.log_summary(f"Scan in session 0x{session:0x} is complete!")

6 changes: 6 additions & 0 deletions src/gallia/udscan/scanner/scan_services.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

import asyncio
import reprlib
import sys
from argparse import BooleanOptionalAction, Namespace
from binascii import unhexlify
from typing import Any
@@ -148,6 +149,11 @@ async def main(self, args: Namespace) -> None:
except Exception as e:
self.logger.log_info(f"{g_repr(sid)}: {g_repr(e)} occurred")
await self.ecu.reconnect()
if not self.ecu.check_and_set_session(session):
self.logger.log_error(
f"Could not change to session 0x{session:02x} after reconnect; exit"
)
sys.exit(1)
continue

if suggests_service_not_supported(resp):
5 changes: 5 additions & 0 deletions src/gallia/udscan/scanner/scan_sessions.py
Original file line number Diff line number Diff line change
@@ -164,6 +164,11 @@ async def main(self, args: Namespace) -> None:
"Attempting to reconnect…"
)
await self.ecu.reconnect()
if not self.ecu.check_and_set_session(session):
self.logger.log_error(
f"Could not change to session 0x{session:02x} after reconnect; exit"
)
sys.exit(1)

try:
resp = await self.ecu.set_session(0x01)