From 3c9965f5e57c48e83d2d1719d538f756dbab7321 Mon Sep 17 00:00:00 2001 From: olliw42 Date: Thu, 5 Sep 2024 09:52:10 +0200 Subject: [PATCH] AP_DroneCAN: set protocol in tunnel.Targetted message according to protocol parameter --- libraries/AP_DroneCAN/AP_DroneCAN_serial.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libraries/AP_DroneCAN/AP_DroneCAN_serial.cpp b/libraries/AP_DroneCAN/AP_DroneCAN_serial.cpp index 56102a4d30..bf5b94edaa 100644 --- a/libraries/AP_DroneCAN/AP_DroneCAN_serial.cpp +++ b/libraries/AP_DroneCAN/AP_DroneCAN_serial.cpp @@ -86,7 +86,20 @@ void AP_DroneCAN_Serial::update(void) } n = MIN(avail, sizeof(pkt.buffer.data)); pkt.target_node = p.node; - pkt.protocol.protocol = UAVCAN_TUNNEL_PROTOCOL_UNDEFINED; + switch (p.state.protocol) { + case AP_SerialManager::SerialProtocol_MAVLink: + pkt.protocol.protocol = UAVCAN_TUNNEL_PROTOCOL_MAVLINK; + break; + case AP_SerialManager::SerialProtocol_MAVLink2: + pkt.protocol.protocol = UAVCAN_TUNNEL_PROTOCOL_MAVLINK2; + break; + case AP_SerialManager::SerialProtocol_GPS: + case AP_SerialManager::SerialProtocol_GPS2: // is not in SERIAL1_PROTOCOL option list, but could be entered by user + pkt.protocol.protocol = UAVCAN_TUNNEL_PROTOCOL_GPS_GENERIC; + break; + default: + pkt.protocol.protocol = UAVCAN_TUNNEL_PROTOCOL_UNDEFINED; + } pkt.buffer.len = n; pkt.baudrate = p.baudrate; pkt.serial_id = p.idx;