From f21a8430a4c063213fea07e7d6bc178b96d05970 Mon Sep 17 00:00:00 2001 From: Daniel Nugent Date: Thu, 18 Jun 2015 14:33:04 -0700 Subject: [PATCH] Added the ability to see command ack --- droneapi/module/api.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/droneapi/module/api.py b/droneapi/module/api.py index 2be604a3f..ad80af4e4 100644 --- a/droneapi/module/api.py +++ b/droneapi/module/api.py @@ -98,6 +98,24 @@ def add(self, cmd): self.__wp.wploader.add(cmd, comment = 'Added by DroneAPI') self.__module.vehicle.wpts_dirty = True + def command_ack(self, timeout = 0.5): + #wait indefinitely + if timeout is None: + while self.__module.command_ack is None: + pass + result = self.__module.command_ack + self.__module.command_ack = None #reset cmd_ack + return result + + #wait for timeout + start = time.time() + while (time.time() - start) < timeout and self.__module.command_ack is None: + pass + result = self.__module.command_ack + self.__module.command_ack = None #reset cmd_ack + return result + + @property def __wp(self): return self.__module.module('wp') @@ -310,7 +328,6 @@ def __init__(self, module, fn, description): # DroneAPI might generate many commands, which in turn generate ots of acks and status text, in the interest of speed we ignore processing those messages try: - self.module.mpstate.rx_blacklist.add('COMMAND_ACK') self.module.mpstate.rx_blacklist.add('STATUSTEXT') except: pass # Silently work with old mavproxies @@ -329,7 +346,6 @@ def run(self): traceback.print_exc() try: - self.module.mpstate.rx_blacklist.remove('COMMAND_ACK') self.module.mpstate.rx_blacklist.remove('STATUSTEXT') except: pass # Silently work with old mavproxies @@ -382,6 +398,8 @@ def __init__(self, mpstate): self.satellites_visible = None self.fix_type = None # FIXME support multiple GPSs per vehicle - possibly by using componentId + self.command_ack = None + self.next_thread_num = 0 # Monotonically increasing self.threads = {} # A map from int ID to thread object @@ -472,6 +490,8 @@ def set(chnum, v): self.mount_roll = m.pointing_b / 100 self.mount_yaw = m.pointing_c / 100 self.__on_change('mount') + elif typ == "COMMAND_ACK": + self.command_ack = m.result if (self.vehicle is not None) and hasattr(self.vehicle, 'mavrx_callback'):