Skip to main content

Running Example Programs

After obtaining a developer account, download the example code provided by PSDK and add application information to it. By compiling, debugging, and flashing, you can obtain the example program. Once ported to the target development board, you can run the example program.

Tip:

  • If you need to run the RTOS or Linux example code on other development boards or operating systems, please refer to Cross-Platform Porting.

Getting Example Code

You can directly download the PSDK development package through the developer website's download link. In the PSDK development package, you can find related example code, which helps you understand how to develop payload devices using PSDK and quickly develop fully functional payload devices.

Creating Payload Applications

Please refer to the Registering PSDK Developer Account section, fill in the necessary information, and apply for a developer account. After the review is completed, we will notify you of the generated account information via email.

Note:

  • To improve your development efficiency, make sure to fill in the application's name, ID, Key, and developer account correctly in the example code. Otherwise, the compiled example program will not run properly.

Running RTOS Example Code

Note:

  • This document takes the HC32F460 chip development board as an example to introduce the steps and methods for running RTOS example code.

Flash Bootloader

Flash the release version using the file ModelX.MODEXTHROWV2-boot_V1.0.0.0_app_Vx.x.x.x.bin located in the samples\sample_c\platform\rtos_freertos\hc32f460\04_tools\release directory.

Related references:

  • Implementing Bootloader: samples\sample_c\platform\rtos_freertos\hc32f460\03_boot\
  • Bootloader project directory: samples\sample_c\platform\rtos_freertos\hc32f460\03_boot\projects
  • Bootloader compile script: samples\sample_c\platform\rtos_freertos\hc32f460\04_tools\all_make.bat

Add Application Information

  • Use Keil IDE to open the project file app.uvprojx located in the samples\sample_c\platform\rtos_freertos\hc32f460\02_app\projects directory.
  • Replace the application's name, ID, Key, License, developer account, and specified baud rate in the samples\module_sample\uav_sdk_app_info.c file.
#define USER_APP_NAME           "your_app_name"
#define USER_APP_ID "your_app_id"
#define USER_APP_KEY "your_app_key"
#define USER_APP_LICENSE "your_app_license"
#define USER_DEVELOPER_ACCOUNT "your_app_account"
#define USER_BAUDRATE_RATE "460800"

Compile and Flash

  • Use Keil MDK IDE to compile the example code into the example program.
  • After compiling the example code, flash the compiled program into the payload device.
  • To debug the example program, set the baud rate of the serial debugging tool to: 115200.
  • If you need to upgrade the program using the upgrade interface in the example program, you will need to use the Bootloader build script to generate a .bin file and flash it. For functional debugging, you can directly use Keil MDK IDE for flashing and debugging.

Running Linux Example Code

Note:

  • This document takes the Raspberry Pi 4B as an example to introduce the steps and methods for running the Linux example code.

Add Application Information

  • Replace the application's name, ID, Key, License, developer account, and specified baud rate in the example/uav_sdk_app_info.h file.
#define USER_APP_NAME           "your_app_name"
#define USER_APP_ID "your_app_id"
#define USER_APP_KEY "your_app_key"
#define USER_APP_LICENSE "your_app_license"
#define USER_DEVELOPER_ACCOUNT "your_app_account"
#define USER_BAUDRATE_RATE "460800"
  • Modify the serial communication information in the main function of example/timesync.cxx example code.
UAV_Uart_Init("/dev/pts/20",115200);
  • Use the ifconfig command to view the current network interface name communicating with the aircraft, and fill it into the LOCALHOST_ETHERNET_TEST macro in the include/uav_platform.h file. Note that the actual development should follow the parameters passed in the UAV_Network_Init function.
#define LOCALHOST_ETHERNET std::string("your_network_name")

Execute the Example Program

  • After configuring the runtime environment, execute the time synchronization example.
export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH
./example/timesync ./config/logger.yaml