From 7cc9aa4845a7fffe2bf80cf50b8aaad5926b9316 Mon Sep 17 00:00:00 2001 From: Romain Bazile Date: Sat, 5 Dec 2020 02:59:52 +0100 Subject: [PATCH] stepper: solve bug if flowrate is 0 --- scripts/planktoscope/stepper.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/planktoscope/stepper.py b/scripts/planktoscope/stepper.py index 85f8c82..b41514d 100644 --- a/scripts/planktoscope/stepper.py +++ b/scripts/planktoscope/stepper.py @@ -283,7 +283,10 @@ class StepperProcess(multiprocessing.Process): logger.error( f"The received message has the wrong argument {last_message}" ) - self.actuator_client.client.publish("status/pump", '{"status":"Error"}') + self.actuator_client.client.publish( + "status/pump", + '{"status":"Error, the message is missing an argument"}', + ) return # Get direction from the different received arguments direction = last_message["direction"] @@ -291,6 +294,12 @@ class StepperProcess(multiprocessing.Process): volume = float(last_message["volume"]) # Get number of steps from the different received arguments flowrate = float(last_message["flowrate"]) + if flowrate == 0: + logger.error(f"The flowrate should not be == 0") + self.actuator_client.client.publish( + "status/pump", '{"status":"Error, The flowrate should not be == 0"}' + ) + return # Print status logger.info("The pump is started.")