diff --git a/e32_client/requirements.txt b/e32_client/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/e32_client/ugv.py b/e32_client/ugv.py index b695762..bc20f50 100755 --- a/e32_client/ugv.py +++ b/e32_client/ugv.py @@ -38,7 +38,7 @@ class UGVComms(E32): def __rx_thread_entry(ugv: UGVComms): - while True: + while ugv.ser.is_open: try: msg = ugv.read_message() if msg is not None: @@ -59,15 +59,19 @@ if __name__ == "__main__": # ugv.reset() cmd_id = 1 time.sleep(0.2) - while True: - gmsg = messages.GroundMessage() - gmsg.command.id = cmd_id - gmsg.command.type = messages.DISABLE - cmd_id += 1 - print("writing message: ", gmsg) - ugv.write_message(gmsg) - time.sleep(2.) + try: + while True: + gmsg = messages.GroundMessage() + gmsg.command.id = cmd_id + gmsg.command.type = messages.DISABLE + cmd_id += 1 + print("writing message: ", gmsg) + ugv.write_message(gmsg) + time.sleep(2.) + except KeyboardInterrupt: + print("exiting...") + finally: + ugv.ser.close() - rx_thread.In rx_thread.join()