def __init__(self, fd, address, source_system=255): self.fd = fd self.address = address self.messages = {'MAV': self} if mavlink.WIRE_PROTOCOL_VERSION == "1.0": self.messages['HOME'] = mavlink.MAVLink_gps_raw_int_message( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) mavlink.MAVLink_waypoint_message = mavlink.MAVLink_mission_item_message else: self.messages['HOME'] = mavlink.MAVLink_gps_raw_message( 0, 0, 0, 0, 0, 0, 0, 0, 0) self.params = {} self.mav = None self.target_system = 0 self.target_component = 0 self.mav = mavlink.MAVLink(self, srcSystem=source_system) self.mav.robust_parsing = True self.logfile = None self.logfile_raw = None self.param_fetch_in_progress = False self.param_fetch_complete = False self.start_time = time.time() self.flightmode = "UNKNOWN" self.timestamp = 0 self.message_hooks = [] self.idle_hooks = [] self.usec = 0 self.notimestamps = False self._timestamp = time.time()
def getdata(s, f, csvgri, csvms): grinames = getdatafields(mavlink.MAVLink_gps_raw_int_message(0,0,0,0,0,0,0,0,0,0)) msnames = getdatafields(mavlink.MAVLink_mpiovd_sensors_message(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,)) csvgri.writerow(grinames) csvms.writerow(msnames) mav.oblique_storage_request_send(20, 0, s, f) while s < f: try: m = master.recv_msg() if type(m) == mavlink.MAVLink_gps_raw_int_message: print "gps_raw_int ", m.time_usec / 1000 store(m.__dict__, grinames, csvgri) s += 0.5 elif type(m) == mavlink.MAVLink_mpiovd_sensors_message: print "mpiovd_sensors", m.time_usec / 1000 store(m.__dict__, msnames, csvms) s += 0.5 except socket.timeout: pass print "-----------------------------------------" print "done"