* New translations common.md (Korean) * New translations common.md (Chinese Simplified) * New translations common.md (Korean) * New translations common.md (Chinese Simplified) * New translations standard.md (Korean) * New translations standard.md (Chinese Simplified) * New translations development.md (Korean) * New translations all.md (Korean) * New translations development.md (Chinese Simplified) * New translations all.md (Chinese Simplified) * New translations dialects.md (Korean) * New translations dialects.md (Chinese Simplified) * New translations common.md (Korean) * New translations common.md (Chinese Simplified) * New translations development.md (Korean) * New translations all.md (Korean) * New translations development.md (Chinese Simplified) * New translations all.md (Chinese Simplified) * New translations common.md (Korean) * New translations common.md (Chinese Simplified) * New translations minimal.md (Korean) * New translations minimal.md (Chinese Simplified) * New translations common.md (Korean) * New translations common.md (Chinese Simplified) * New translations development.md (Korean) * New translations all.md (Korean) * New translations development.md (Chinese Simplified) * New translations all.md (Chinese Simplified) * New translations uavionix.md (Korean) * New translations uavionix.md (Chinese Simplified) * New translations cubepilot.md (Korean) * New translations cubepilot.md (Chinese Simplified) * New translations storm32.md (Korean) * New translations storm32.md (Chinese Simplified) * New translations ardupilotmega.md (Korean) * New translations avssuas.md (Korean) * New translations ardupilotmega.md (Chinese Simplified) * New translations avssuas.md (Chinese Simplified) * New translations matrixpilot.md (Korean) * New translations paparazzi.md (Korean) * New translations python_array_test.md (Korean) * New translations ualberta.md (Korean) * New translations asluav.md (Korean) * New translations marsh.md (Korean) * New translations matrixpilot.md (Chinese Simplified) * New translations paparazzi.md (Chinese Simplified) * New translations python_array_test.md (Chinese Simplified) * New translations ualberta.md (Chinese Simplified) * New translations asluav.md (Chinese Simplified) * New translations marsh.md (Chinese Simplified) * New translations common.md (Korean) * New translations common.md (Chinese Simplified) * New translations example_c_udp.md (Korean) * New translations example_c_udp.md (Chinese Simplified) * New translations installation.md (Korean) * New translations installation.md (Chinese Simplified) * New translations manual_control.md (Korean) * New translations manual_control.md (Chinese Simplified) * New translations development.md (Korean) * New translations all.md (Korean) * New translations development.md (Chinese Simplified) * New translations all.md (Chinese Simplified)
2.0 KiB
MAVLink C UDP Example
The MAVLink UDP Example is a simple C example that sends and receives MAVLink HEARTBEATS over UDP.
:::info The example should work on any Unix-like system (Linux, MacOS, BSD, etc.). These instructions were tested on a Ubuntu LTS 22.04 installation with either PX4 or ArduPilot dependencies installed (such as cmake). :::
Building/Running the Example
The following instructions show how to build and run the example.
-
Clone the mavlink/mavlink repository
-
Open a terminal in the repository root.
-
Use
cmaketo install MAVLink locally:cmake -Bbuild -H. -DCMAKE_INSTALL_PREFIX=install cmake --build build --target install -
Navigate to examples/c
cd examples/c -
Use
cmaketo compile and build the example:cmake -Bbuild -H. -DCMAKE_PREFIX_PATH=$(pwd)/../../install cmake --build build -
Run the executable from the terminal:
./build/udp_exampleBy default, the example will listen for data on the localhost IP address, port 14550.
-
Open another terminal on the same machine and start either PX4 or ArduPilot. These publish to port 14550 on localhost by default.
-
The example should start displaying messages about sent and received HEARTBEAT messages in the terminal. The following output is displayed if you connect to PX4:
~/github/mavlink/mavlink/examples/c$ ./build/udp_example Sent heartbeat Got heartbeat from PX4 autopilot Sent heartbeat Got heartbeat from PX4 autopilot Sent heartbeat Got heartbeat from PX4 autopilot Sent heartbeat Got heartbeat from PX4 autopilot Sent heartbeat Got heartbeat from PX4 autopilot ...
Note that the build and installation instructions are from examples/c/README.md.