Skip to content

Mergemaster#144

Merged
beniroquai merged 2 commits into
masterfrom
mergemaster
Jun 26, 2026
Merged

Mergemaster#144
beniroquai merged 2 commits into
masterfrom
mergemaster

Conversation

@beniroquai

Copy link
Copy Markdown
Contributor

No description provided.

Allow selecting/pinning USB boards and require CANopen masters; add TMC parameter readback.

- UC2Client: pass new device_id and requireMaster flags into Serial constructor so callers can pin to a specific board or insist on a CANopen master.
- mserial.Serial: accept device_id and requireMaster options; add firmware_info storage, _portMatchesDeviceId helper, and _probeDeviceIdentity to query /state_get and parse identity (pindef, version, etc.). Auto-skip ports that don't match device_id. When requireMaster is set, probe and reject non-master boards to avoid accidentally connecting to motor/slave devices.
- state.State: add get_firmware_info and is_master helpers to expose parsed identity (name, version, date, author, pindef, isMaster).
- motor.Motor: add get_tmc_parameters (and camelCase alias getTMCSettings) to read TMC settings from /tmc_get; returns a dict of known TMC keys or None if unsupported.

These changes let users target specific physical boards, avoid connecting to non-master boards, and read back TMC settings when supported by firmware.
Fixes inflated time estimates by computing absolute travel distance as |current_physical - target_physical| and then converting to hardware steps (avoids sign/sum errors when axes are inverted). Clarifies that speed and acceleration are already expressed in firmware step units and uses their magnitudes directly (keeps a 20000 steps/s² safe default). Also expose acceleration in motor property output by adding "acceleration" and (misspelled) "acceleleration" keys alongside the existing "accel" for compatibility.
Copilot AI review requested due to automatic review settings June 26, 2026 04:10
@beniroquai beniroquai merged commit fb5e48f into master Jun 26, 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 extends UC2-REST’s Python client to better support multi-board USB environments (e.g., distinguishing CANopen master vs motor/slave boards), while also improving motor move time estimation and adding TMC parameter readback.

Changes:

  • Add device_id and requireMaster options to serial connection setup to pin/select the intended USB device.
  • Introduce firmware identity parsing helpers (get_firmware_info, is_master) and serial-side probing to support “master-only” selection.
  • Fix absolute-move time estimation logic for inverted axes, and add /tmc_get readback API with a compatibility alias.

Reviewed changes

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

File Description
uc2rest/UC2Client.py Threads new device_id / requireMaster options through client construction into serial layer.
uc2rest/state.py Adds firmware identity parsing helpers for determining whether a connected board is a CANopen master.
uc2rest/mserial.py Adds device filtering by device_id and master-only probing via /state_get before accepting a port.
uc2rest/motor.py Corrects absolute-distance time estimation on inverted axes; adds TMC readback and expands motor payload fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uc2rest/motor.py
motorProp["acceleration"] = int(acceleration[iMotor])
else:
motorProp["accel"] = self.DEFAULT_ACCELERATION
motorProp["acceleleration"] = self.DEFAULT_ACCELERATION
Comment thread uc2rest/mserial.py
# motor/slave board (ESP32-S3, native USB) is never picked accidentally.
self.device_id = device_id
self.requireMaster = requireMaster
# identity of the board we actually connected to (filled by checkFirmware)
Comment thread uc2rest/state.py
Comment on lines +149 to +151
The build date and pindef are the fields that matter for telling boards
apart. Returns an empty dict if nothing could be parsed.
'''
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