- parse responses improved with exceptions
This commit is contained in:
@@ -25,19 +25,14 @@ class Pololu1376:
|
|||||||
self.send(cmd)
|
self.send(cmd)
|
||||||
rsp = self.recv()
|
rsp = self.recv()
|
||||||
|
|
||||||
success = False
|
|
||||||
if "." in rsp[0]:
|
if "." in rsp[0]:
|
||||||
print("The last command was understood and no errors are stopping the motor.")
|
pass
|
||||||
success = True
|
|
||||||
elif "!" in rsp[0]:
|
elif "!" in rsp[0]:
|
||||||
print("The last command was understood and errors are stopping the motor.")
|
pass
|
||||||
success = True
|
|
||||||
elif "?" in rsp[0]:
|
elif "?" in rsp[0]:
|
||||||
print("The last command was not understood (a Serial Format Error has occurred).")
|
raise Exception("The last command was not understood (a Serial Format Error has occurred).")
|
||||||
success = False
|
|
||||||
elif rsp is None:
|
elif rsp is None:
|
||||||
print("Timeout.")
|
raise Exception("Timeout.")
|
||||||
success = False
|
|
||||||
|
|
||||||
return rsp[1:]
|
return rsp[1:]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user