diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 80ca3694c728c14fb48c81979f9b2e442a575179..f9703964ea32d262312a9e89fb0d05bd55578542 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -1005,14 +1005,22 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) const unsigned int portWidth = 8; // XXX magic number emit remoteControlRSSIChanged(channels.rssi/255.0f); - emit remoteControlChannelRawChanged(channels.port * portWidth + 0, channels.chan1_raw); - emit remoteControlChannelRawChanged(channels.port * portWidth + 1, channels.chan2_raw); - emit remoteControlChannelRawChanged(channels.port * portWidth + 2, channels.chan3_raw); - emit remoteControlChannelRawChanged(channels.port * portWidth + 3, channels.chan4_raw); - emit remoteControlChannelRawChanged(channels.port * portWidth + 4, channels.chan5_raw); - emit remoteControlChannelRawChanged(channels.port * portWidth + 5, channels.chan6_raw); - emit remoteControlChannelRawChanged(channels.port * portWidth + 6, channels.chan7_raw); - emit remoteControlChannelRawChanged(channels.port * portWidth + 7, channels.chan8_raw); + if (channels.chan1_raw != UINT16_MAX) + emit remoteControlChannelRawChanged(channels.port * portWidth + 0, channels.chan1_raw); + if (channels.chan2_raw != UINT16_MAX) + emit remoteControlChannelRawChanged(channels.port * portWidth + 1, channels.chan2_raw); + if (channels.chan3_raw != UINT16_MAX) + emit remoteControlChannelRawChanged(channels.port * portWidth + 2, channels.chan3_raw); + if (channels.chan4_raw != UINT16_MAX) + emit remoteControlChannelRawChanged(channels.port * portWidth + 3, channels.chan4_raw); + if (channels.chan5_raw != UINT16_MAX) + emit remoteControlChannelRawChanged(channels.port * portWidth + 4, channels.chan5_raw); + if (channels.chan6_raw != UINT16_MAX) + emit remoteControlChannelRawChanged(channels.port * portWidth + 5, channels.chan6_raw); + if (channels.chan7_raw != UINT16_MAX) + emit remoteControlChannelRawChanged(channels.port * portWidth + 6, channels.chan7_raw); + if (channels.chan8_raw != UINT16_MAX) + emit remoteControlChannelRawChanged(channels.port * portWidth + 7, channels.chan8_raw); } break; case MAVLINK_MSG_ID_RC_CHANNELS_SCALED: @@ -1023,14 +1031,22 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) const unsigned int portWidth = 8; // XXX magic number emit remoteControlRSSIChanged(channels.rssi/255.0f); - emit remoteControlChannelScaledChanged(channels.port * portWidth + 0, channels.chan1_scaled/10000.0f); - emit remoteControlChannelScaledChanged(channels.port * portWidth + 1, channels.chan2_scaled/10000.0f); - emit remoteControlChannelScaledChanged(channels.port * portWidth + 2, channels.chan3_scaled/10000.0f); - emit remoteControlChannelScaledChanged(channels.port * portWidth + 3, channels.chan4_scaled/10000.0f); - emit remoteControlChannelScaledChanged(channels.port * portWidth + 4, channels.chan5_scaled/10000.0f); - emit remoteControlChannelScaledChanged(channels.port * portWidth + 5, channels.chan6_scaled/10000.0f); - emit remoteControlChannelScaledChanged(channels.port * portWidth + 6, channels.chan7_scaled/10000.0f); - emit remoteControlChannelScaledChanged(channels.port * portWidth + 7, channels.chan8_scaled/10000.0f); + if (channels.chan1_scaled != UINT16_MAX) + emit remoteControlChannelScaledChanged(channels.port * portWidth + 0, channels.chan1_scaled/10000.0f); + if (channels.chan2_scaled != UINT16_MAX) + emit remoteControlChannelScaledChanged(channels.port * portWidth + 1, channels.chan2_scaled/10000.0f); + if (channels.chan3_scaled != UINT16_MAX) + emit remoteControlChannelScaledChanged(channels.port * portWidth + 2, channels.chan3_scaled/10000.0f); + if (channels.chan4_scaled != UINT16_MAX) + emit remoteControlChannelScaledChanged(channels.port * portWidth + 3, channels.chan4_scaled/10000.0f); + if (channels.chan5_scaled != UINT16_MAX) + emit remoteControlChannelScaledChanged(channels.port * portWidth + 4, channels.chan5_scaled/10000.0f); + if (channels.chan6_scaled != UINT16_MAX) + emit remoteControlChannelScaledChanged(channels.port * portWidth + 5, channels.chan6_scaled/10000.0f); + if (channels.chan7_scaled != UINT16_MAX) + emit remoteControlChannelScaledChanged(channels.port * portWidth + 6, channels.chan7_scaled/10000.0f); + if (channels.chan8_scaled != UINT16_MAX) + emit remoteControlChannelScaledChanged(channels.port * portWidth + 7, channels.chan8_scaled/10000.0f); } break; case MAVLINK_MSG_ID_PARAM_VALUE: