- parse responses improved with exceptions

This commit is contained in:
jens
2021-08-11 16:15:21 +02:00
parent afd63c6505
commit 3299b47def
+4 -9
View File
@@ -25,19 +25,14 @@ class Pololu1376:
self.send(cmd)
rsp = self.recv()
success = False
if "." in rsp[0]:
print("The last command was understood and no errors are stopping the motor.")
success = True
pass
elif "!" in rsp[0]:
print("The last command was understood and errors are stopping the motor.")
success = True
pass
elif "?" in rsp[0]:
print("The last command was not understood (a Serial Format Error has occurred).")
success = False
raise Exception("The last command was not understood (a Serial Format Error has occurred).")
elif rsp is None:
print("Timeout.")
success = False
raise Exception("Timeout.")
return rsp[1:]