From 5bc1c9ca9fa24399d2e62ef253c84166bf188e47 Mon Sep 17 00:00:00 2001 From: spirkelmann Date: Thu, 6 Jun 2019 15:19:14 +0200 Subject: [PATCH] fixed another reconnection issue that only seems to occur with windows --- micropython_firmware/main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/micropython_firmware/main.py b/micropython_firmware/main.py index 4b7787f..42e51eb 100644 --- a/micropython_firmware/main.py +++ b/micropython_firmware/main.py @@ -51,10 +51,10 @@ class Robot: # expected data: '(u1, u2)'\n" # where ui = control for motor i # ui \in [-1.0, 1.0] - data = comm_socket.readline() - data_str = data.decode() - #print("Data received: {}".format(data_str)) try: + data = comm_socket.readline() + data_str = data.decode() + #print("Data received: {}".format(data_str)) #print("processing data = {}".format(data_str)) l = data_str.strip('()\n').split(',') #print("l = {}".format(l)) @@ -74,6 +74,12 @@ class Robot: print("Shutting down ...") u1 = u2 = 0 listening = False + except Exception as e: + print("Some other error occured") + print("Exception: {}".format(e)) + print("Shutting down ...") + u1 = u2 = 0 + listening = False finally: self.m1.speed(u1) self.m2.speed(u2)