Skip to content

Conversation

@xiaoyu10031
Copy link
Collaborator

@xiaoyu10031 xiaoyu10031 commented Nov 25, 2025

  1. fix laiyu_liquid_test driver display bugs in backend.
  2. delete laiyu_liquid_test info and debug display in backend.

Summary by Sourcery

Improve robustness and logging behavior for the Laiyu liquid test XYZ stepper driver and adjust its device registry configuration.

Bug Fixes:

  • Add tolerant Modbus communication and status handling to reduce backend driver failures when the device response is missing or invalid.

Enhancements:

  • Introduce retry and soft-fail behavior for Modbus requests and dependent register operations to make motion control more resilient.
  • Relax wait-for-completion logic to handle transient errors and unexpected status values without crashing.
  • Silence most debug/info logging for Laiyu liquid test operations to reduce backend log noise.

Chores:

  • Update Laiyu liquid test device registry defaults, including serial port configuration and controller metadata fields.

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 25, 2025

Reviewer's Guide

Refactors the Laiyu liquid test stepper driver for more robust, non-throwing Modbus communication and quieter logging, and cleans up the device registry YAML (though merge conflict markers remain).

File-Level Changes

Change Details Files
Make Modbus communication more fault-tolerant and adjust return types to avoid raising on transient errors.
  • Refactored send_request to support configurable retries, internal exception handling, and CRC/length validation while returning None instead of raising on repeated failure.
  • Updated read_registers to return Optional[List[int]], handling None responses and parsing registers via an explicit loop.
  • Adjusted write_single_register and write_multiple_registers to treat None responses as a False result instead of propagating errors.
unilabos/devices/laiyu_liquid_test/xyz_stepper_driver.py
Harden higher-level motion/status logic against communication failures and quiet backend logging for this device.
  • Added defensive checks in get_status to handle None/short register reads and return a safe default status.
  • Enhanced wait_complete with exception handling, status validation, and more tolerant retry logic while suppressing timeout logs.
  • Commented out various info/debug logs (TX frame logging, multi-axis movement logs, zero-point and work-origin logs) to reduce backend noise for this driver.
unilabos/devices/laiyu_liquid_test/xyz_stepper_driver.py
Updated the device registry YAML for the Laiyu liquid test controller but left unresolved merge conflict markers.
  • Added placeholder_keys: {} sections under multiple controller operations, likely aligning with newer schema requirements.
  • Introduced a conflicting default serial port value (ttyUSB1 vs ttyUSB0) and left Git conflict markers (<<<<<<<, =======, >>>>>>>) in the YAML file.
unilabos/registry/devices/laiyu_liquid_test.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • There are unresolved merge conflict markers in unilabos/registry/devices/laiyu_liquid_test.yaml (<<<<<<<, =======, >>>>>>>); please resolve these and pick a single value for placeholder_keys and the port default before merging.
  • send_request now swallows all exceptions and returns None after retries; consider logging the last error (and possibly the frame) when giving up so that communication issues remain diagnosable.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There are unresolved merge conflict markers in unilabos/registry/devices/laiyu_liquid_test.yaml (<<<<<<<, =======, >>>>>>>); please resolve these and pick a single value for placeholder_keys and the port default before merging.
- send_request now swallows all exceptions and returns None after retries; consider logging the last error (and possibly the frame) when giving up so that communication issues remain diagnosable.

## Individual Comments

### Comment 1
<location> `unilabos/devices/laiyu_liquid_test/xyz_stepper_driver.py:172-174` </location>
<code_context>
    def read_registers(self, addr: int, start: int, count: int) -> Optional[List[int]]:
        """
        读保持寄存器:
        - 成功时返回寄存器列表 List[int]
        - 失败时返回 None(send_request 已经做了重试)
        """
        payload = struct.pack(">HH", start, count)
        resp = self.send_request(
            addr,
            ModbusFunction.READ_HOLDING_REGISTERS.value,
            payload,
        )
        if resp is None:
            return None

        byte_count = resp[2]
        regs: List[int] = []
        for i in range(0, byte_count, 2):
            regs.append(struct.unpack(">H", resp[3 + i:5 + i])[0])
        return regs

</code_context>

<issue_to_address>
**suggestion (code-quality):** Convert for loop into list comprehension ([`list-comprehension`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/list-comprehension/))

```suggestion
        regs: List[int] = [
            struct.unpack(">H", resp[3 + i : 5 + i])[0]
            for i in range(0, byte_count, 2)
        ]
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

1 participant