MAVLink UDP C example

57 views
Skip to first unread message

Ryan Edmonds

unread,
Aug 8, 2025, 10:37:41 AMAug 8
to MAVLink
Hello all, I have a question about the MAVLink UDP C Example. I have been following the instructions from the official mavlink documentation. There seems to be some sort of conflict over udp ports between the mavlink_udp executable and the QGroundControl. When I launch the mavlink_udp first and then QGroundControl I get this error:

Screenshot 2025-08-08 103427.png

When I try the opposite launch order I get this error from the mavlink_udp example:
Screenshot 2025-08-08 103626.png

Any help or suggestion would be greatly appreciated! Thanks so much!

Ryan Edmonds

unread,
Aug 11, 2025, 10:53:07 AMAug 11
to MAVLink
Update: I configured the UDP connection in QGroundControl and I think they are atleast communicating now.

In the mavlink help docs it says the following for step 6.)
Screenshot 2025-08-11 104950.png

Inspecting the example C code, this does not exist in the C code. It only prints:

void handle_heartbeat(const mavlink_message_t* message)
{
    mavlink_heartbeat_t heartbeat;
    mavlink_msg_heartbeat_decode(message, &heartbeat);

    printf("Got heartbeat from ");
    switch (heartbeat.autopilot) {
        case MAV_AUTOPILOT_GENERIC:
            printf("generic");
            break;
        case MAV_AUTOPILOT_ARDUPILOTMEGA:
            printf("ArduPilot");
            break;
        case MAV_AUTOPILOT_PX4:
            printf("PX4");
            break;
        default:
            printf("other");
            break;
    }
    printf(" autopilot\n");
}

from the terminal where the c example is running, I only see this:
Screenshot 2025-08-11 105241.png

Am I missing something, or is this a newer example than what is in the help docs?

Hamish Willee

unread,
Aug 12, 2025, 9:55:13 PMAug 12
to MAVLink
The example doesn't even build for me. I've made some modifications but I don't know if they are OK

The fact that you got a heartbeat is a good sign. I did not know the reason for the errors, but have created an issue for tracking:   https://github.com/mavlink/mavlink/issues/2332

Hamish Willee

unread,
Aug 14, 2025, 3:52:36 AMAug 14
to MAVLink
OK, the example is fixed up, and so is the documentation - you can see how to run it now in https://github.com/mavlink/mavlink-devguide/pull/623 - that should go live soon.

This now builds properly via cmake, which is a bit easier. 
The connection works. I was having problems because I was trying to connect to QGC. This connects to an autopilot - if you connect to QGC you end up being in conflict for the port, because both QGC and the example bind to the port to listen to it.
Reply all
Reply to author
Forward
0 new messages