Skip to content

Conversation

@davidvng
Copy link
Contributor

@davidvng davidvng commented Aug 5, 2025

Description

Add ValueError handling to agent process. Attempts calling the individual driver functions individually if the combined function fails.

Motivation and Context

Error found when agent deployed to site.
Traceback from Loki logs:

2025-08-04 21:32:46.270	
2025-08-04T21:32:46+0000 acq:1 CRASH: [Failure instance: Traceback: <class 'ValueError'>: not enough values to unpack (expected 4, got 3)
2025-08-04 21:32:46.270	
/opt/venv/lib/python3.10/site-packages/twisted/python/threadpool.py:269:inContext
2025-08-04 21:32:46.270	
/opt/venv/lib/python3.10/site-packages/twisted/python/threadpool.py:285:<lambda>
2025-08-04 21:32:46.270	
/opt/venv/lib/python3.10/site-packages/twisted/python/context.py:117:callWithContext
2025-08-04 21:32:46.270	
/opt/venv/lib/python3.10/site-packages/twisted/python/context.py:82:callWithContext
2025-08-04 21:32:46.270	
/opt/venv/lib/python3.10/site-packages/ocs/ocs_agent.py:984:_running_wrapper
2025-08-04 21:32:46.270	
/opt/venv/lib/python3.10/site-packages/socs/agents/srs_cg635/agent.py:151:acq
2025-08-04 21:32:46.270	
/opt/venv/lib/python3.10/site-packages/socs/agents/srs_cg635/drivers.py:85:get_all_status
2025-08-04 21:32:46.270	
]
2025-08-04 21:32:46.270	
2025-08-04T21:32:46+0000 acq:1 Status is now "done".

The process had ran fine for about an hour, then this error occurred seemingly randomly. I assume something finicky happened when trying to read 4 registers at the same time, so this fix adds the fallback of reading the 4 registers separately.

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@BrianJKoopman
Copy link
Member

Now that #913 is merged, please either rebase or merge in main, that'll fix the failing build.

@BrianJKoopman
Copy link
Member

While you're rebasing/merging, can you also provide some context and post the traceback for the error this is fixing?

@davidvng
Copy link
Contributor Author

davidvng commented Aug 8, 2025

@BrianJKoopman Merged in main and added traceback to original post. Looks like tests passed so should be good to go.

Copy link
Member

@BrianJKoopman BrianJKoopman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I just have one comment about the implementation here.

Comment on lines 151 to 162
try:
freq, stdc, runs, timb = self.clock.get_all_status().split(';')
data['data']['Frequency'] = float(freq)
data['data']['Standard_CMOS_Output'] = int(stdc)
data['data']['Running_State'] = int(runs)
data['data']['Timebase'] = int(timb)
except ValueError:
self.clock.clear()
data['data']['Frequency'] = self.clock.get_freq()
data['data']['Standard_CMOS_Output'] = self.clock.get_stdc()
data['data']['Running_State'] = self.clock.get_runs()
data['data']['Timebase'] = self.clock.get_timebase()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but I think would be better suited to go down a level, into the SRSCG635Interface.get_all_status() method. That way the driver is robust to this error, rather than just the agent.

@davidvng davidvng requested a review from BrianJKoopman August 13, 2025 20:53
Copy link
Member

@BrianJKoopman BrianJKoopman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for the changes!

@BrianJKoopman BrianJKoopman merged commit ac24cfa into main Aug 14, 2025
5 checks passed
@BrianJKoopman BrianJKoopman deleted the srs-agent-fix branch August 14, 2025 13:36
@BrianJKoopman BrianJKoopman changed the title SRS CG635 Agent ValueError handling SRS CG635: Add ValueError handling Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants