Companion computer and MAVLINK_MSG_ID_RC_CHANNELS_RAW

On a companion computer I have a connection to Rover 4.2.1
I request a stream like this;

#define CC_SYSID 2
#define CC_COMPID 200
void mavlink_Request_Data()
{
  mavlink_message_t msg;
  uint8_t buf[MAVLINK_MAX_PACKET_LEN];
  const int  maxStreams = 1;
  const uint8_t MAVStreams[maxStreams] = {MAV_DATA_STREAM_RC_CHANNELS};
  const uint16_t MAVRates[maxStreams] = {0x01};
    
  for (int i=0; i < maxStreams; i++) {
    mavlink_msg_request_data_stream_pack(CC_SYSID, CC_COMPID, &msg, 1, 0, MAVStreams[i], MAVRates[i], 1);
    uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);
    ardupilotPort.write(buf, len);
  }
}

and I receive like this;

void mavlink_receive() {
  mavlink_message_t msg;
  mavlink_status_t status;

  while(ardupilotPort.available()>0) {
    uint8_t c = ardupilotPort.read();

    if(mavlink_parse_char(MAVLINK_COMM_0, c, &msg, &status)) {
      Serial.println(msg.msgid);

      // Handle message
      switch(msg.msgid) {
        case MAVLINK_MSG_ID_RC_CHANNELS_RAW:
        {
          mavlink_rc_channels_raw_t rc_channels_raw;
          mavlink_msg_rc_channels_raw_decode(&msg, &rc_channels_raw);
            Serial.println("CHANNEL RAW");
        }
          break;
        
       default:
          break;
      }
    }
  }

Where ardupilotPort is the UART the Pixhawk is connected to.
The only thing I am getting now is a msg.msgid == 66 which is a MAVLINK_MSG_ID_REQUEST_DATA_STREAM message.

How do I get the raw RC channels data?
Thanks.

Sounds like you are reading back your own message, could it be that the TX and RX lines are somewhere bridged? Do you receive any periodic heartbeat messages? If not then maybe you are not really connected to the autopilot.

@copilot If I set the request data stream pack to MAV_DATA_STREAM_ALL, all I get back is the HEARTBEAT & 66 (REQUEST_DATA_STREAM) messages. It is like an echo, I have doubled checked the wiring. TX of telem 2 is going to pin IO33 of the ESP32 and the configuration of SoftwareSerial is correct.

@amilcarlucas @peterbarker Could either of you advise on this Rover/Mavlink question? This uses request data stream which I expect is still supported? MAV_CMD_SET_MESSAGE_INTERVAL might work too.

@CarbonMan Some things to try:

  • What are you getting in the heartbeat?
  • Can you connect a GCS to the same port and connect?

@hamishwillee I am pretty sure I have found it

Turns out the library I am using coming from this topic…
MAVLink and Arduino
only understands the mavlink 1 protocol

Of course I was using Mavlink 2 :frowning:

1 Like

That would be it. Use MAVLink 2.

Well turns out I can’t use #2, because that library only supports MAVLink 1, so for now, ver. 1 it is.

But I am a happy camper, unless it is going to interfere with my ability to send messages to the GCS. That’s the next thing to investigate.