Repository navigation
Match Sutter MP-285 13-byte position reply (no prefix echo) - #81
Merged
Merged
Conversation
The library expected a 14-byte reply for GET_POSITION:
<xlllx> = pad + 3 int32 + terminator, where the leading pad is
the echoed command prefix 'C'. Testing against live hardware
(serial SIDCACD9, after a power cycle) showed the device replies
with only 13 bytes: 3 int32 + b'\r' -- no prefix echo.
The protocol has two reply modes (echo on / off). The mode appears
to depend on firmware state and is reset by a power cycle. The
prior 14-byte assumption worked for the previous device state
earlier in the session; this commit accepts the no-echo mode.
Changes:
- SutterDevice.commands['GET_POSITION']:
replyDataLength: 14 -> 13
unpackingMask: '<xlllx' -> '<lllx'
responseFormat: '<clllc' -> '<lllc' (mock side)
responseFields: drops 'header' (mock side)
- DebugSerialPort.process_command for 'GET_POSITION':
drops the {'header': b'c', ...} entry in the returned dict.
- testSutterSerialPort.py::testMoveGet:
readData length: 14 -> 13
unpack format: '<xlllx' -> '<lllx'
Caveat: if a future MP-285 boots into echo-on mode, this commit
will break GET_POSITION for it. The robust long-term fix is
either to detect/toggle the mode at init or to accept both reply
lengths. Filed as a follow-up to be addressed before this is
trusted across all MP-285 firmwares.
Verified against live hardware: 7/7 SutterDevice tests pass with
real stage motion (1.33s testDeviceMoveBy, 0.91s testDeviceMove,
0.89s testDeviceHome) and 7/7 DebugSerialPort tests still pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates the `SutterDevice` `GET_POSITION` command to expect a 13-byte reply (``: 3 int32 positions + b'\r' terminator) instead of the previous 14-byte assumption (``: prefix echo + 3 int32 + terminator).
Verified live against a Sutter ROE-200 (serial `SIDCACD9`) — the device replies with 13 bytes, no echoed command prefix.
Background
The Sutter MP-285 protocol has two response modes for `GET_POSITION`:
The library previously assumed echo-on. Hardware testing in this session showed the same physical device returning 14 bytes early on, then 13 bytes after a power cycle — confirming the mode is not stable across firmware resets.
Changes
Total: 6 insertions, 7 deletions across 2 files.
Caveat — this is a unilateral mode switch
If a future MP-285 boots into echo-on mode (the previous library assumption), `GET_POSITION` will fail with a 14-byte read that includes the echoed prefix as a corrupting offset.
The robust long-term fix is one of:
This PR opts for the simpler one-mode fix because (a) the device is clearly in 13-byte mode for the current lab unit, and (b) implementing dual-mode handling is a more invasive change to the `DataCommand` machinery.
Test plan
Related
Surfaced while bringing up live Sutter hardware to validate PR #73's table-driven debug port pattern. The dual-role consistency between the device reply parser and the mock's response builder caught the mock test failure when only the receive side was updated — exactly the safety net the pattern is supposed to provide.
🤖 Generated with Claude Code