예제 #1
0
def main():
    global interface_drone_comm, IP_RX, UDP_Port_RX, UDP_PORT_ANDROID
    parsedArgs = parsearguments()
    interface_drone_comm = parsedArgs.interface_drone_comm
    mode = parsedArgs.mode
    IP_RX = parsedArgs.ip_rx
    UDP_Port_RX = parsedArgs.udp_port_rx
    UDP_PORT_ANDROID = parsedArgs.udp_port_android
    frame_type = parsedArgs.frame_type

    src = find_mac(interface_drone_comm)
    extended_comm_id = bytes(
        b'\x01' + b'\x01' +
        bytearray.fromhex(parsedArgs.comm_id))  # <odd><direction><comm_id>
    # print("DB_TX_Comm: Communication ID: " + comm_id.hex()) # only works in python 3.5+
    print("DB_TX_Comm: Communication ID: " + str(extended_comm_id))

    dbprotocol = DBProtocol(src, dst, UDP_Port_RX, IP_RX, UDP_PORT_ANDROID,
                            b'\x01', interface_drone_comm, mode,
                            extended_comm_id, frame_type, b'\x04')
    if mode == 'wifi':
        dbprotocol.updateRouting()

    last_keepalive = 0

    while True:
        last_keepalive = dbprotocol.process_smartphonerequests(
            last_keepalive)  # non-blocking
        time.sleep(0.5)
예제 #2
0
def main():
    global interface_drone_comm, IP_RX, UDP_Port_RX, fifo_write
    parsedArgs = parsearguments()
    interface_drone_comm = parsedArgs.interface_drone_comm
    mode = parsedArgs.mode
    IP_RX = parsedArgs.ip_rx
    UDP_Port_RX = parsedArgs.udp_port_rx
    frame_type = parsedArgs.frame_type

    src = find_mac(interface_drone_comm)
    comm_id = bytes([parsedArgs.comm_id])
    print("DB_TEL_GROUND: Communication ID: " + str(comm_id))

    dbprotocol = DBProtocol(src, UDP_Port_RX, IP_RX, 1606, b'\x01',
                            interface_drone_comm, mode, comm_id, frame_type,
                            b'\x02')
    print("DB_TEL_GROUND: Opening /root/telemetryfifo1...")
    fifo_write = open("/root/telemetryfifo1", "wb")
    print("DB_TEL_GROUND: Opened /root/telemetryfifo1")

    while True:
        received = dbprotocol.receive_telemetryfromdrone()
        if received != False:
            try:
                write_tofifos(received)
                sent = dbprotocol.sendto_smartphone(received,
                                                    dbprotocol.APP_PORT_TEL)
                # print("DB_TX_TEL: Sent "+str(sent)+" bytes to sp")
            except Exception as e:
                print(e)
예제 #3
0
def main():
    global SerialPort, UDP_Port_TX, IP_TX
    parsedArgs = parseArguments()
    UDP_Port_TX = 1604
    mode = parsedArgs.mode
    frame_type = parsedArgs.frame_type
    DB_INTERFACE = parsedArgs.DB_INTERFACE
    src = find_mac(DB_INTERFACE)
    comm_id = bytes([parsedArgs.comm_id])
    # print("DB_TX_Comm: Communication ID: " + comm_id.hex()) # only works in python 3.5+
    print("DB_RX_Comm: Communication ID: " + str(comm_id))
    dbprotocol = DBProtocol(src, UDP_Port_TX, IP_TX, 0, b'\x03', DB_INTERFACE,
                            mode, comm_id, frame_type, b'\x04')

    while True:
        dbprotocol.receive_process_datafromgroundstation()  # blocking
