Skip to content

Commit

Permalink
fix(db): Update ecu state after reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
peckto committed Jul 15, 2022
1 parent e4eba81 commit 82c7b20
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/gallia/uds/ecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from gallia.uds.core import service
from gallia.uds.core.client import UDSClient, UDSRequestConfig
from gallia.uds.core.constants import DataIdentifier
from gallia.uds.core.exception import ResponseException, UnexpectedNegativeResponse
from gallia.uds.core.exception import ResponseException, UnexpectedNegativeResponse, UDSException
from gallia.uds.core.utils import from_bytes
from gallia.uds.helpers import (
as_exception,
Expand Down Expand Up @@ -62,6 +62,10 @@ def __init__(
async def connect(self) -> None:
...

async def reconnect(self, timeout: Optional[int] = None) -> None:
await super().reconnect(timeout)
await self.refresh_state()

async def properties(
self, fresh: bool = False, config: Optional[UDSRequestConfig] = None
) -> dict:
Expand Down Expand Up @@ -382,7 +386,10 @@ async def refresh_state(self, reset_state: bool = False) -> None:
if reset_state:
self.state.reset()

await self.read_session()
try:
await self.read_session()
except UDSException as e:
self.logger.log_warning(f'Could not read current session as part of refresh_state: {e}')

async def _request(
self, request: service.UDSRequest, config: Optional[UDSRequestConfig] = None
Expand Down

0 comments on commit 82c7b20

Please sign in to comment.