Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 18, 2025

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original prompt

Refactor OAMS to use an asynchronous, callback-driven action model and update the manager to use the async API.

Changes to include in the PR:

  • klipper_openams/src/oams.py: Implement an async-first action model for load/unload/calibrate operations. Add a pending-action queue with per-action timeouts, _enqueue_action/_deliver_action_result logic, and non-blocking G-code handlers (OAMS_LOAD_SPOOL, OAMS_UNLOAD_SPOOL, calibrations). Keep synchronous compatibility wrappers load_spool/unload_spool that use the async API internally but wait cooperatively with the reactor.
  • klipper_openams/src/oams_manager.py: Convert manager orchestration to call the async OAMS start APIs for unload/load flows. Update the runout reload callback to run unload then load asynchronously and continue in callbacks. Add defensive handling and timer cleanup.

Also include the fps.py robustness fixes already on the branch (clamp ADC values, protect callbacks).

Testing notes:

  • Test on a single OAMS unit. Watch klippy.log for M118 notifications and for timeouts (default per-action timeout 30s).
  • Validate manual load/unload commands start and complete and that runout reload flow performs unload->load asynchronously.

Ensure the PR merges branch 'oams-async-refactor' into 'main'.

Do not modify other unrelated files.

No images attached.

This pull request was created as a result of the following prompt from Copilot chat.

Refactor OAMS to use an asynchronous, callback-driven action model and update the manager to use the async API.

Changes to include in the PR:

  • klipper_openams/src/oams.py: Implement an async-first action model for load/unload/calibrate operations. Add a pending-action queue with per-action timeouts, _enqueue_action/_deliver_action_result logic, and non-blocking G-code handlers (OAMS_LOAD_SPOOL, OAMS_UNLOAD_SPOOL, calibrations). Keep synchronous compatibility wrappers load_spool/unload_spool that use the async API internally but wait cooperatively with the reactor.
  • klipper_openams/src/oams_manager.py: Convert manager orchestration to call the async OAMS start APIs for unload/load flows. Update the runout reload callback to run unload then load asynchronously and continue in callbacks. Add defensive handling and timer cleanup.

Also include the fps.py robustness fixes already on the branch (clamp ADC values, protect callbacks).

Testing notes:

  • Test on a single OAMS unit. Watch klippy.log for M118 notifications and for timeouts (default per-action timeout 30s).
  • Validate manual load/unload commands start and complete and that runout reload flow performs unload->load asynchronously.

Ensure the PR merges branch 'oams-async-refactor' into 'main'.

Do not modify other unrelated files.

No images attached.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@lindnjoe lindnjoe marked this pull request as ready for review October 18, 2025 18:59
@lindnjoe lindnjoe merged commit 7314345 into main Oct 18, 2025
1 check failed
Copilot AI requested a review from lindnjoe October 18, 2025 18:59
Copilot finished work on behalf of lindnjoe October 18, 2025 18:59
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