Skip to content

Commit

Permalink
fix(hardware-testing): stacker qc script add error handling (#16988)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahiuchingau authored Nov 26, 2024
1 parent ab58237 commit b82fc0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
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

0 comments on commit b82fc0e

Please sign in to comment.