예제 #4
0
def main():
    global SerialPort, UDP_Port_TX, IP_TX
    parsedArgs = parseArguments()
    SerialPort = parsedArgs.serialport
    UDP_Port_TX = parsedArgs.udp_port_tx
    istelemetryenabled = False
    if parsedArgs.enable_telemetry == "yes":
        istelemetryenabled = True
    mode = parsedArgs.mode
    frame_type = parsedArgs.frame_type
    DB_INTERFACE = parsedArgs.DB_INTERFACE
    src = find_mac(DB_INTERFACE)
    comm_id = bytes(b'\x01' + b'\x02' + bytearray.fromhex(parsedArgs.comm_id))
    # print("DB_RX_TEL: Communication ID: " + comm_id.hex()) # only works in python 3.5
    print("DB_RX_TEL: Communication ID: " + str(comm_id))
    dbprotocol = DBProtocol(src, dst, UDP_Port_TX, IP_TX, 0, b'\x02',
                            DB_INTERFACE, mode, comm_id, frame_type, b'\x02')

    if istelemetryenabled:
        tel_sock = openFCTel_Socket()
    time.sleep(0.3)

    while True:
        # Test
        # LTM_Frame = b'$TA\x00\x00\x01\x00\xf0\x00\xf1'
        # dbprotocol.sendto_groundstation(LTM_Frame, b'\x02')
        # time.sleep(1)
        # Test end
        if istelemetryenabled:
            if tel_sock.read() == b'$':
                tel_sock.read()  # next one is always a 'T' (do not care)
                LTM_Frame = read_LTM_Frame(tel_sock.read(), tel_sock)
                dbprotocol.sendto_groundstation(LTM_Frame, b'\x02')
                # create DroneBridgeFrame and send
                if LTM_Frame[
                        2] == 83:  # int("53", 16) --> 0x53 = S in UTF-8 --> sending frame after each status frame
                    dbprotocol.send_dronebridge_frame()
        dbprotocol.receive_process_datafromgroundstation(
        )  # to get the beacon frame and its RSSI values
        if not istelemetryenabled:
            # DroneBridge LTM Frame is triggered from LTM origin frame. If telemetry is "no" we need to change trigger
            dbprotocol.send_dronebridge_frame()
            time.sleep(0.2)
예제 #5
0
def main():
    global SerialPort, UDP_Port_TX, IP_TX
    parsedArgs = parseArguments()
    UDP_Port_TX = parsedArgs.udp_port_tx
    mode = parsedArgs.mode
    frame_type = parsedArgs.frame_type
    DB_INTERFACE = parsedArgs.DB_INTERFACE
    src = find_mac(DB_INTERFACE)
    extended_comm_id = bytes(
        b'\x01' + b'\x02' +
        bytearray.fromhex(parsedArgs.comm_id))  # <odd><direction><comm_id>
    # print("DB_TX_Comm: Communication ID: " + comm_id.hex()) # only works in python 3.5+
    print("DB_RX_Comm: Communication ID: " + str(extended_comm_id))
    dbprotocol = DBProtocol(src, dst, UDP_Port_TX, IP_TX, 0, b'\x02',
                            DB_INTERFACE, mode, extended_comm_id, frame_type,
                            b'\x04')

    #setupVideo(mode)
    #time.sleep(2)
    while True:
        dbprotocol.receive_process_datafromgroundstation()  # blocking
예제 #6
0
def main():
    global interface_drone_comm, IP_RX, UDP_Port_RX, UDP_PORT_ANDROID
    parsedArgs = parsearguments()
    interface_drone_comm = parsedArgs.interface_drone_comm
    mode = parsedArgs.mode
    IP_RX = parsedArgs.ip_rx
    UDP_Port_RX = parsedArgs.udp_port_rx
    UDP_PORT_ANDROID = parsedArgs.udp_port_android

    src = find_mac(interface_drone_comm)
    comm_id = bytes([parsedArgs.comm_id])
    print("DB_Comm_GROUND: Communication ID: " + str(comm_id))

    dbprotocol = DBProtocol(src, UDP_Port_RX, IP_RX, UDP_PORT_ANDROID, b'\x01',
                            interface_drone_comm, mode, comm_id, b'\x04')
    last_keepalive = 0

    while True:
        last_keepalive = dbprotocol.process_smartphonerequests(
            last_keepalive)  # non-blocking
        time.sleep(0.5)
