def __init__(self, port='/dev/ttyACM0'): self.ser = serial.Serial(port, 115200, timeout=0) if self.ser.isOpen: self.ser.flushInput() self.ser.flushOutput() else: print "Error when opening serial port" self.mav = mavlink.MAVLink(0)
def __init__(self, device="/dev/ttyUSB0", baudrate=1000000, callback_all=lambda msg: None, *args, **kwargs): self.data_amounts = defaultdict(int) self.data_timings = defaultdict(float) self.serial = serial.Serial(device, baudrate, timeout=0.1) self.mavlink_link = mavlink.MAVLink(FakeFile()) self.mavlink_link.set_callback(self.internal_callback_all) self.external_callback_all = callback_all self.start = time.time() self.callbacks = defaultdict(lambda: lambda msg: None)
def __init__(self, addr=None, agg_max_size=None, agg_timeout=None, inject_rssi=False): # use self.write to send mavlink message if inject_rssi: self.mav = mavlink.MAVLink(self, srcSystem=3, srcComponent=242) # WFB else: self.mav = None self.peer = None self.reply_addr = addr self.agg_max_size = agg_max_size self.agg_timeout = agg_timeout self.agg_queue = [] self.agg_queue_size = 0 self.agg_queue_timer = None
def __init__(self, host, port): self.host = host self.port = port self.mav = mavlink.MAVLink(self, srcSystem=1, srcComponent=242) # WFB
# fifo object for mavlink class fifo(object): def __init__(self): self.buf = [] def write(self, data): self.buf += data return len(data) def read(self): return self.buf.pop(0) f = fifo() # buffer for mavlink mav = mavlink.MAVLink(f) STEP = 1 # шаг по оси Х SCOPE_LEN = 100 # количество точек на экране # import fir # taps = fir.get_taps() # lfilter(taps, 1.0, i[1]) # print taps mag = [] def gen(): i = 0 X = []