Skip to content

[Go Migration] Fix bltouch.test 0.25s timing offset #4

@AndySze

Description

@AndySze

Problem

All commands have a consistent 4,000,000 MCU clock ticks (0.25 second) offset:

Expected: queue_digital_out oid=12 clock=1400981798
Actual:   queue_digital_out oid=12 clock=1396981798
Offset:   4,000,000 ticks = 0.25 seconds

This affects all BLTouch-related operations including homing and probing.

Root Cause

Go initialization (bltouch.go:50-55):

nextCmdTime: bltMinCmdTimeSec + 0.200 + bltPinMoveTimeSec,  // = 0.98s

Python initialization (bltouch.py:40):

self.next_cmd_time = self.action_end_time = 0.  # Initialize to ZERO

Go pre-calculates nextCmdTime during object creation, while Python initializes to 0.0 and adds values dynamically during handle_connect().

Proposed Fix

File: go/pkg/hosth4/bltouch.go

  1. Initialize nextCmdTime to 0.0 (not pre-calculated value)
  2. Add connect-phase initialization that:
    • Syncs to runtime print_time
    • Adds 0.200 seconds
    • Calls raise_probe()

Match Python's handle_connect() behavior:

def handle_connect(self):
    self.sync_mcu_print_time()
    self.next_cmd_time += 0.200
    self.set_output_mode(self.output_mode)
    try:
        self.raise_probe()
        self.verify_raise_probe()

Verification

./scripts/go_migration_golden.py compare --only bltouch --mode strict

Estimate

~3-4 hours (requires understanding initialization flow)

Parent Issue

Part of #1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions