Skip to content

PI N-472: check the connect and every setup step, make the object retryable, fix stopmotion - #67

Merged
kalidke merged 7 commits into
mainfrom
n472-init-fixes
Sep 29, 2026
Merged

kalidke merged 7 commits into
mainfrom
n472-init-fixes

Conversation

@AliKNS

@AliKNS AliKNS commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Targets main, which carries 0.2.5-DEV since #69 folded 0.3rc1 into it and retired it; no version change here. Original fixes by @AliKNS; review changes on top. Main is merged in at e5d534c: the CHANGELOG and test/runtests.jl conflicts keep both sides.

Fixed (PI N-472 driver, PI_N472)

  • A failed connect was silent and poisoned the object. connectionstatus was set before PI_ConnectUSB and its -1 never checked. It is now set only after a successful connect; a failure logs the description and PI_GetInitError() and leaves the object retryable. The intermittent initialize seen on the rig is more likely another process holding the controller, made sticky by this bug, than anything in the connect string; that is not established.
  • shutdown never cleared connectionstatus, so re-initializing the same object was refused. It now clears the flag.
  • shutdown could close another object's connection. id defaulted to 0, a valid GCS ID, and was never reset. It now defaults to -1, and shutdown resets it.
  • stopmotion never reached the controller. It passed stage.axes, a Vector{String}, as Ptr{Cchar}. It now joins the axes.
  • The connect string relied on an implementation detail. Before, filter over the enumeration buffer happened to leave a terminator, and the string carried a trailing newline. The first description is now passed, stripped, as a String.

Changed

  • initialize(::N472) now throws when a setup step fails. The steps are reference mode, PI_POS, servos, travel range and velocity. On failure it closes the connection and clears the flag and id, which is the PI stage: refuse to finish initialize unreferenced #64 shape for PIStage. Non-breaking under main's rule (CLAUDE.md, Versioning): it changes behaviour only on a path that was already broken, where "Stage initialized" was logged on a half-set-up stage. Enumeration and connect failures still @error and return.
  • A re-initialize after shutdown now re-zeroes the frame (reference mode off, PI_POS = homepos, servos on).
  • With several C-885s attached, initialize connects to the first enumerated one.
  • N472() defaults id to -1.
  • setvel(::N472) returns FALSE when PI_VEL fails.

Tests

test/pi_n472_fake_sdk.jl replaces the GCS2 wrappers with a recorder, the same seam as the TCube fake, so no test can reach a DLL. test/pi_n472.jl covers the connect string, a failed and a retried connect, no controller, the stopmotion axes string, shutdown ownership, the default id, and each of nine failing setup steps. On the pre-PR driver 52 fail and 12 error; on this head all pass. Full local suite at e5d534c (xvfb-run -a julia --project -e 'using Pkg; Pkg.test()'): 1079 pass, 8 broken, 0 fail, 0 error.

Hardware

Not verified in this repository. The author reports exercising initialize, stopmotion with no motion in progress, shutdown, re-initialize and a refused second object on a C-885 (SN 124014300), with no motion commanded. Stop during motion and the connect-failure branch were not exercised on hardware.

🤖 Generated with Claude Code

…bject, working stop

initialize handed PI_ConnectUSB a description with every 0x00 stripped and no
terminator, so the DLL read past the vector until it met a zero by chance; it
also set connectionstatus before the connect was checked, so a -1 return was
logged as "Stage initialized" and a retry was refused. shutdown never cleared
the flag. stopmotion passed a Vector{String} where the DLL wants one string.

Verified on the rig (C-885 SN 124014300): init, stop (returns 1), shutdown,
re-init on the same object, and the held-controller refusal. No motion.

Adds a "PI N472 (no hardware)" testset that skips its DLL path whenever a
controller enumerates, so the suite never commands attached hardware. Bumps
to 0.2.4; documents the ccall-boundary rules in CLAUDE.md and the skills.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 08:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

kalidke and others added 3 commits September 29, 2026 09:50
Per the ruling that this work collects on 0.3rc1: Project.toml, the README
and mc-system-design's install pins return to the 0.3rc1 values (no 0.2.4
bump), and DAQmx's [sources] loses the unrelated rev = "main". Markers read
v0.3.0.

CHANGELOG: one hardware statement (not verified in this repository; the
author's no-motion exercise on a C-885 described as such); the connect
string is described as relying on filter's implementation rather than
missing a terminator, and not as the cause of the intermittent initialize;
the id/shutdown fix and the behaviour changes a pinned rig will see (throw
on setup failure, re-zeroing re-initialize, first enumerated controller,
default id, setvel's return) are listed individually.

CLAUDE.md: provenance without a version, BOOL* rule scoped to GCS2,
shutdown clears the id too, driver tests use recorded fakes. rig-causes
merges the C-867 and C-885 rows; driver-caveats drops the rig claim.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kalidke
kalidke changed the base branch from main to 0.3rc1 September 29, 2026 16:10
stopmotion never worked; the connect string is what worked by accident.
setvel's return is unchanged in value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kalidke kalidke changed the title PI N-472: fix intermittent initialize, silent connect failure, non-retryable shutdown, broken stopmotion PI N-472: check the connect and every setup step, make the object retryable, fix stopmotion Sep 29, 2026
@kalidke
kalidke changed the base branch from 0.3rc1 to main September 29, 2026 20:20
kalidke and others added 2 commits September 29, 2026 14:23
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	CHANGELOG.md
#	test/runtests.jl
…a break

It changes behaviour only on a path that was already broken ("Stage
initialized" was logged on a half-set-up stage), which main's versioning rule
(CLAUDE.md, decision 0033) does not count as a break; #64's identical
PIStage change is under Fixed. The entry stays under Changed. Ruled with #67
going into main at 0.2.5-DEV.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kalidke
kalidke merged commit 6519584 into main Sep 29, 2026
5 checks passed
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.

3 participants