Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hardware-testing): stacker qc script add error handling #16988

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __init__(self, port: str, simulating: bool = False) -> None:
"""Constructor."""
self._simulating = simulating
if not self._simulating:
self._serial = serial.Serial(port, baudrate=STACKER_FREQ)
self._serial = serial.Serial(port, baudrate=STACKER_FREQ, timeout=60)

def _send_and_recv(self, msg: str, guard_ret: str = "") -> str:
"""Internal utility to send a command and receive the response."""
Expand Down Expand Up @@ -155,6 +155,12 @@ def set_serial_number(self, sn: str) -> None:
return
self._send_and_recv(f"M996 {sn}\n", "M996 OK")

def stop_motor(self) -> None:
"""Stop motor movement."""
if self._simulating:
return
self._send_and_recv("M0\n")

def get_limit_switch(self, axis: StackerAxis, direction: Direction) -> bool:
"""Get limit switch status.

Expand Down Expand Up @@ -243,4 +249,5 @@ def move_to_limit_switch(
def __del__(self) -> None:
"""Close serial port."""
if not self._simulating:
self.stop_motor()
self._serial.close()
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_limit_switches_per_direction(
direction: Direction,
report: CSVReport,
section: str,
speed: float = 50.0,
speed: float = 10.0,
) -> None:
"""Sequence to test the limit switch for one direction."""
ui.print_header(f"{axis} Limit Switch - {direction} direction")
Expand All @@ -26,7 +26,7 @@ def test_limit_switches_per_direction(

# move until the limit switch is reached
print(f"moving towards {direction} limit switch...\n")
driver.move_to_limit_switch(axis, direction, MoveParams(max_speed=speed))
driver.move_to_limit_switch(axis, direction, MoveParams(max_speed_discont=speed))
result = driver.get_limit_switch(axis, direction)
opposite_result = not driver.get_limit_switch(axis, direction.opposite())
print(f"{direction} switch triggered: {result}")
Expand Down