NEW: release DJI Payload-SDK version 3.1
Signed-off-by: DJI-Martin <DJI-Martin@dji.com>
This commit is contained in:
@ -26,11 +26,13 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage -lgcov")
|
||||
|
||||
include_directories(../../../module_sample)
|
||||
include_directories(../../../../sample_c/module_sample)
|
||||
include_directories(../common)
|
||||
|
||||
file(GLOB_RECURSE MODULE_SAMPLE_SRC
|
||||
../../../module_sample/liveview/*.c*
|
||||
../../../module_sample/perception/*.c*
|
||||
../../../../sample_c/module_sample/*.c
|
||||
)
|
||||
file(GLOB_RECURSE MODULE_COMMON_SRC ../common/*.c*)
|
||||
file(GLOB_RECURSE MODULE_HAL_SRC hal/*.c*)
|
||||
|
@ -32,8 +32,9 @@
|
||||
|
||||
#include "../common/osal/osal.h"
|
||||
#include "../common/osal/osal_fs.h"
|
||||
#include "../manifold2//hal/hal_usb_bulk.h"
|
||||
#include "../manifold2//hal/hal_uart.h"
|
||||
#include "../common/osal/osal_socket.h"
|
||||
#include "../manifold2/hal/hal_usb_bulk.h"
|
||||
#include "../manifold2/hal/hal_uart.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define DJI_LOG_PATH "Logs/DJI"
|
||||
@ -41,7 +42,7 @@
|
||||
#define DJI_LOG_FOLDER_NAME "Logs"
|
||||
#define DJI_LOG_PATH_MAX_SIZE (128)
|
||||
#define DJI_LOG_FOLDER_NAME_MAX_SIZE (32)
|
||||
#define DJI_SYSTEM_CMD_STR_MAX_SIZE (64)
|
||||
#define DJI_LOG_SYSTEM_CMD_MAX_SIZE (64)
|
||||
#define DJI_LOG_MAX_COUNT (10)
|
||||
|
||||
#define USER_UTIL_UNUSED(x) ((x) = (x))
|
||||
@ -62,7 +63,7 @@ Application::Application(int argc, char **argv)
|
||||
Application::DjiUser_SetupEnvironment();
|
||||
Application::DjiUser_ApplicationStart();
|
||||
|
||||
Osal_TaskSleepMs(1000);
|
||||
Osal_TaskSleepMs(3000);
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
@ -78,6 +79,18 @@ void Application::DjiUser_SetupEnvironment()
|
||||
T_DjiLoggerConsole printConsole;
|
||||
T_DjiLoggerConsole localRecordConsole;
|
||||
T_DjiFileSystemHandler fileSystemHandler;
|
||||
T_DjiSocketHandler socketHandler;
|
||||
|
||||
socketHandler.Socket = Osal_Socket;
|
||||
socketHandler.Bind = Osal_Bind;
|
||||
socketHandler.Close = Osal_Close;
|
||||
socketHandler.UdpSendData = Osal_UdpSendData;
|
||||
socketHandler.UdpRecvData = Osal_UdpRecvData;
|
||||
socketHandler.TcpListen = Osal_TcpListen;
|
||||
socketHandler.TcpAccept = Osal_TcpAccept;
|
||||
socketHandler.TcpConnect = Osal_TcpConnect;
|
||||
socketHandler.TcpSendData = Osal_TcpSendData;
|
||||
socketHandler.TcpRecvData = Osal_TcpRecvData;
|
||||
|
||||
osalHandler.TaskCreate = Osal_TaskCreate;
|
||||
osalHandler.TaskDestroy = Osal_TaskDestroy;
|
||||
@ -145,6 +158,11 @@ void Application::DjiUser_SetupEnvironment()
|
||||
throw std::runtime_error("Register hal usb bulk handler error.");
|
||||
}
|
||||
|
||||
returnCode = DjiPlatform_RegSocketHandler(&socketHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
throw std::runtime_error("register osal socket handler error");
|
||||
}
|
||||
|
||||
returnCode = DjiPlatform_RegFileSystemHandler(&fileSystemHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
throw std::runtime_error("Register osal filesystem handler error.");
|
||||
@ -272,7 +290,7 @@ T_DjiReturnCode Application::DjiUser_LocalWriteFsInit(const char *path)
|
||||
{
|
||||
T_DjiReturnCode djiReturnCode = DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
char filePath[DJI_LOG_PATH_MAX_SIZE];
|
||||
char systemCmd[DJI_SYSTEM_CMD_STR_MAX_SIZE];
|
||||
char systemCmd[DJI_LOG_SYSTEM_CMD_MAX_SIZE];
|
||||
char folderName[DJI_LOG_FOLDER_NAME_MAX_SIZE];
|
||||
time_t currentTime = time(nullptr);
|
||||
struct tm *localTime = localtime(¤tTime);
|
||||
|
@ -25,7 +25,22 @@
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <liveview/test_liveview_entry.hpp>
|
||||
#include <perception/test_perception_entry.hpp>
|
||||
#include <flight_control/test_flight_control.h>
|
||||
#include <hms/test_hms.h>
|
||||
#include <waypoint_v2/test_waypoint_v2.h>
|
||||
#include <waypoint_v3/test_waypoint_v3.h>
|
||||
#include <gimbal_manager/test_gimbal_manager.h>
|
||||
#include "application.hpp"
|
||||
#include "fc_subscription/test_fc_subscription.h"
|
||||
#include <gimbal_emu/test_payload_gimbal_emu.h>
|
||||
#include <camera_emu/test_payload_cam_emu_media.h>
|
||||
#include <camera_emu/test_payload_cam_emu_base.h>
|
||||
#include <dji_logger.h>
|
||||
#include "widget/test_widget.h"
|
||||
#include "widget/test_widget_speaker.h"
|
||||
#include <power_management/test_power_management.h>
|
||||
#include "data_transmission/test_data_transmission.h"
|
||||
#include <camera_manager/test_camera_manager.h>
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
@ -34,35 +49,182 @@
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_DjiReturnCode DjiTest_HighPowerApplyPinInit();
|
||||
static T_DjiReturnCode DjiTest_WriteHighPowerApplyPin(E_DjiPowerManagementPinState pinState);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Application application(argc, argv);
|
||||
char inputChar;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiTestApplyHighPowerHandler applyHighPowerHandler;
|
||||
|
||||
start:
|
||||
std::cout
|
||||
<< "\n"
|
||||
<< "| Available commands: |\n"
|
||||
<< "| [0] Camera stream view sample |\n"
|
||||
<< "| [1] Stereo vision view sample |\n"
|
||||
<< "| Available commands: |\n"
|
||||
<< "| [0] Fc subscribe sample - subscribe quaternion and gps data |\n"
|
||||
<< "| [1] Flight controller sample - take off landing |\n"
|
||||
<< "| [2] Flight controller sample - take off position ctrl landing |\n"
|
||||
<< "| [3] Flight controller sample - take off go home force landing |\n"
|
||||
<< "| [4] Flight controller sample - take off velocity ctrl landing |\n"
|
||||
<< "| [5] Flight controller sample - arrest flying |\n"
|
||||
<< "| [6] Flight controller sample - set get parameters |\n"
|
||||
<< "| [7] Hms info sample - get health manger system info |\n"
|
||||
<< "| [8] Waypoint 2.0 sample - run airline mission by settings (only support on M300 RTK) |\n"
|
||||
<< "| [9] Waypoint 3.0 sample - run airline mission by kmz file (only support on M30/30T) |\n"
|
||||
<< "| [a] Gimbal manager sample - rotate gimbal on free mode |\n"
|
||||
<< "| [b] Gimbal manager sample - rotate gimbal on yaw follow mode |\n"
|
||||
<< "| [c] Camera stream view sample - display the camera video stream |\n"
|
||||
<< "| [d] Stereo vision view sample - display the stereo image (only support on M300 RTK) |\n"
|
||||
<< "| [e] Start camera all feautes sample - you can operate the camera on DJI Pilot |\n"
|
||||
<< "| [f] Start gimbal all feautes sample - you can operate the gimbal on DJI Pilot |\n"
|
||||
<< "| [g] Start widget all feautes sample - you can operate the widget on DJI Pilot |\n"
|
||||
<< "| [h] Start widget speaker sample - you can operate the speaker on MSDK demo |\n"
|
||||
<< "| [i] Start power management sample - you will see notification when aircraft power off |\n"
|
||||
<< "| [j] Start data transmission sample - you can send or recv custom data on MSDK demo |\n"
|
||||
<< "| [l] Run camera manager sample - shoot photo by the selected camera mounted position |\n"
|
||||
<< std::endl;
|
||||
|
||||
std::cin >> inputChar;
|
||||
switch (inputChar) {
|
||||
case '0':
|
||||
DjiUser_RunCameraStreamViewSample();
|
||||
DjiTest_FcSubscriptionRunSample();
|
||||
break;
|
||||
case '1':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_LANDING);
|
||||
break;
|
||||
case '2':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_POSITION_CTRL_LANDING);
|
||||
break;
|
||||
case '3':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_GO_HOME_FORCE_LANDING);
|
||||
break;
|
||||
case '4':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_VELOCITY_CTRL_LANDING);
|
||||
break;
|
||||
case '5':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_ARREST_FLYING);
|
||||
break;
|
||||
case '6':
|
||||
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_SET_GET_PARAM);
|
||||
break;
|
||||
case '7':
|
||||
DjiTest_HmsRunSample();
|
||||
break;
|
||||
case '8':
|
||||
DjiTest_WaypointV2RunSample();
|
||||
break;
|
||||
case '9':
|
||||
DjiTest_WaypointV3RunSample();
|
||||
break;
|
||||
case 'a':
|
||||
DjiTest_GimbalManagerRunSample(DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1, DJI_GIMBAL_MODE_FREE);
|
||||
break;
|
||||
case 'b':
|
||||
DjiTest_GimbalManagerRunSample(DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1, DJI_GIMBAL_MODE_YAW_FOLLOW);
|
||||
break;
|
||||
case 'c':
|
||||
DjiUser_RunCameraStreamViewSample();
|
||||
break;
|
||||
case 'd':
|
||||
DjiUser_RunStereoVisionViewSample();
|
||||
break;
|
||||
case 'e':
|
||||
returnCode = DjiTest_CameraEmuBaseStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("camera emu common init error");
|
||||
break;
|
||||
}
|
||||
|
||||
if (DjiPlatform_GetSocketHandler() != NULL) {
|
||||
returnCode = DjiTest_CameraEmuMediaStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("camera emu media init error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start camera all feautes sample successfully");
|
||||
break;
|
||||
case 'f':
|
||||
if (DjiTest_GimbalStartService() != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("psdk gimbal init error");
|
||||
break;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start gimbal all feautes sample successfully");
|
||||
break;
|
||||
case 'g':
|
||||
returnCode = DjiTest_WidgetStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget sample init error");
|
||||
break;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start widget all feautes sample successfully");
|
||||
break;
|
||||
case 'h':
|
||||
returnCode = DjiTest_WidgetSpeakerStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("widget speaker test init error");
|
||||
break;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start widget speaker sample successfully");
|
||||
break;
|
||||
case 'i':
|
||||
applyHighPowerHandler.pinInit = DjiTest_HighPowerApplyPinInit;
|
||||
applyHighPowerHandler.pinWrite = DjiTest_WriteHighPowerApplyPin;
|
||||
|
||||
returnCode = DjiTest_RegApplyHighPowerHandler(&applyHighPowerHandler);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("regsiter apply high power handler error");
|
||||
break;
|
||||
}
|
||||
|
||||
returnCode = DjiTest_PowerManagementStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("power management init error");
|
||||
break;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start power management sample successfully");
|
||||
break;
|
||||
case 'j':
|
||||
returnCode = DjiTest_DataTransmissionStartService();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("data transmission sample init error");
|
||||
break;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Start data transmission sample successfully");
|
||||
break;
|
||||
case 'l':
|
||||
DjiTest_CameraManagerRunSample(DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_SINGLE_PHOTO);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
|
||||
goto start;
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static T_DjiReturnCode DjiTest_HighPowerApplyPinInit()
|
||||
{
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_WriteHighPowerApplyPin(E_DjiPowerManagementPinState pinState)
|
||||
{
|
||||
//attention: please pull up the HWPR pin state by hardware.
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define UART_DEV_NAME_STR_SIZE (128)
|
||||
#define DJI_SYSTEM_CMD_STR_MAX_SIZE (64)
|
||||
#define DJI_SYSTEM_CMD_MAX_SIZE (64)
|
||||
#define DJI_SYSTEM_RESULT_STR_MAX_SIZE (128)
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
@ -48,7 +48,7 @@ T_DjiReturnCode HalUart_Init(E_DjiHalUartNum uartNum, uint32_t baudRate, T_DjiUa
|
||||
struct flock lock;
|
||||
T_DjiReturnCode returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
char uartName[UART_DEV_NAME_STR_SIZE];
|
||||
char systemCmd[DJI_SYSTEM_CMD_STR_MAX_SIZE];
|
||||
char systemCmd[DJI_SYSTEM_CMD_MAX_SIZE];
|
||||
char *ret = NULL;
|
||||
char lineBuf[DJI_SYSTEM_RESULT_STR_MAX_SIZE] = {0};
|
||||
FILE *fp;
|
||||
|
Reference in New Issue
Block a user