예제 #7
0
def main():
    global interface_drone_comm, IP_RX, UDP_Port_RX, fifo_write
    parsedArgs = parsearguments()
    interface_drone_comm = parsedArgs.interface_drone_comm
    mode = parsedArgs.mode
    IP_RX = parsedArgs.ip_rx
    UDP_Port_RX = parsedArgs.udp_port_rx
    frame_type = parsedArgs.frame_type

    src = find_mac(interface_drone_comm)
    comm_id = bytes(b'\x01' + b'\x01' + bytearray.fromhex(parsedArgs.comm_id))
    # print("DB_TX_TEL: Communication ID: " + comm_id.hex()) # only works in python 3.5
    print("DB_TX_TEL: Communication ID: " + str(comm_id))

    dbprotocol = DBProtocol(src, dst, UDP_Port_RX, IP_RX, 1606, b'\x01',
                            interface_drone_comm, mode, comm_id, frame_type,
                            b'\x02')
    print("DB_TX_TEL: Opening /root/telemetryfifo1...")
    fifo_write = open("/root/telemetryfifo1", "wb")
    print("DB_TX_TEL: Opened /root/telemetryfifo1")

    while True:
        received = dbprotocol.receive_telemetryfromdrone()
        #received= b'$TA\x00\x00\x01\x00\xf0\x00\xf1'
        #time.sleep(0.15)
        if received != False:
            try:
                if received[2] == 89:  # int("59", 16)
                    received = dbprotocol.finish_dronebridge_ltmframe(received)
                    # send a beaconframe so drone telemetry can extract signal strength. MSP RSSI over AUX is also a option
                    # Then RSSI field in LTM would be set correctly. But RSSI would be in % which is worse compared to dbm
                    dbprotocol.send_beacon()
                write_tofifos(received)
                sent = dbprotocol.sendto_smartphone(
                    received, dbprotocol.LTM_PORT_SMARTPHONE)
                #print("DB_TX_TEL: Sent "+str(sent)+" bytes to sp")
            except Exception as e:
                print(e)
예제 #8
0
def main():
    global SerialPort, UDP_Port_TX, IP_TX
    parsedArgs = parseArguments()
    SerialPort = parsedArgs.serialport
    UDP_Port_TX = parsedArgs.udp_port_tx
    mode = parsedArgs.mode
    frame_type = parsedArgs.frame_type
    DB_INTERFACE = parsedArgs.DB_INTERFACE
    telemetry_selection_auto = False
    isLTMTel = True
    if parsedArgs.telemetry_type == "mavlink":
        isLTMTel = False
    elif parsedArgs.telemetry_type == "auto":
        telemetry_selection_auto = True
        isLTMTel = False
    src = find_mac(DB_INTERFACE)
    comm_id = bytes([parsedArgs.comm_id])
    # print("DB_RX_TEL: Communication ID: " + comm_id.hex()) # only works in python 3.5
    print("DB_TEL_AIR: Communication ID: " + str(comm_id))
    dbprotocol = DBProtocol(src, UDP_Port_TX, IP_TX, 0, b'\x03', DB_INTERFACE,
                            mode, comm_id, frame_type, b'\x02')

    tel_sock = openFCTel_Socket()
    time.sleep(0.3)
    if telemetry_selection_auto:
        isLTMTel = isitLTM_telemetry(tel_sock)
    time.sleep(0.3)

    while True:
        if isLTMTel:
            if tel_sock.read() == b'$':
                tel_sock.read()  # next one is always a 'T' (do not care)
                LTM_Frame = read_LTM_Frame(tel_sock.read(), tel_sock)
                dbprotocol.sendto_groundstation(LTM_Frame, b'\x02')
        else:
            # it is not LTM --> fully transparent link for MavLink and other protocols
            dbprotocol.sendto_groundstation(tel_sock.read(MavLink_junksize),
                                            b'\x02')