Skip to content

Commit b82fc0e

Browse files
authored
fix(hardware-testing): stacker qc script add error handling (#16988)
1 parent ab58237 commit b82fc0e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

hardware-testing/hardware_testing/modules/flex_stacker_evt_qc/driver.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def __init__(self, port: str, simulating: bool = False) -> None:
117117
"""Constructor."""
118118
self._simulating = simulating
119119
if not self._simulating:
120-
self._serial = serial.Serial(port, baudrate=STACKER_FREQ)
120+
self._serial = serial.Serial(port, baudrate=STACKER_FREQ, timeout=60)
121121

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

158+
def stop_motor(self) -> None:
159+
"""Stop motor movement."""
160+
if self._simulating:
161+
return
162+
self._send_and_recv("M0\n")
163+
158164
def get_limit_switch(self, axis: StackerAxis, direction: Direction) -> bool:
159165
"""Get limit switch status.
160166
@@ -243,4 +249,5 @@ def move_to_limit_switch(
243249
def __del__(self) -> None:
244250
"""Close serial port."""
245251
if not self._simulating:
252+
self.stop_motor()
246253
self._serial.close()

hardware-testing/hardware_testing/modules/flex_stacker_evt_qc/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_limit_switches_per_direction(
1414
direction: Direction,
1515
report: CSVReport,
1616
section: str,
17-
speed: float = 50.0,
17+
speed: float = 10.0,
1818
) -> None:
1919
"""Sequence to test the limit switch for one direction."""
2020
ui.print_header(f"{axis} Limit Switch - {direction} direction")
@@ -26,7 +26,7 @@ def test_limit_switches_per_direction(
2626

2727
# move until the limit switch is reached
2828
print(f"moving towards {direction} limit switch...\n")
29-
driver.move_to_limit_switch(axis, direction, MoveParams(max_speed=speed))
29+
driver.move_to_limit_switch(axis, direction, MoveParams(max_speed_discont=speed))
3030
result = driver.get_limit_switch(axis, direction)
3131
opposite_result = not driver.get_limit_switch(axis, direction.opposite())
3232
print(f"{direction} switch triggered: {result}")

0 commit comments

Comments
 (0)