def mavlink_packet(self, m):
        '''handle an incoming mavlink packet'''
        mtype = m.get_type()
        if mtype in ['WAYPOINT_COUNT','MISSION_COUNT']:
            if self.wp_op is None:
                self.console.error("No waypoint load started")
            else:
                self.wploader.clear()
                self.wploader.expected_count = m.count
                self.console.writeln("Requesting %u waypoints t=%s now=%s" % (m.count,
                                                                                 time.asctime(time.localtime(m._timestamp)),
                                                                                 time.asctime()))
                self.master.waypoint_request_send(0)

        elif mtype in ['WAYPOINT', 'MISSION_ITEM'] and self.wp_op != None:
            if m.seq > self.wploader.count():
                self.console.writeln("Unexpected waypoint number %u - expected %u" % (m.seq, self.wploader.count()))
            elif m.seq < self.wploader.count():
                # a duplicate
                pass
            else:
                self.wploader.add(m)
            if m.seq+1 < self.wploader.expected_count:
                self.master.waypoint_request_send(m.seq+1)
            else:
                if self.wp_op == 'list':
                    for i in range(self.wploader.count()):
                        w = self.wploader.wp(i)
                        print("%u %u %.10f %.10f %f p1=%.1f p2=%.1f p3=%.1f p4=%.1f cur=%u auto=%u" % (
                            w.command, w.frame, w.x, w.y, w.z,
                            w.param1, w.param2, w.param3, w.param4,
                            w.current, w.autocontinue))
                    if self.logdir != None:
                        waytxt = os.path.join(self.logdir, 'way.txt')
                        self.save_waypoints(waytxt)
                        print("Saved waypoints to %s" % waytxt)
                elif self.wp_op == "save":
                    self.save_waypoints(self.wp_save_filename)
                self.wp_op = None

        elif mtype in ["WAYPOINT_REQUEST", "MISSION_REQUEST"]:
            self.process_waypoint_request(m, self.master)

        elif mtype in ["WAYPOINT_CURRENT", "MISSION_CURRENT"]:
            if m.seq != self.last_waypoint:
                self.last_waypoint = m.seq
                if self.settings.wpupdates:
                    self.say("waypoint %u" % m.seq,priority='message')
def mavlink_packet ( self , m ) : mtype = m . get_type ( ) if mtype in [ 'WAYPOINT_COUNT' , 'MISSION_COUNT' ] : if self . wp_op is None : self . console . error ( "No waypoint load started" ) else : self . wploader . clear ( ) self . wploader . expected_count = m . count self . console . writeln ( "Requesting %u waypoints t=%s now=%s" % ( m . count , time . asctime ( time . localtime ( m . _timestamp ) ) , time . asctime ( ) ) ) self . master . waypoint_request_send ( 0 ) elif mtype in [ 'WAYPOINT' , 'MISSION_ITEM' ] and self . wp_op != None : if m . seq > self . wploader . count ( ) : self . console . writeln ( "Unexpected waypoint number %u - expected %u" % ( m . seq , self . wploader . count ( ) ) ) elif m . seq < self . wploader . count ( ) : pass else : self . wploader . add ( m ) if m . seq + 1 < self . wploader . expected_count : self . master . waypoint_request_send ( m . seq + 1 ) else : if self . wp_op == 'list' : for i in range ( self . wploader . count ( ) ) : w = self . wploader . wp ( i ) print ( "%u %u %.10f %.10f %f p1=%.1f p2=%.1f p3=%.1f p4=%.1f cur=%u auto=%u" % ( w . command , w . frame , w . x , w . y , w . z , w . param1 , w . param2 , w . param3 , w . param4 , w . current , w . autocontinue ) ) if self . logdir != None : waytxt = os . path . join ( self . logdir , 'way.txt' ) self . save_waypoints ( waytxt ) print ( "Saved waypoints to %s" % waytxt ) elif self . wp_op == "save" : self . save_waypoints ( self . wp_save_filename ) self . wp_op = None elif mtype in [ "WAYPOINT_REQUEST" , "MISSION_REQUEST" ] : self . process_waypoint_request ( m , self . master ) elif mtype in [ "WAYPOINT_CURRENT" , "MISSION_CURRENT" ] : if m . seq != self . last_waypoint : self . last_waypoint = m . seq if self . settings . wpupdates : self . say ( "waypoint %u" % m . seq , priority = 'message' )
handle an incoming mavlink packet