From 8dc307b426282b553cf08600202e614789436eac Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Thu, 26 Jan 2017 15:27:12 +0100 Subject: [PATCH] Script execution --- script/local.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/script/local.py b/script/local.py index 376ce24..d468139 100644 --- a/script/local.py +++ b/script/local.py @@ -50,12 +50,13 @@ class RobotModbus(DeviceBase): robot_args.write(to_array(args, 'i')) try: self.request() - ret = robot_ret.read() - if ret == 1: - return True - if ret == 2: + err = robot_ack.take() + if err == 1: + ret = robot_ret.read() + return ret + if err == 2: raise Exception("Invalid command: " + str(command)) - raise Exception("Unknown error: " + str(ret)) + raise Exception("Unknown error: " + str(err)) finally: self.cancel_request() @@ -66,7 +67,7 @@ class RobotModbus(DeviceBase): def cancel_request(self): robot_req.write(0) - while robot_ack.read() == 1: + while robot_ack.read() != 0: time.sleep(0.001) def mount(self, puck, sample):