Skip to content

Fix recursion error in moxa_serial module - #935

Merged
BrianJKoopman merged 7 commits into
mainfrom
koopman/moxa-recursion-split
Nov 3, 2025
Merged

BrianJKoopman merged 7 commits into
mainfrom
koopman/moxa-recursion-split

Conversation

@BrianJKoopman

Copy link
Copy Markdown
Member

Description

This PR contains the relevant changes originally from #924 to the issue described in #891.

Motivation and Context

Resolves #891.

Split since this has potential impact on more than just the wiregrid agents and I'd like to keep it separated from the reconnection handling work in #924.

How Has This Been Tested?

This, along with the changes in #924, was run with the wiregrid tiltsensor agent. Tests have not been done on other agents that use the moxa_serial module, such as the PMX agents.

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 added a commit that referenced this pull request Oct 15, 2025
That change has been split out to #935.
BrianJKoopman added a commit that referenced this pull request Oct 16, 2025
* update moxa_serial.py to use specific exceptions (TimeoutError and BlockingIOError) in reading data

* Committer: sadachi5 <adachi@daq-satp1.simonsobs.org>

On branch fix_wiregrid_tiltsensor_RecursionError
Your branch is up to date with 'origin/fix_wiregrid_tiltsensor_RecursionError'.

Changes to be committed:
       modified:   agent.py
       modified:   drivers/dwl.py
       modified:   drivers/sherborne.py

- agent.py: Add reconnect function if the read data is wronge
- agent.py: Comment-out a function that has not been implemented (`get_temperatures()`)
- drivers/dwl.py: Fix the return values to -999 if the read data is wrong
- drivers/dwl.py, sherborne.py: In `__del__()`, there was unavailable attribute
  `self.ser.close()`. It was changed to `self.ser.sock.close()`.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update

* update moxa_serial.py

* Update moxa_serial.py

In `readbuf()`, use a byte type string for `msg` and `msg_current`.

* Undo moxa_serial recursion fix

That change has been split out to #935.

* Add note about possibly dropping support for 'sherborne'

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Brian Koopman <brian.koopman@yale.edu>
@sadachi5

sadachi5 commented Nov 2, 2025

Copy link
Copy Markdown
Contributor

@BrianJKoopman Is there anything to be modified on my side for this PR?

Since we were catching BaseException before, there's some chance we were
catching something that isn't a TimeoutError or BlockingIOError. This catches
anything else and logs it, just in case.
@BrianJKoopman

Copy link
Copy Markdown
Member Author

@BrianJKoopman Is there anything to be modified on my side for this PR?

Yeah, sorry, I was meaning to add more general exception handling, but got distracted before traveling. I wanted to add this since we were catching BaseException prior to this -- in the event that that was catching something besides the TimeoutError and BlockingIOError that is now explicitly defined.

Added in b002944.

@BrianJKoopman
BrianJKoopman merged commit 4fa29ce into main Nov 3, 2025
5 checks passed
@BrianJKoopman
BrianJKoopman deleted the koopman/moxa-recursion-split branch November 3, 2025 16:37
laurensaunders pushed a commit that referenced this pull request Feb 19, 2026
* update moxa_serial.py to use specific exceptions (TimeoutError and BlockingIOError) in reading data

* Committer: sadachi5 <adachi@daq-satp1.simonsobs.org>

On branch fix_wiregrid_tiltsensor_RecursionError
Your branch is up to date with 'origin/fix_wiregrid_tiltsensor_RecursionError'.

Changes to be committed:
       modified:   agent.py
       modified:   drivers/dwl.py
       modified:   drivers/sherborne.py

- agent.py: Add reconnect function if the read data is wronge
- agent.py: Comment-out a function that has not been implemented (`get_temperatures()`)
- drivers/dwl.py: Fix the return values to -999 if the read data is wrong
- drivers/dwl.py, sherborne.py: In `__del__()`, there was unavailable attribute
  `self.ser.close()`. It was changed to `self.ser.sock.close()`.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update

* update moxa_serial.py

* Update moxa_serial.py

In `readbuf()`, use a byte type string for `msg` and `msg_current`.

* Undo moxa_serial recursion fix

That change has been split out to #935.

* Add note about possibly dropping support for 'sherborne'

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Brian Koopman <brian.koopman@yale.edu>
laurensaunders pushed a commit that referenced this pull request Feb 19, 2026
* update moxa_serial.py to use specific exceptions (TimeoutError and BlockingIOError) in reading data

* update

* update moxa_serial.py

* Update moxa_serial.py

In `readbuf()`, use a byte type string for `msg` and `msg_current`.

* Add general exception handling

Since we were catching BaseException before, there's some chance we were
catching something that isn't a TimeoutError or BlockingIOError. This catches
anything else and logs it, just in case.

---------

Co-authored-by: Shunsuke Adachi <38268229+sadachi5@users.noreply.github.com>
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.

wiregrid_tiltsensor RecursionError

2 participants