-
Notifications
You must be signed in to change notification settings - Fork 26
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
base: master
Are you sure you want to change the base?
Conversation
src/gallia/uds/ecu.py
Outdated
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}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we reset the state in this case?
The error handling is not so trivial for this case. Unfortunately, this can cause quite deep try-except blocks: try:
ecu.do_something()
except Error:
try:
ecu.reconnect()
except ConnectionError:
ecu.power_cycle()
try:
ecu.wait_for_ecu()
except Error:
# Fatal Error
sys.exit(1)
except StateChanged:
try:
ecu.set_session(session)
except Error:
# Fatal Error
sys.exit(1) A related problem is, that we currently don't have higher level exceptions. This is all not so convincing I must admit. |
The problematic error handling maybe shows, that it's not a good idea to combine the update state with the reconnect function. I updated this PR and added |
72a5ecf
to
41e0a13
Compare
981f73a
to
5218514
Compare
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@peckto is this still relevant? |
After reconnect, the ECU might have lost its state (eg. session).
This PR updates the state after the reconnect.