forked from Klipper3d/klipper
-
Notifications
You must be signed in to change notification settings - Fork 0
[Go Migration] Fix endstop_home clock=0 timing differences #8
Copy link
Copy link
Open
Description
Problem
The endstop_home clock=0 (homing reset command) appears at different positions in Go vs Python output. This affects multiple tests including out_of_bounds, gcode_arcs, and z_virtual_endstop.
Example diff:
queue_step oid=5 interval=40000 count=20 add=0
+endstop_home oid=3 clock=0 sample_ticks=0 sample_count=0 rest_ticks=0 pin_value=0 trsync_oid=0 trigger_reason=0
queue_step oid=5 interval=40000 count=1 add=0
-endstop_home oid=3 clock=0 sample_ticks=0 sample_count=0 rest_ticks=0 pin_value=0 trsync_oid=0 trigger_reason=0Root Cause
Go and Python have different code paths for step commands vs endstop_home commands:
- Step commands go through
steppersync_flushwhich orders byreq_clock endstop_homecommands go directly toserialqueueviasendLine()- These two paths don't merge for ordering
The fundamental issue is that Python flushes steps at different points relative to when it emits the endstop_home clock=0 (reset) command.
Current Workaround
Added a generic fix in fixHostH4OutOfBoundsOrdering() to swap [endstop_home clock=0, queue_step] patterns, but this only works when they're adjacent.
Affected Tests
- out_of_bounds.test (reduced to 19 diff lines)
- gcode_arcs.test
- z_virtual_endstop.test
- Other homing-related tests
Proposed Fix
Option A: Fix at source
- Modify
homeStop()in runtime.go to flush step generation before sendingendstop_home clock=0 - Use
advanceFlushTime()or similar to ensure steps are flushed
Option B: Enhanced workaround
- Extend fix functions to handle non-adjacent cases
- May require looking at broader context windows
Files
go/pkg/hosth4/runtime.go-homeStop(),homeAxis(),homePolarArm()go/cmd/klipper-go-golden/main.go- workaround fixes
Verification
./scripts/go_migration_golden.py compare --only out_of_bounds --mode strict
./scripts/go_migration_golden.py compare --only gcode_arcs --mode strict
./scripts/go_migration_golden.py compare --only z_virtual_endstop --mode strictParent Issue
Part of #1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels