AP_DroneCAN: set protocol in tunnel.Targetted message according to protocol parameter

This commit is contained in:
olliw42 2024-09-05 09:52:10 +02:00 committed by Andrew Tridgell
parent 62806c6cd6
commit 3c9965f5e5
1 changed files with 14 additions and 1 deletions

View File

@ -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;