Пример #1
0
 def __init__(self, GCSport, debug_level):
     self._PortGCS = GCSport
     self._PortMe = 14555
     self._IP = "127.0.0.1"
     self._LocalGCSConnection = None
     self._DEBUG_LEVEL = debug_level
     f = fifo()
     self._MavlinkHelperObject = mavlink.MAVLink(f)
 def __init__(self, SendToPhoneNumber, LocalModemPath, baud=115200, DEBUG_LEVEL=2):
     self._RemotePhoneNumber = SendToPhoneNumber
     self._DEBUG_LEVEL = DEBUG_LEVEL
     self._ModemLocation = LocalModemPath
     f=fifo()
     self._MavlinkHelperObject = mavlink.MAVLink(f)
     self._ModemLock = multiprocessing.Lock()
     self._ModemConnection = gsmmodem.GsmModem(port=LocalModemPath, baudrate=baud)
     try:
         self._PrepareModem()
     except Exception, err:
         self.Logger("Modem Init failed"+str(err), message_importance=1)
         self._ModemConnection=None
Пример #3
0
    def __init__(self, s_type, zmq_context, port, serial_port, serial_baud,
                 udp_client, udp_port):
        self.s_type = s_type
        self.zmq_context = zmq_context
        self.server = zmq_context.socket(zmq.REP)
        self.data_server = zmq_context.socket(zmq.PUB)
        self.data_server.bind('tcp://*:' + port)
        self.server.bind('tcp://*:' + str(int(port) + 1))
        self.poller = zmq.Poller()
        self.poller.register(self.server, zmq.POLLIN)
        self.udp_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.addr = (str(udp_client), int(udp_port))

        self.marker = zmq_context.socket(zmq.SUB)
        self.marker.setsockopt(zmq.SUBSCRIBE, '')
        self.marker.connect('tcp://192.168.0.114:4999')
        self.mark_poller = zmq.Poller()
        self.mark_poller.register(self.marker, zmq.POLLIN)
        self.mark = 0.0
        self.error_lines = 0
        self.sent_lines = 0
        self.time = 0

        if s_type == 0:  # Serial port
            self.ser = serial.Serial(port=serial_port,
                                     baudrate=serial_baud,
                                     timeout=0,
                                     xonxoff=False,
                                     rtscts=False,
                                     dsrdtr=False)
        elif s_type == 1:
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.sock.connect(("192.168.0.113", 2000))
        elif s_type == 2:
            self.subscriber = self.zmq_context.socket(zmq.SUB)
            self.subscriber.setsockopt(zmq.SUBSCRIBE, '')
            self.subscriber.connect('tcp://192.168.0.150:4002')

        self.fifo = fifo()
        self.mav = mavlink.MAVLink(self.fifo)
        self.buffer = ''
        self.log_file = open('ardupilot.log', 'a')
Пример #4
0
    def __init__(self):
        self.buf = []

    def write(self, data):
        self.buf += data
        return len(data)

    def read(self):
        return self.buf.pop(0)


# we will use a fifo as an encode/decode buffer
f = fifo()

# create a mavlink instance, which will do IO on file object 'f'
mav = mavlink.MAVLink(f)

# set the WP_RADIUS parameter on the MAV at the end of the link
mav.param_set_send(7, 1, "WP_RADIUS", 101, mavlink.MAV_PARAM_TYPE_REAL32)

# alternatively, produce a MAVLink_param_set object
# this can be sent via your own transport if you like
m = mav.param_set_encode(7, 1, "WP_RADIUS", 101, mavlink.MAV_PARAM_TYPE_REAL32)

# get the encoded message as a buffer
b = m.get_msgbuf()

# decode an incoming message
m2 = mav.decode(b)

# show what fields it has
Пример #5
0
 def __init__(self, source_system):
     self.mav = mavlink.MAVLink(self, srcSystem=source_system)
     self.mav.robust_parsing = True