Skip to content

XPeel: fix status parsing and the adhere-time code in peel() - #1473

Open
Dondonn wants to merge 2 commits into
PyLabRobot:mainfrom
Dondonn:fix/xpeel-status-and-adhere-time
Open

Dondonn wants to merge 2 commits into
PyLabRobot:mainfrom
Dondonn:fix/xpeel-status-and-adhere-time

Conversation

@Dondonn

@Dondonn Dondonn commented Oct 6, 2026

Copy link
Copy Markdown

Warning

AI-found and AI-written: please review manually. An AI coding agent (Claude) found these bugs while driving a real XPeel and wrote this fix and its tests. A person asked for the PR, but no human has reviewed the code line by line yet. Please review it accordingly.

Problem

Two bugs in the XPeel driver, present in both pylabrobot.azenta.XPeel and the legacy pylabrobot.legacy.peeling.XPeelBackend:

  1. request_status() / get_status() raise on every reply. send_command appends the error description to each *ready: line it returns (*ready:00,00,00 [No error]). The status parser then splits the line on , and calls int("00 [No error]"):
    ValueError: invalid literal for int() with base 10: '00 [No error]'
    
  2. peel() sends the adhere time in seconds. f"*xpeel:{parameter_set}{adhere_time}" produces *xpeel:42.5, which the peeler rejects with error 05 Illegal command. The peeler expects the adhere time as a code, so 2.5 s is *xpeel:41.

Fix

  • The status parser reads the three codes from the first token after the colon, so it handles lines with and without the appended description. It returns a real (int, int, int) tuple, which drops the # type: ignore. send_command's return value is unchanged.
  • peel() maps adhere_time to the code 1–4 (2.5 / 5.0 / 7.5 / 10.0 s) and sends that. The accepted values and the ValueError for anything else are unchanged.
  • New xpeel_tests.py (v1) and xpeel_backend_tests.py (legacy) mock the serial port. They cover the status parsing and the command peel() writes for each adhere time. They fail on main and pass with this change.
  • One CHANGELOG.md entry under Unreleased → Fixed.

Verification

  • On hardware (one Azenta XPeel, driven through our own wrapper rather than this exact branch):
    • *stat answers *ready:00,00,00, and the unpatched parser fails on it as shown above.
    • *xpeel:42.5 gives 05 Illegal command.
    • *xpeel:41 peels a sealed plate and ends *ready:00,00,00.
  • Not verified on hardware: adhere codes 2, 3 and 4 (5.0 / 7.5 / 10.0 s). Their mapping follows the 1–4 order of the device's adhere-time options. Please check it against the XPeel protocol documentation.
  • pytest: the full suite passes (4855 passed, 66 skipped), including the new tests.
  • With the pinned ruff==0.15.4, ruff format --check, ruff check and ruff check --select I pass.
  • mypy==1.18.2 pylabrobot reports the same 9 errors as on main (missing optional dependencies in my environment). None are in the touched files.

🤖 Generated with Claude Code

… as a code

`send_command` returns each `*ready:` line with its error description appended
(`*ready:00,00,00 [No error]`), and `request_status` (legacy: `get_status`) parsed
the last field as `"00 [No error]"`, raising ValueError on every reply. The codes
are now read from the first token after the colon.

`peel` formatted `adhere_time` in seconds into the command (`*xpeel:42.5`), which the
peeler rejects as error 05 "Illegal command". The peeler takes the adhere time as a
code, 1-4 for 2.5, 5.0, 7.5 and 10.0 s (`*xpeel:41`).

Both fixes apply to `pylabrobot.azenta.XPeel` and the legacy `XPeelBackend`, with
tests for each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Dondonn
Dondonn requested a review from a team as a code owner October 6, 2026 22:57

This branch has not been deployed

No deployments
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