Skip to content

Commit

Permalink
[checkbox-ce-oem] Enhance serial test to be more stable (Bugfix) (#1682)
Browse files Browse the repository at this point in the history
1. enhance the server mode could handle binary data without crashing
2. clean up garbage in the serial port before testing
  • Loading branch information
hanhsuan authored Jan 17, 2025
1 parent 9253900 commit b3b62f3
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ def recv(self) -> bytes:
if rcv:
logging.info("Received: {}".format(rcv.decode()))
except Exception:
logging.exception("Received unmanageable string format")
raise SystemExit(1)
logging.exception(
"Received unmanageable string format {}".format(rcv)
)
return None
return rcv


Expand Down Expand Up @@ -157,7 +159,12 @@ def client_mode(ser: Serial, data_size: int = 1024):
running on port /dev/ttymxc1 as a client
$ sudo ./serial_test.py /dev/ttymxc1 --mode client --type RS485
"""

random_string = generate_random_string(data_size)

# clean up the garbage in the serial before test
while ser.recv():
continue
ser.send(random_string.encode())
for i in range(1, 6):
logging.info("Attempting receive string... {} time".format(i))
Expand Down

0 comments on commit b3b62f3

Please sign in to comment.