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)