Skip to content

Commit

Permalink
AP_DroneCAN: set protocol in tunnel.Targetted message according to pr…
Browse files Browse the repository at this point in the history
…otocol parameter
  • Loading branch information
olliw42 authored and tridge committed Sep 10, 2024
1 parent 62806c6 commit 3c9965f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion libraries/AP_DroneCAN/AP_DroneCAN_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3c9965f

Please sign in to comment.