예제 #1
0
파일: mavutil.py 프로젝트: oberion/mavlink
 def auto_mavlink_version(self, buf):
     '''auto-switch mavlink protocol version'''
     global mavlink, GPS_RAW
     if len(buf) == 0:
         return
     if not ord(buf[0]) in [85, 254]:
         return
     self.first_byte = False
     if self.WIRE_PROTOCOL_VERSION == "0.9" and ord(buf[0]) == 254:
         import mavlinkv10 as mavlink
         GPS_RAW = 'GPS_RAW_INT'
     elif self.WIRE_PROTOCOL_VERSION == "1.0" and ord(buf[0]) == 85:
         import mavlinkv09 as mavlink
         os.environ['MAVLINK09'] = '1'
         GPS_RAW = 'GPS_RAW'
     else:
         return
     # switch protocol
     (callback, callback_args,
      callback_kwargs) = (self.mav.callback, self.mav.callback_args,
                          self.mav.callback_kwargs)
     self.mav = mavlink.MAVLink(self, srcSystem=self.source_system)
     self.mav.robust_parsing = self.robust_parsing
     self.WIRE_PROTOCOL_VERSION = mavlink.WIRE_PROTOCOL_VERSION
     (self.mav.callback, self.mav.callback_args,
      self.mav.callback_kwargs) = (callback, callback_args, callback_kwargs)
예제 #2
0
파일: mavutil.py 프로젝트: oberion/mavlink
 def __init__(self,
              fd,
              address,
              source_system=255,
              notimestamps=False,
              input=True):
     global mavfile_global
     if input:
         mavfile_global = self
     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.target_system = 0
     self.target_component = 0
     self.source_system = source_system
     self.first_byte = True
     self.robust_parsing = True
     self.mav = mavlink.MAVLink(self, srcSystem=self.source_system)
     self.mav.robust_parsing = self.robust_parsing
     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.uptime = 0.0
     self.notimestamps = notimestamps
     self._timestamp = None
     self.ground_pressure = None
     self.ground_temperature = None
     self.altitude = 0
     self.WIRE_PROTOCOL_VERSION = mavlink.WIRE_PROTOCOL_VERSION
     if self.WIRE_PROTOCOL_VERSION == '0.9':
         self.GPS_RAW = 'GPS_RAW'
     else:
         self.GPS_RAW = 'GPS_RAW_INT'
     self.last_seq = -1
     self.mav_loss = 0
     self.mav_count = 0
     self.stop_on_EOF = False