From 3299b47def32f9fa1479a300bc1bf23625c580e8 Mon Sep 17 00:00:00 2001 From: jens Date: Wed, 11 Aug 2021 16:15:21 +0200 Subject: [PATCH] - parse responses improved with exceptions --- components/actor/Pololu1376.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/components/actor/Pololu1376.py b/components/actor/Pololu1376.py index e0a3e3c..da80a6f 100644 --- a/components/actor/Pololu1376.py +++ b/components/actor/Pololu1376.py @@ -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:]