Skip to content

Commit

Permalink
fix simulator returns
Browse files Browse the repository at this point in the history
  • Loading branch information
ahiuchingau committed Nov 18, 2024
1 parent 2b58d3e commit 6c9ddaf
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ def build_simulator(cls, port: str = "") -> "FlexStacker":

def __init__(self, port: str, simulating: bool = False) -> None:
"""Constructor."""
self._serial = serial.Serial(port, baudrate=STACKER_FREQ)
self._simulating = simulating
if not self._simulating:
self._serial = serial.Serial(port, baudrate=STACKER_FREQ)

def _send_and_recv(self, msg: str, guard_ret: str = "") -> str:
"""Internal utility to send a command and receive the response."""
assert self._simulating
self._serial.write(msg.encode())
ret = self._serial.readline()
if guard_ret:
Expand Down Expand Up @@ -87,4 +89,5 @@ def set_serial_number(self, sn: str) -> None:

def __del__(self) -> None:
"""Close serial port."""
self._serial.close()
if not self._simulating:
self._serial.close()

0 comments on commit 6c9ddaf

Please sign in to comment.