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

Improve robustness of hwp_pcu #797

Merged
merged 4 commits into from
Nov 25, 2024
Merged
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
27 changes: 19 additions & 8 deletions socs/agents/hwp_pcu/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dataclasses import dataclass
from queue import Queue

import serial
import txaio
from twisted.internet import defer, reactor, threads

Expand Down Expand Up @@ -116,20 +117,30 @@ def main(self, session, params):
self.log.info('Connected to PCU')
PCU.clear_buffer()
self.log.info('Cleared buffer')
except ConnectionRefusedError:
except (ConnectionRefusedError, serial.serialutil.SerialException):
self.log.error(
"Could not connect to PCU. "
"Retrying after 30 sec..."
)
time.sleep(30)
continue
now = time.time()
if now - last_daq > 5:
self._get_and_publish_data(PCU, session)
last_daq = now

self._process_actions(PCU)
time.sleep(0.1)
try:
now = time.time()
if now - last_daq > 5:
self._get_and_publish_data(PCU, session)
last_daq = now

self._process_actions(PCU)
session.degraded = False
time.sleep(0.1)
except serial.serialutil.SerialException:
self.log.error(
"Decive reports readiness to read but returned no data. "
"Reconnect to PCU."
)
PCU.close()
PCU = None
session.degraded = True

PCU.close()

Expand Down