diff --git a/script/local.py b/script/local.py index facde69..376ce24 100644 --- a/script/local.py +++ b/script/local.py @@ -51,19 +51,23 @@ class RobotModbus(DeviceBase): try: self.request() ret = robot_ret.read() + if ret == 1: + return True + if ret == 2: + raise Exception("Invalid command: " + str(command)) + raise Exception("Unknown error: " + str(ret)) finally: self.cancel_request() - return ret def request(self): robot_req.write(1) while robot_ack.read() == 0: - time.sleep(0.01) + time.sleep(0.001) def cancel_request(self): robot_req.write(0) while robot_ack.read() == 1: - time.sleep(0.01) + time.sleep(0.001) def mount(self, puck, sample): return self.execute('1', '1', puck, sample)