Skip to content

Commit ba71fd6

Browse files
committed
GCS_MAVLink: handle RADIO_RC_CHANNELS
1 parent 5ed167c commit ba71fd6

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

libraries/GCS_MAVLink/GCS.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ class GCS_MAVLINK
683683
void handle_optical_flow(const mavlink_message_t &msg);
684684

685685
void handle_manual_control(const mavlink_message_t &msg);
686+
void handle_radio_rc_channels(const mavlink_message_t &msg);
686687

687688
// default empty handling of LANDING_TARGET
688689
virtual void handle_landing_target(const mavlink_landing_target_t &packet, uint32_t timestamp_ms) { }
@@ -746,6 +747,9 @@ class GCS_MAVLINK
746747
mavlink_message_t _channel_buffer;
747748
mavlink_status_t _channel_status;
748749

750+
// for mavlink radio
751+
mavlink_radio_t _mavlink_radio_packet;
752+
749753
const AP_SerialManager::UARTState *uartstate;
750754

751755
// last time we got a non-zero RSSI from RADIO_STATUS

libraries/GCS_MAVLink/GCS_Common.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4102,6 +4102,9 @@ void GCS_MAVLINK::handle_common_message(const mavlink_message_t &msg)
41024102
case MAVLINK_MSG_ID_RC_CHANNELS_OVERRIDE:
41034103
handle_rc_channels_override(msg);
41044104
break;
4105+
case MAVLINK_MSG_ID_RADIO_RC_CHANNELS:
4106+
handle_radio_rc_channels(msg);
4107+
break;
41054108

41064109
#if AP_OPTICALFLOW_ENABLED
41074110
case MAVLINK_MSG_ID_OPTICAL_FLOW:
@@ -6407,6 +6410,12 @@ bool GCS_MAVLINK::accept_packet(const mavlink_status_t &status,
64076410
return true;
64086411
}
64096412

6413+
// handle messages from a mavlink receiver
6414+
if ((msg.compid == MAV_COMP_ID_TELEMETRY_RADIO) &&
6415+
(msg.msgid == MAVLINK_MSG_ID_RADIO_RC_CHANNELS)) {
6416+
return true;
6417+
}
6418+
64106419
if (!sysid_enforce()) {
64116420
return true;
64126421
}
@@ -6780,4 +6789,12 @@ MAV_RESULT GCS_MAVLINK::handle_control_high_latency(const mavlink_command_int_t
67806789
}
67816790
#endif // HAL_HIGH_LATENCY2_ENABLED
67826791

6792+
void GCS_MAVLINK::handle_radio_rc_channels(const mavlink_message_t &msg)
6793+
{
6794+
mavlink_radio_rc_channels_t packet;
6795+
mavlink_msg_radio_rc_channels_decode(&msg, &packet);
6796+
6797+
AP::RC().handle_radio_rc_channels(&packet);
6798+
}
6799+
67836800
#endif // HAL_GCS_ENABLED

libraries/GCS_MAVLink/MAVLink_routing.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ bool MAVLink_routing::check_and_forward(GCS_MAVLINK &in_link, const mavlink_mess
140140
int16_t target_component = -1;
141141
get_targets(msg, target_system, target_component);
142142

143+
// handle messages from a mavlink receiver as if it had target_system = our system, target_component = 0
144+
if ((msg.compid == MAV_COMP_ID_TELEMETRY_RADIO) &&
145+
(msg.msgid == MAVLINK_MSG_ID_RADIO_RC_CHANNELS)) {
146+
target_system = mavlink_system.sysid;
147+
target_component = 0;
148+
}
149+
143150
bool broadcast_system = (target_system == 0 || target_system == -1);
144151
bool broadcast_component = (target_component == 0 || target_component == -1);
145152
bool match_system = broadcast_system || (target_system == mavlink_system.sysid);

0 commit comments

Comments
 (0)