Skip to content

Mergemaster - #150

Merged
beniroquai merged 7 commits into
masterfrom
mergemaster
Aug 20, 2026
Merged

Mergemaster#150
beniroquai merged 7 commits into
masterfrom
mergemaster

Conversation

@beniroquai

Copy link
Copy Markdown
Contributor

No description provided.

Introduces `uc2rest.aio` with an opt-in `AsyncUC2Client` wrapper around the synchronous `UC2Client`, running blocking operations via `asyncio.to_thread` and exposing a typed async event stream for serial callback frames (`steppers`, `home`, `emergency`, `message`, etc.). It also adds async convenience methods for motors, homing, illumination, objective control, CAN, galvo, and firmware/system calls, plus cancellation-safe stop behavior. A new hardware-free test (`TEST_aio_mock.py`) verifies MockSerial fallback and confirms raw callback frames are bridged into typed async events.
Copilot AI lite review requested due to automatic review settings August 20, 2026 06:55
@beniroquai
beniroquai merged commit 60f15bf into master Aug 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an opt-in asyncio facade (uc2rest.aio.AsyncUC2Client) for driving the existing blocking UC2Client from async applications, adds a motor API for configuring joystick jog speed multipliers, and adds a hardware-free script test that exercises the async event bridge using the existing MockSerial fallback.

Changes:

  • Add uc2rest/aio.py: AsyncUC2Client wrapper using asyncio.to_thread plus a typed async firmware-event stream bridged from serial callbacks.
  • Extend uc2rest/motor.py with set_speed_multiplier() / get_speed_multiplier() for joystick jog speed scaling.
  • Add uc2rest/TEST/TEST_aio_mock.py script to validate MockSerial fallback and typed event emission without hardware.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
uc2rest/aio.py Adds an asyncio-friendly wrapper around UC2Client and a typed async event stream bridged from serial callbacks.
uc2rest/motor.py Adds joystick jog speed multiplier setter/getter methods.
uc2rest/TEST/TEST_aio_mock.py Adds a hardware-free script test to validate async event bridging via injected frames.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread uc2rest/motor.py
Comment on lines +1408 to +1425
motors = self.get_motors(timeout=timeout)

if motors and "steppers" in motors:
if axis is not None:
if type(axis) != int:
axis = self.xyztTo1230(axis)
for stepper in motors["steppers"]:
if stepper.get("stepperid") == axis:
return stepper.get("speedMultiplier", 1)
else:
result = []
for stepper in motors["steppers"]:
result.append({
"axis": stepper.get("stepperid"),
"multiplier": stepper.get("speedMultiplier", 1)
})
return result
return None
Comment thread uc2rest/aio.py
Comment on lines +182 to +186
@property
def is_connected(self) -> bool:
"""Whether the serial link is currently alive."""
return bool(getattr(self._client, "is_connected", False))

Comment thread uc2rest/aio.py
Comment on lines +229 to +242
async def events(self, queue_size: int = _DEFAULT_QUEUE_SIZE) -> AsyncIterator[SerialEvent]:
"""Yield typed firmware events as they arrive.

Multiple consumers may iterate concurrently; each gets its own queue.
The oldest events are dropped if a consumer falls behind.
"""
queue: asyncio.Queue = asyncio.Queue(maxsize=queue_size)
self._queues.append(queue)
try:
while True:
yield await queue.get()
finally:
self._queues.remove(queue)

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