M350b版本

This commit is contained in:
xin
2026-01-08 16:00:08 +08:00
parent 7396728ea7
commit a76d4b77e9
213 changed files with 8883 additions and 7196579 deletions

View File

@ -33,6 +33,8 @@
#include "dji_gimbal.h"
#include "dji_xport.h"
#include "gimbal_emu/test_payload_gimbal_emu.h"
#include <widget_interaction_test/test_widget_interaction.h>
#include "test_raspberry_pi_camera.h"
/* Private constants ---------------------------------------------------------*/
#define PAYLOAD_CAMERA_EMU_TASK_FREQ (100)
@ -40,8 +42,8 @@
#define SDCARD_TOTAL_SPACE_IN_MB (32 * 1024)
#define SDCARD_PER_PHOTO_SPACE_IN_MB (4)
#define SDCARD_PER_SECONDS_RECORD_SPACE_IN_MB (2)
#define ZOOM_OPTICAL_FOCAL_MAX_LENGTH (300)
#define ZOOM_OPTICAL_FOCAL_MIN_LENGTH (10)
#define ZOOM_OPTICAL_FOCAL_MAX_LENGTH (200*240)
#define ZOOM_OPTICAL_FOCAL_MIN_LENGTH (1.2*240)
#define ZOOM_OPTICAL_FOCAL_LENGTH_STEP (10)
#define ZOOM_OPTICAL_FOCAL_LENGTH_CTRL_STEP (5)
#define ZOOM_DIGITAL_BASE_FACTOR (1.0)
@ -118,6 +120,7 @@ static T_TestCameraGimbalRotationArgument s_tapZoomNewestGimbalRotationArgument
static uint32_t s_tapZoomNewestTargetHybridFocalLength = 0; // unit: 0.1mm
static T_DjiMutexHandle s_tapZoomMutex = NULL;
static E_DjiCameraVideoStreamType s_cameraVideoStreamType;
static uint32_t s_currentVideoRecordTimeInSeconds = 0;
/* Private functions declaration ---------------------------------------------*/
static T_DjiReturnCode GetSystemState(T_DjiCameraSystemState *systemState);
@ -205,6 +208,7 @@ static T_DjiReturnCode SetMode(E_DjiCameraMode mode)
s_cameraState.cameraMode = mode;
USER_LOG_INFO("set camera mode:%d", mode);
DjiTest_WidgetLogAppend("set cam mode %d", mode);
returnCode = osalHandler->MutexUnlock(s_commonMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -235,6 +239,11 @@ static T_DjiReturnCode StartRecordVideo(void)
s_cameraState.isRecording = true;
USER_LOG_INFO("start record video");
DjiTest_WidgetLogAppend("start record video");
#if USE_RASPBERRY_PI_CAMERA
DjiTest_RaspberryPiRecordingAction(true);
#endif
out:
djiStat = osalHandler->MutexUnlock(s_commonMutex);
@ -267,6 +276,11 @@ static T_DjiReturnCode StopRecordVideo(void)
s_cameraState.isRecording = false;
s_cameraState.currentVideoRecordingTimeInSeconds = 0;
USER_LOG_INFO("stop record video");
DjiTest_WidgetLogAppend("stop record video");
#if USE_RASPBERRY_PI_CAMERA
DjiTest_RaspberryPiRecordingAction(false);
#endif
out:
djiStat = osalHandler->MutexUnlock(s_commonMutex);
@ -290,6 +304,7 @@ static T_DjiReturnCode StartShootPhoto(void)
}
USER_LOG_INFO("start shoot photo");
DjiTest_WidgetLogAppend("start shoot photo");
s_cameraState.isStoring = true;
if (s_cameraShootPhotoMode == DJI_CAMERA_SHOOT_PHOTO_MODE_SINGLE) {
@ -300,6 +315,7 @@ static T_DjiReturnCode StartShootPhoto(void)
s_cameraState.shootingState = DJI_CAMERA_SHOOTING_INTERVAL_PHOTO;
s_cameraState.isShootingIntervalStart = true;
s_cameraState.currentPhotoShootingIntervalTimeInSeconds = s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds;
s_cameraState.currentPhotoShootingIntervalTimeInMs = s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds;
}
returnCode = osalHandler->MutexUnlock(s_commonMutex);
@ -308,6 +324,16 @@ static T_DjiReturnCode StartShootPhoto(void)
return returnCode;
}
#if USE_RASPBERRY_PI_CAMERA
if(s_cameraShootPhotoMode == DJI_CAMERA_SHOOT_PHOTO_MODE_SINGLE) {
DjiTest_RaspberryPiCameraTakePhoto();
} else if(s_cameraShootPhotoMode == DJI_CAMERA_SHOOT_PHOTO_MODE_BURST) {
for(uint8_t i = 0; i < s_cameraBurstCount; i++) {
DjiTest_RaspberryPiCameraTakePhoto();
}
}
#endif
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
@ -323,6 +349,7 @@ static T_DjiReturnCode StopShootPhoto(void)
}
USER_LOG_INFO("stop shoot photo");
DjiTest_WidgetLogAppend("stop shoot photo");
s_cameraState.shootingState = DJI_CAMERA_SHOOTING_PHOTO_IDLE;
s_cameraState.isStoring = false;
s_cameraState.isShootingIntervalStart = false;
@ -349,6 +376,7 @@ static T_DjiReturnCode SetShootPhotoMode(E_DjiCameraShootPhotoMode mode)
s_cameraShootPhotoMode = mode;
USER_LOG_INFO("set shoot photo mode:%d", mode);
DjiTest_WidgetLogAppend("set shoot photo mode:%d", mode);
returnCode = osalHandler->MutexUnlock(s_commonMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -394,6 +422,7 @@ static T_DjiReturnCode SetPhotoBurstCount(E_DjiCameraBurstCount burstCount)
s_cameraBurstCount = burstCount;
USER_LOG_INFO("set photo burst count:%d", burstCount);
DjiTest_WidgetLogAppend("set photo burst count:%d", burstCount);
returnCode = osalHandler->MutexUnlock(s_commonMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -439,8 +468,12 @@ static T_DjiReturnCode SetPhotoTimeIntervalSettings(T_DjiCameraPhotoTimeInterval
s_cameraPhotoTimeIntervalSettings.captureCount = settings.captureCount;
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds = settings.timeIntervalSeconds;
USER_LOG_INFO("set photo interval settings count:%d seconds:%d", settings.captureCount,
settings.timeIntervalSeconds);
s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds = settings.timeIntervalMilliseconds;
USER_LOG_INFO("set photo interval settings count:%d seconds:%d.%d", settings.captureCount,
settings.timeIntervalSeconds, settings.timeIntervalMilliseconds / 100);
DjiTest_WidgetLogAppend("set photo interval: %d - %d.%d", settings.captureCount,
settings.timeIntervalSeconds, settings.timeIntervalMilliseconds / 100);
s_cameraState.currentPhotoShootingIntervalCount = settings.captureCount;
returnCode = osalHandler->MutexUnlock(s_commonMutex);
@ -508,6 +541,7 @@ static T_DjiReturnCode FormatSDCard(void)
}
USER_LOG_INFO("format sdcard");
DjiTest_WidgetLogAppend("format sdcard");
memset(&s_cameraSDCardState, 0, sizeof(T_DjiCameraSDCardState));
s_cameraSDCardState.isInserted = true;
@ -530,6 +564,7 @@ static T_DjiReturnCode FormatSDCard(void)
static T_DjiReturnCode SetMeteringMode(E_DjiCameraMeteringMode mode)
{
USER_LOG_INFO("set metering mode:%d", mode);
DjiTest_WidgetLogAppend("set metering mode:%d", mode);
s_cameraMeteringMode = mode;
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -545,6 +580,7 @@ static T_DjiReturnCode GetMeteringMode(E_DjiCameraMeteringMode *mode)
static T_DjiReturnCode SetSpotMeteringTarget(T_DjiCameraSpotMeteringTarget target)
{
USER_LOG_INFO("set spot metering area col:%d row:%d", target.col, target.row);
DjiTest_WidgetLogAppend("set spot metering area col:%d row:%d", target.col, target.row);
memcpy(&s_cameraSpotMeteringTarget, &target, sizeof(T_DjiCameraSpotMeteringTarget));
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -560,6 +596,7 @@ static T_DjiReturnCode GetSpotMeteringTarget(T_DjiCameraSpotMeteringTarget *targ
static T_DjiReturnCode SetFocusMode(E_DjiCameraFocusMode mode)
{
USER_LOG_INFO("set focus mode:%d", mode);
DjiTest_WidgetLogAppend("set focus mode:%d", mode);
s_cameraFocusMode = mode;
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -575,6 +612,7 @@ static T_DjiReturnCode GetFocusMode(E_DjiCameraFocusMode *mode)
static T_DjiReturnCode SetFocusTarget(T_DjiCameraPointInScreen target)
{
USER_LOG_INFO("set focus target x:%.2f y:%.2f", target.focusX, target.focusY);
DjiTest_WidgetLogAppend("set focus target x:%.2f y:%.2f", target.focusX, target.focusY);
memcpy(&s_cameraFocusTarget, &target, sizeof(T_DjiCameraPointInScreen));
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -590,6 +628,7 @@ static T_DjiReturnCode GetFocusTarget(T_DjiCameraPointInScreen *target)
static T_DjiReturnCode SetFocusAssistantSettings(T_DjiCameraFocusAssistantSettings settings)
{
USER_LOG_INFO("set focus assistant setting MF:%d AF:%d", settings.isEnabledMF, settings.isEnabledAF);
DjiTest_WidgetLogAppend("set focus assistant setting MF:%d AF:%d", settings.isEnabledMF, settings.isEnabledAF);
memcpy(&s_cameraFocusAssistantSettings, &settings, sizeof(T_DjiCameraFocusAssistantSettings));
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -605,6 +644,7 @@ static T_DjiReturnCode GetFocusAssistantSettings(T_DjiCameraFocusAssistantSettin
static T_DjiReturnCode SetFocusRingValue(uint32_t value)
{
USER_LOG_INFO("set focus ring value:%d", value);
DjiTest_WidgetLogAppend("set focus ring value:%d", value);
s_cameraFocusRingValue = value;
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -636,6 +676,7 @@ static T_DjiReturnCode SetDigitalZoomFactor(dji_f32_t factor)
}
USER_LOG_INFO("set digital zoom factor:%.2f", factor);
DjiTest_WidgetLogAppend("set digital zoom factor:%.2f", factor);
s_cameraDigitalZoomFactor = factor;
returnCode = osalHandler->MutexUnlock(s_zoomMutex);
@ -659,9 +700,10 @@ static T_DjiReturnCode SetOpticalZoomFocalLength(uint32_t focalLength)
}
USER_LOG_INFO("set optical zoom focal length:%d", focalLength);
DjiTest_WidgetLogAppend("set optical zoom focal length:%d", focalLength);
s_isOpticalZoomReachLimit = false;
s_cameraDigitalZoomFactor = ZOOM_DIGITAL_BASE_FACTOR;
s_cameraOpticalZoomFocalLength = ZOOM_OPTICAL_FOCAL_MIN_LENGTH;
s_cameraOpticalZoomFocalLength = focalLength;
returnCode = osalHandler->MutexUnlock(s_zoomMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -714,7 +756,8 @@ static T_DjiReturnCode StartContinuousOpticalZoom(E_DjiCameraZoomDirection direc
return returnCode;
}
USER_LOG_INFO("start continuous optical zoom direction:%d speed:%d", direction, speed);
DjiTest_WidgetLogAppend("continuous optical zoom dir:%d speed:%d", direction, speed);
USER_LOG_INFO("continuous optical zoom direction:%d speed:%d", direction, speed);
s_isStartContinuousOpticalZoom = true;
s_cameraZoomDirection = direction;
s_cameraZoomSpeed = speed;
@ -740,6 +783,7 @@ static T_DjiReturnCode StopContinuousOpticalZoom(void)
}
USER_LOG_INFO("stop continuous optical zoom");
DjiTest_WidgetLogAppend("stop continuous optical zoom");
s_isStartContinuousOpticalZoom = false;
s_cameraZoomDirection = DJI_CAMERA_ZOOM_DIRECTION_OUT;
s_cameraZoomSpeed = DJI_CAMERA_ZOOM_SPEED_NORMAL;
@ -777,6 +821,7 @@ static T_DjiReturnCode GetTapZoomState(T_DjiCameraTapZoomState *state)
static T_DjiReturnCode SetTapZoomEnabled(bool enabledFlag)
{
DjiTest_WidgetLogAppend("set tap zoom enabled flag: %d.", enabledFlag);
USER_LOG_INFO("set tap zoom enabled flag: %d.", enabledFlag);
s_isTapZoomEnabled = enabledFlag;
@ -793,6 +838,7 @@ static T_DjiReturnCode GetTapZoomEnabled(bool *enabledFlag)
static T_DjiReturnCode SetTapZoomMultiplier(uint8_t multiplier)
{
USER_LOG_INFO("set tap zoom multiplier: %d.", multiplier);
DjiTest_WidgetLogAppend("set tap zoom multiplier: %d.", multiplier);
s_tapZoomMultiplier = multiplier;
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -815,6 +861,7 @@ static T_DjiReturnCode TapZoomAtTarget(T_DjiCameraPointInScreen target)
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
USER_LOG_INFO("tap zoom at target: x %f, y %f.", target.focusX, target.focusY);
DjiTest_WidgetLogAppend("tap zoom at target: x %f, y %f.", target.focusX, target.focusY);
if (s_isTapZoomEnabled != true) {
USER_LOG_WARN("tap zoom is not enabled.");
@ -908,6 +955,8 @@ static T_DjiReturnCode DjiTest_CameraRotationGimbal(T_TestCameraGimbalRotationAr
}
if (aircraftBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 ||
aircraftBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V3 ||
aircraftBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_EPORT_V2_RIBBON_CABLE ||
aircraftBaseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_NONE) {
returnCode = DjiTest_GimbalRotate(gimbalRotationArgument.rotationMode, gimbalRotationArgument.rotationProperty,
gimbalRotationArgument.rotationValue);
@ -946,6 +995,7 @@ static void *UserCamera_Task(void *arg)
uint32_t currentTime = 0;
bool isStartIntervalPhotoAction = false;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
uint32_t intervalFreq = 10;
USER_UTIL_UNUSED(arg);
@ -1138,8 +1188,7 @@ out:
}
}
// 1Hz
if (USER_UTIL_IS_WORK_TURN(step, 1, PAYLOAD_CAMERA_EMU_TASK_FREQ)) {
if (USER_UTIL_IS_WORK_TURN(step, intervalFreq, PAYLOAD_CAMERA_EMU_TASK_FREQ)) {
returnCode = osalHandler->MutexLock(s_commonMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
@ -1147,13 +1196,21 @@ out:
}
if (s_cameraState.isRecording) {
s_cameraState.currentVideoRecordingTimeInSeconds++;
s_cameraSDCardState.remainSpaceInMB =
s_cameraSDCardState.remainSpaceInMB - SDCARD_PER_SECONDS_RECORD_SPACE_IN_MB;
if (s_cameraSDCardState.remainSpaceInMB > SDCARD_TOTAL_SPACE_IN_MB) {
s_cameraSDCardState.remainSpaceInMB = 0;
s_cameraSDCardState.isFull = true;
uint16_t preTimeInSeconds = s_cameraState.currentVideoRecordingTimeInSeconds;
s_currentVideoRecordTimeInSeconds++;
s_cameraState.currentVideoRecordingTimeInSeconds = s_currentVideoRecordTimeInSeconds / intervalFreq;
if (s_cameraState.currentVideoRecordingTimeInSeconds > preTimeInSeconds) {
s_cameraSDCardState.remainSpaceInMB =
s_cameraSDCardState.remainSpaceInMB - SDCARD_PER_SECONDS_RECORD_SPACE_IN_MB;
if (s_cameraSDCardState.remainSpaceInMB > SDCARD_TOTAL_SPACE_IN_MB) {
s_cameraSDCardState.remainSpaceInMB = 0;
s_cameraSDCardState.isFull = true;
}
}
} else {
s_currentVideoRecordTimeInSeconds = 0;
}
if (s_cameraState.isShootingIntervalStart == false) {
@ -1162,10 +1219,16 @@ out:
if (s_cameraShootPhotoMode == DJI_CAMERA_SHOOT_PHOTO_MODE_INTERVAL
&& s_cameraState.isShootingIntervalStart == true && s_cameraPhotoTimeIntervalSettings.captureCount > 0
&& s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds > 0) {
s_cameraState.currentPhotoShootingIntervalTimeInSeconds--;
&& (s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds > 0 || s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds > 0)) {
uint16_t currentPhotoShootingIntervalTimeInMs = s_cameraState.currentPhotoShootingIntervalTimeInSeconds * 1000 +
s_cameraState.currentPhotoShootingIntervalTimeInMs;
if ((s_cameraState.currentPhotoShootingIntervalTimeInSeconds == 0 &&
currentPhotoShootingIntervalTimeInMs -= 1000 / intervalFreq;
s_cameraState.currentPhotoShootingIntervalTimeInSeconds = currentPhotoShootingIntervalTimeInMs / 1000;
s_cameraState.currentPhotoShootingIntervalTimeInMs = currentPhotoShootingIntervalTimeInMs % 1000;
if ((currentPhotoShootingIntervalTimeInMs == 0 &&
s_cameraState.currentPhotoShootingIntervalCount > 0) ||
(s_cameraState.isShootingIntervalStart == true && isStartIntervalPhotoAction == false)) {
@ -1173,13 +1236,23 @@ out:
s_cameraState.shootingState = DJI_CAMERA_SHOOTING_INTERVAL_PHOTO;
s_cameraState.isStoring = true;
s_cameraState.currentPhotoShootingIntervalTimeInSeconds
= s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds;
s_cameraState.currentPhotoShootingIntervalTimeInSeconds = s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds;
s_cameraState.currentPhotoShootingIntervalTimeInMs = s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds;
if (s_cameraState.currentPhotoShootingIntervalCount < INTERVAL_PHOTOGRAPH_ALWAYS_COUNT) {
USER_LOG_INFO("interval taking photograph count:%d interval_time:%ds",
#if USE_RASPBERRY_PI_CAMERA
DjiTest_RaspberryPiCameraTakePhoto();
#endif
DjiTest_WidgetLogAppend("interval taking photo count:%d interval:%d.%ds",
(s_cameraPhotoTimeIntervalSettings.captureCount -
s_cameraState.currentPhotoShootingIntervalCount + 1),
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds);
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds,
s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds / 100);
USER_LOG_INFO("interval taking photograph count:%d interval_time:%d.%ds",
(s_cameraPhotoTimeIntervalSettings.captureCount -
s_cameraState.currentPhotoShootingIntervalCount + 1),
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds,
s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds / 100);
s_cameraState.currentPhotoShootingIntervalCount--;
if (s_cameraState.currentPhotoShootingIntervalCount == 0) {
s_cameraState.shootingState = DJI_CAMERA_SHOOTING_PHOTO_IDLE;
@ -1187,8 +1260,15 @@ out:
s_cameraState.isShootingIntervalStart = false;
}
} else {
USER_LOG_INFO("interval taking photograph always, interval_time:%ds",
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds);
#if USE_RASPBERRY_PI_CAMERA
DjiTest_RaspberryPiCameraTakePhoto();
#endif
DjiTest_WidgetLogAppend("interval taking photo always, interval:%d.%ds",
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds,
s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds / 100);
USER_LOG_INFO("interval taking photograph always, interval_time:%d.%ds",
s_cameraPhotoTimeIntervalSettings.timeIntervalSeconds,
s_cameraPhotoTimeIntervalSettings.timeIntervalMilliseconds / 100);
s_cameraState.currentPhotoShootingIntervalCount--;
}
}
@ -1462,4 +1542,4 @@ bool DjiTest_CameraIsInited(void)
return s_isCamInited;
}
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/

View File

@ -23,6 +23,7 @@
*/
/* Includes ------------------------------------------------------------------*/
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include "dji_logger.h"
@ -35,6 +36,7 @@
#include "camera_emu/dji_media_file_manage/dji_media_file_core.h"
#include "dji_high_speed_data_channel.h"
#include "dji_aircraft_info.h"
#include "test_raspberry_pi_camera.h"
/* Private constants ---------------------------------------------------------*/
#define FFMPEG_CMD_BUF_SIZE (256 + 256)
@ -193,7 +195,8 @@ T_DjiReturnCode DjiTest_CameraEmuMediaStartService(void)
UtilBuffer_Init(&s_mediaPlayCommandBufferHandler, s_mediaPlayCommandBuffer, sizeof(s_mediaPlayCommandBuffer));
if (aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M300_RTK ||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M350_RTK) {
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M350_RTK ||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M400) {
returnCode = DjiPayloadCamera_RegMediaDownloadPlaybackHandler(&s_psdkCameraMedia);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("psdk camera media function init error.");
@ -207,6 +210,13 @@ T_DjiReturnCode DjiTest_CameraEmuMediaStartService(void)
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
#if USE_RASPBERRY_PI_CAMERA
returnCode = DjiTest_RaspberryPiCameraInit();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("start raspberry pi camera error.");
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
#else
if (DjiPlatform_GetHalNetworkHandler() != NULL || DjiPlatform_GetHalUsbBulkHandler() != NULL) {
returnCode = osalHandler->TaskCreate("user_camera_media_task", UserCameraMedia_SendVideoTask, 2048,
NULL, &s_userSendVideoThread);
@ -215,6 +225,7 @@ T_DjiReturnCode DjiTest_CameraEmuMediaStartService(void)
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
}
#endif
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
@ -726,7 +737,7 @@ static T_DjiReturnCode DjiPlayback_GetFrameRateOfVideoFile(const char *path, flo
ret = fscanf(fpCommand, "r_frame_rate=%d/%d", &frameRateMolecule, &frameRateDenominator);
if (ret <= 0) {
USER_LOG_ERROR("can not find frame rate.");
USER_LOG_ERROR("can not find frame rate form \"%s\".", path);
returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_NOT_FOUND;
goto out;
}
@ -1196,7 +1207,7 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
exit(1);
}
if (s_isMediaFileDirPathConfigured == true) {
snprintf(tempPath, DJI_FILE_PATH_SIZE_MAX, "%sPSDK_0005.h264", s_mediaFileDirPath);
snprintf(tempPath, DJI_FILE_PATH_SIZE_MAX, "%smedia_file/PSDK_0005.h264", s_mediaFileDirPath);
} else {
snprintf(tempPath, DJI_FILE_PATH_SIZE_MAX, "%smedia_file/PSDK_0005.h264", curFileDirPath);
}
@ -1309,7 +1320,7 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
fpFile = fopen(transcodedFilePath, "rb+");
if (fpFile == NULL) {
USER_LOG_ERROR("open video file fail.");
USER_LOG_ERROR("open video file:\"%s\" fail:%d.", transcodedFilePath, errno);
continue;
}

View File

@ -65,17 +65,24 @@ static const T_DjiTestCameraTypeStr s_cameraTypeStrList[] = {
{DJI_CAMERA_TYPE_P1, "Zenmuse P1"},
{DJI_CAMERA_TYPE_L1, "Zenmuse L1"},
{DJI_CAMERA_TYPE_L2, "Zenmuse L2"},
{DJI_CAMERA_TYPE_L3, "Zenmuse L3"},
{DJI_CAMERA_TYPE_H20N, "Zenmuse H20N"},
{DJI_CAMERA_TYPE_M30, "M30 Camera"},
{DJI_CAMERA_TYPE_M30T, "M30T Camera"},
{DJI_CAMERA_TYPE_M3E, "M3E Camera"},
{DJI_CAMERA_TYPE_M3T, "M3T Camera"},
{DJI_CAMERA_TYPE_M3TA, "M3TA Camera"},
{DJI_CAMERA_TYPE_M3D, "M3D Camera"},
{DJI_CAMERA_TYPE_M3TD, "M3TD Camera"},
{DJI_CAMERA_TYPE_H30, "H30 Camera"},
{DJI_CAMERA_TYPE_H30T, "H30T Camera"},
{DJI_CAMERA_TYPE_M4T, "M4T Camera"},
{DJI_CAMERA_TYPE_M4E, "M4E Camera"},
{DJI_CAMERA_TYPE_M4TD, "M4TD Camera"},
{DJI_CAMERA_TYPE_M4D, "M4D Camera"},
};
#ifndef SYSTEM_ARCH_RTOS
static FILE *s_downloadMediaFile = NULL;
static T_DjiCameraManagerFileList s_meidaFileList;
static uint32_t downloadStartMs = 0;
@ -84,18 +91,23 @@ static char downloadFileName[TEST_CAMERA_MANAGER_MEDIA_FILE_NAME_MAX_SIZE] = {0}
static uint32_t s_nextDownloadFileIndex = 0;
static T_DjiMopChannelHandle s_mopChannelHandle;
static char s_pointCloudFilePath[TEST_CAMEAR_POINT_CLOUD_FILE_PATH_STR_MAX_SIZE];
#endif
/* Private functions declaration ---------------------------------------------*/
static uint8_t DjiTest_CameraManagerGetCameraTypeIndex(E_DjiCameraType cameraType);
#ifdef SYSTEM_ARCH_LINUX
static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_DjiMountPosition position);
static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadFileListBySlices(E_DjiMountPosition position);
static T_DjiReturnCode DjiTest_CameraManagerDownloadFileDataCallback(T_DjiDownloadFilePacketInfo packetInfo,
const uint8_t *data, uint16_t len);
#endif
static T_DjiReturnCode DjiTest_CameraManagerGetAreaThermometryData(E_DjiMountPosition position);
static T_DjiReturnCode DjiTest_CameraManagerGetPointThermometryData(E_DjiMountPosition position);
static T_DjiReturnCode DjiTest_CameraManagerGetLidarRangingInfo(E_DjiMountPosition position);
#ifndef SYSTEM_ARCH_RTOS
T_DjiReturnCode DjiTest_CameraManagerSubscribePointCloud(E_DjiMountPosition position);
#endif
/* Exported functions definition ---------------------------------------------*/
/*! @brief Sample to set EV for camera, using async api
@ -846,12 +858,18 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_CAMERA_SHUTTER_SPEED: {
USER_LOG_INFO("--> Function a: Set camera shutter speed to 1/100 s");
DjiTest_WidgetLogAppend("--> Function a: Set camera shutter speed to 1/100 s");
if (cameraType == DJI_CAMERA_TYPE_H20 || cameraType == DJI_CAMERA_TYPE_H20T ||
cameraType == DJI_CAMERA_TYPE_H20N || cameraType == DJI_CAMERA_TYPE_M30 ||
cameraType == DJI_CAMERA_TYPE_M30T || cameraType == DJI_CAMERA_TYPE_M3E ||
cameraType == DJI_CAMERA_TYPE_M3T || cameraType == DJI_CAMERA_TYPE_M3D ||
cameraType == DJI_CAMERA_TYPE_M3TD || cameraType == DJI_CAMERA_TYPE_H30 ||
cameraType == DJI_CAMERA_TYPE_H30T) {
if (DJI_CAMERA_TYPE_H20 == cameraType || DJI_CAMERA_TYPE_H20T == cameraType
|| DJI_CAMERA_TYPE_H20N == cameraType
|| DJI_CAMERA_TYPE_M30 == cameraType || DJI_CAMERA_TYPE_M30T == cameraType
|| DJI_CAMERA_TYPE_M3E == cameraType || DJI_CAMERA_TYPE_M3T == cameraType
|| DJI_CAMERA_TYPE_M3TA == cameraType
|| DJI_CAMERA_TYPE_M3D == cameraType || DJI_CAMERA_TYPE_M3TD == cameraType
|| DJI_CAMERA_TYPE_M4T == cameraType || DJI_CAMERA_TYPE_M4TD == cameraType
|| DJI_CAMERA_TYPE_H30 == cameraType || DJI_CAMERA_TYPE_H30T == cameraType
|| DJI_CAMERA_TYPE_M4T == cameraType || DJI_CAMERA_TYPE_M4E == cameraType
|| DJI_CAMERA_TYPE_H30 == cameraType || DJI_CAMERA_TYPE_H30T == cameraType
|| DJI_CAMERA_TYPE_M4TD == cameraType || DJI_CAMERA_TYPE_M4D == cameraType
) {
USER_LOG_INFO("Set mounted position %d camera's exposure mode to manual mode.",
mountPosition);
returnCode = DjiTest_CameraManagerSetExposureMode(mountPosition,
@ -887,12 +905,17 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_CAMERA_APERTURE: {
USER_LOG_INFO("--> Function b: Set camera aperture to 400(F/4)");
DjiTest_WidgetLogAppend("--> Function b: Set camera aperture to 400(F/4)");
if (cameraType == DJI_CAMERA_TYPE_H20 || cameraType == DJI_CAMERA_TYPE_H20N
|| cameraType == DJI_CAMERA_TYPE_H20T || cameraType == DJI_CAMERA_TYPE_M30
|| cameraType == DJI_CAMERA_TYPE_M30T || cameraType == DJI_CAMERA_TYPE_M3E
|| cameraType == DJI_CAMERA_TYPE_M3T || cameraType == DJI_CAMERA_TYPE_M3D
|| cameraType == DJI_CAMERA_TYPE_M3TD || cameraType == DJI_CAMERA_TYPE_H30
|| cameraType == DJI_CAMERA_TYPE_H30T) {
if (DJI_CAMERA_TYPE_H20 == cameraType || DJI_CAMERA_TYPE_H20T == cameraType
|| DJI_CAMERA_TYPE_H20N == cameraType
|| DJI_CAMERA_TYPE_M30 == cameraType || DJI_CAMERA_TYPE_M30T == cameraType
|| DJI_CAMERA_TYPE_M3E == cameraType || DJI_CAMERA_TYPE_M3T == cameraType
|| DJI_CAMERA_TYPE_M3TA == cameraType
|| DJI_CAMERA_TYPE_M3D == cameraType || DJI_CAMERA_TYPE_M3TD == cameraType
|| DJI_CAMERA_TYPE_M4T == cameraType || DJI_CAMERA_TYPE_M4TD == cameraType
|| DJI_CAMERA_TYPE_M4E == cameraType || DJI_CAMERA_TYPE_H30 == cameraType
|| DJI_CAMERA_TYPE_H30T == cameraType|| DJI_CAMERA_TYPE_M4TD == cameraType
|| DJI_CAMERA_TYPE_M4D == cameraType
) {
USER_LOG_INFO("Set mounted position %d camera's exposure mode to manual mode.",
mountPosition);
returnCode = DjiTest_CameraManagerSetExposureMode(mountPosition,
@ -1081,9 +1104,7 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_INTERVAL_PHOTO: {
USER_LOG_INFO("--> Function k: Shoot Interval photo with 3s intervals in 15s");
DjiTest_WidgetLogAppend("--> Function k: Shoot Interval photo with 3s intervals in 15s");
T_DjiCameraPhotoTimeIntervalSettings intervalData;
intervalData.captureCount = 255;
intervalData.timeIntervalSeconds = 3;
T_DjiCameraPhotoTimeIntervalSettings intervalData = {.captureCount = 255, .timeIntervalSeconds = 3, .timeIntervalMilliseconds = 0};
returnCode = DjiTest_CameraManagerStartShootIntervalPhoto(mountPosition, intervalData);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -1185,11 +1206,17 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
E_DjiCameraManagerNightSceneMode nightSceneMode;
T_DjiCameraManagerRangeList nightSceneModeRange;
if (cameraType == DJI_CAMERA_TYPE_XT2 || cameraType == DJI_CAMERA_TYPE_XTS ||
cameraType == DJI_CAMERA_TYPE_H20 || cameraType == DJI_CAMERA_TYPE_P1 ||
cameraType == DJI_CAMERA_TYPE_L1 || cameraType == DJI_CAMERA_TYPE_L2 ||
cameraType == DJI_CAMERA_TYPE_M3E || cameraType == DJI_CAMERA_TYPE_M3T ||
cameraType == DJI_CAMERA_TYPE_M3D || cameraType == DJI_CAMERA_TYPE_M3TD) {
if (DJI_CAMERA_TYPE_XT2 == cameraType || DJI_CAMERA_TYPE_XTS == cameraType
|| DJI_CAMERA_TYPE_H20 == cameraType
|| DJI_CAMERA_TYPE_P1 == cameraType
|| DJI_CAMERA_TYPE_L1 == cameraType || DJI_CAMERA_TYPE_L2 == cameraType
|| DJI_CAMERA_TYPE_M3E == cameraType || DJI_CAMERA_TYPE_M3T == cameraType
|| DJI_CAMERA_TYPE_M3TA == cameraType
|| DJI_CAMERA_TYPE_M3D == cameraType || DJI_CAMERA_TYPE_M3TD == cameraType
|| DJI_CAMERA_TYPE_M4T == cameraType || DJI_CAMERA_TYPE_M4E == cameraType
|| DJI_CAMERA_TYPE_M4TD == cameraType || DJI_CAMERA_TYPE_M4D == cameraType
|| DJI_CAMERA_TYPE_L3 == cameraType
) {
USER_LOG_INFO("Camera type %s does not support night scene mode!",
s_cameraTypeStrList[DjiTest_CameraManagerGetCameraTypeIndex(cameraType)].cameraTypeStr);
goto exitCameraModule;
@ -1534,6 +1561,7 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
cameraType == DJI_CAMERA_TYPE_H20N || cameraType == DJI_CAMERA_TYPE_M30 ||
cameraType == DJI_CAMERA_TYPE_M30T || cameraType == DJI_CAMERA_TYPE_M3E ||
cameraType == DJI_CAMERA_TYPE_M3T || cameraType == DJI_CAMERA_TYPE_H30 ||
cameraType == DJI_CAMERA_TYPE_M3TA ||
cameraType == DJI_CAMERA_TYPE_H30T) {
returnCode = DjiCameraManager_SetStreamSource(mountPosition, DJI_CAMERA_MANAGER_SOURCE_ZOOM_CAM);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -1595,7 +1623,9 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
cameraType == DJI_CAMERA_TYPE_H20T || cameraType == DJI_CAMERA_TYPE_M30 ||
cameraType == DJI_CAMERA_TYPE_M30T || cameraType == DJI_CAMERA_TYPE_M3E ||
cameraType == DJI_CAMERA_TYPE_M3T || cameraType == DJI_CAMERA_TYPE_H30 ||
cameraType == DJI_CAMERA_TYPE_H30T) {
cameraType == DJI_CAMERA_TYPE_M3TA ||
cameraType == DJI_CAMERA_TYPE_H30T)
{
USER_LOG_INFO("Set camera stream source to zoom camera.");
returnCode = DjiCameraManager_SetStreamSource(mountPosition, DJI_CAMERA_MANAGER_SOURCE_ZOOM_CAM);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -1637,7 +1667,8 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
if (cameraType != DJI_CAMERA_TYPE_Z30) {
returnCode = DjiCameraManager_GetFocusRingValue(mountPosition, &focusRingValue);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS
&& returnCode != DJI_ERROR_CAMERA_MANAGER_MODULE_CODE_UNSUPPORTED_COMMAND) {
USER_LOG_ERROR("Get camera focus ring value at position %d failed", mountPosition);
goto exitCameraModule;
}
@ -1817,60 +1848,51 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
}
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_METERING_MODE: {
E_DjiCameraManagerMeteringMode meteringMode;
T_DjiCameraManagerRangeList rangeList = {0};
USER_LOG_INFO("Set metering mode as %d", DJI_CAMERA_MANAGER_METERING_MODE_AVERAGE);
returnCode = DjiCameraManager_SetMeteringMode(mountPosition, DJI_CAMERA_MANAGER_METERING_MODE_AVERAGE);
returnCode = DjiCameraManager_GetMeteringModeRange(mountPosition, &rangeList);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Set camera metering mode %d failed", DJI_CAMERA_MANAGER_METERING_MODE_AVERAGE);
USER_LOG_ERROR("Failed to get metering mode range of camera on position %d, return code 0x%08X",
mountPosition, returnCode);
goto exitCameraModule;
}
osalHandler->TaskSleepMs(200);
USER_LOG_INFO("Avaliable metering mode num is %d", rangeList.size);
returnCode = DjiCameraManager_GetMeteringMode(mountPosition, &meteringMode);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get camera metering mode failed.");
goto exitCameraModule;
for (uint8_t i = 0; i < rangeList.size; i++) {
USER_LOG_INFO("[%d] Set metering mode as %d (%s)",
i,
rangeList.meteringMode[i],
rangeList.meteringMode[i] == DJI_CAMERA_MANAGER_METERING_MODE_CENTRAL ? "centeral" :
rangeList.meteringMode[i] == DJI_CAMERA_MANAGER_METERING_MODE_AVERAGE ? "average" :
rangeList.meteringMode[i] == DJI_CAMERA_MANAGER_METERING_MODE_SPOT ? "spot" :
"error mode"
);
returnCode = DjiCameraManager_SetMeteringMode(mountPosition, rangeList.meteringMode[i]);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Set camera metering mode %d failed", DJI_CAMERA_MANAGER_METERING_MODE_AVERAGE);
goto exitCameraModule;
}
osalHandler->TaskSleepMs(200);
returnCode = DjiCameraManager_GetMeteringMode(mountPosition, &meteringMode);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get camera metering mode failed.");
goto exitCameraModule;
}
USER_LOG_INFO("[%d] Current mode is %d (%s)",
i,
rangeList.meteringMode[i],
rangeList.meteringMode[i] == DJI_CAMERA_MANAGER_METERING_MODE_CENTRAL ? "centeral" :
rangeList.meteringMode[i] == DJI_CAMERA_MANAGER_METERING_MODE_AVERAGE ? "average" :
rangeList.meteringMode[i] == DJI_CAMERA_MANAGER_METERING_MODE_SPOT ? "spot" :
"error mode"
);
osalHandler->TaskSleepMs(2000);
}
USER_LOG_INFO("Current metering mode is %d", meteringMode);
USER_LOG_INFO("Sleep 2s...");
osalHandler->TaskSleepMs(2000);
USER_LOG_INFO("Set metering mode as %d", DJI_CAMERA_MANAGER_METERING_MODE_SPOT);
returnCode = DjiCameraManager_SetMeteringMode(mountPosition, DJI_CAMERA_MANAGER_METERING_MODE_SPOT);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Set camera metering mode %d failed", DJI_CAMERA_MANAGER_METERING_MODE_SPOT);
goto exitCameraModule;
}
osalHandler->TaskSleepMs(200);
returnCode = DjiCameraManager_GetMeteringMode(mountPosition, &meteringMode);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get camera metering mode failed.");
goto exitCameraModule;
}
USER_LOG_INFO("Current metering mode is %d", meteringMode);
USER_LOG_INFO("Sleep 2s...");
osalHandler->TaskSleepMs(2000);
USER_LOG_INFO("Set metering mode as %d", DJI_CAMERA_MANAGER_METERING_MODE_CENTRAL);
returnCode = DjiCameraManager_SetMeteringMode(mountPosition, DJI_CAMERA_MANAGER_METERING_MODE_CENTRAL);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Set camera metering mode %d failed", DJI_CAMERA_MANAGER_METERING_MODE_CENTRAL);
goto exitCameraModule;
}
osalHandler->TaskSleepMs(200);
returnCode = DjiCameraManager_GetMeteringMode(mountPosition, &meteringMode);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get camera metering mode failed.");
goto exitCameraModule;
}
USER_LOG_INFO("Current metering mode is %d", meteringMode);
break;
}
@ -1885,34 +1907,62 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
goto exitCameraModule;
}
returnCode = DjiCameraManager_GetMeteringPointRegionRange(mountPosition, &horizonRegionNum, &viticalRegionNum);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get metering point region range failed!");
goto exitCameraModule;
if (cameraType == DJI_CAMERA_TYPE_L3) {
dji_f32_t inputXFloat, inputYFloat;
dji_f32_t getXFloat, getYFloat;
printf("Input nomorlized meterting point, range: 0.0 ~ 1.0 (x, y) you want to set: ");
scanf("%f %f", &inputXFloat, &inputYFloat);
USER_LOG_INFO("Try to set metering point as (%f, %f)", inputXFloat, inputYFloat);
returnCode = DjiCameraManager_SetMeteringPointNormalized(mountPosition, inputXFloat, inputYFloat);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Set metering point failed");
goto exitCameraModule;
}
osalHandler->TaskSleepMs(500);
returnCode = DjiCameraManager_GetMeteringPointNormalized(mountPosition, &getXFloat, &getYFloat);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get metering point failed");
goto exitCameraModule;
}
USER_LOG_INFO("Current metering point in normalized: (%f, %f)", getXFloat, getYFloat);
} else {
returnCode = DjiCameraManager_GetMeteringPointRegionRange(mountPosition, &horizonRegionNum, &viticalRegionNum);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get metering point region range failed!");
goto exitCameraModule;
}
USER_LOG_INFO("region range: horizon %d, vitical %d", horizonRegionNum, viticalRegionNum);
osalHandler->TaskSleepMs(5);
printf("Input meterting point (x, y) you want to set: ");
scanf("%d %d", &x, &y);
USER_LOG_INFO("Try to set metering point as (%d, %d)", (uint8_t)x, (uint8_t)y);
returnCode = DjiCameraManager_SetMeteringPoint(mountPosition, x, y);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Set metering point failed");
goto exitCameraModule;
}
osalHandler->TaskSleepMs(500);
returnCode = DjiCameraManager_GetMeteringPoint(mountPosition, &getX, &getY);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get metering point failed");
goto exitCameraModule;
}
USER_LOG_INFO("Current metering point: (%d, %d)", getX, getY);
}
USER_LOG_INFO("region range: horizon %d, vitical %d", horizonRegionNum, viticalRegionNum);
osalHandler->TaskSleepMs(5);
printf("Input meterting point (x, y) you want to set: ");
scanf("%d %d", &x, &y);
USER_LOG_INFO("Try to set metering point as (%d, %d)", (uint8_t)x, (uint8_t)y);
returnCode = DjiCameraManager_SetMeteringPoint(mountPosition, x, y);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Set metering point failed");
goto exitCameraModule;
}
osalHandler->TaskSleepMs(500);
returnCode = DjiCameraManager_GetMeteringPoint(mountPosition, &getX, &getY);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get metering point failed");
goto exitCameraModule;
}
USER_LOG_INFO("Current metering point: (%d, %d)", getX, getY);
break;
}
@ -1923,7 +1973,10 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
cameraType == DJI_CAMERA_TYPE_H20 || cameraType == DJI_CAMERA_TYPE_P1 ||
cameraType == DJI_CAMERA_TYPE_L1 || cameraType == DJI_CAMERA_TYPE_M30 ||
cameraType == DJI_CAMERA_TYPE_M3E || cameraType == DJI_CAMERA_TYPE_M3D ||
cameraType == DJI_CAMERA_TYPE_L2 || cameraType == DJI_CAMERA_TYPE_H30) {
cameraType == DJI_CAMERA_TYPE_L2 || cameraType == DJI_CAMERA_TYPE_H30 ||
cameraType == DJI_CAMERA_TYPE_M4TD || cameraType == DJI_CAMERA_TYPE_M4D ||
cameraType == DJI_CAMERA_TYPE_M4T || cameraType == DJI_CAMERA_TYPE_L3 ||
cameraType == DJI_CAMERA_TYPE_M4E) {
USER_LOG_WARN("Camera type %s don't support FFC function.",
s_cameraTypeStrList[DjiTest_CameraManagerGetCameraTypeIndex(cameraType)].cameraTypeStr);
goto exitCameraModule;
@ -1969,7 +2022,10 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
cameraType == DJI_CAMERA_TYPE_H20 || cameraType == DJI_CAMERA_TYPE_P1 ||
cameraType == DJI_CAMERA_TYPE_L1 || cameraType == DJI_CAMERA_TYPE_M30 ||
cameraType == DJI_CAMERA_TYPE_M3E || cameraType == DJI_CAMERA_TYPE_M3D ||
cameraType == DJI_CAMERA_TYPE_L2 || cameraType == DJI_CAMERA_TYPE_H30) {
cameraType == DJI_CAMERA_TYPE_L2 || cameraType == DJI_CAMERA_TYPE_H30 ||
cameraType == DJI_CAMERA_TYPE_M4TD || cameraType == DJI_CAMERA_TYPE_M4D ||
cameraType == DJI_CAMERA_TYPE_M4T || cameraType == DJI_CAMERA_TYPE_L3 ||
cameraType == DJI_CAMERA_TYPE_M4E) {
USER_LOG_WARN("Camera type %s don't support infrared function.",
s_cameraTypeStrList[DjiTest_CameraManagerGetCameraTypeIndex(cameraType)].cameraTypeStr);
goto exitCameraModule;
@ -2102,6 +2158,7 @@ static uint8_t DjiTest_CameraManagerGetCameraTypeIndex(E_DjiCameraType cameraTyp
return 0;
}
#ifdef SYSTEM_ARCH_LINUX
static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_DjiMountPosition position)
{
T_DjiReturnCode returnCode;
@ -2117,9 +2174,11 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
return returnCode;
}
USER_LOG_INFO("obtain downloader rights of pos %d", position);
returnCode = DjiCameraManager_ObtainDownloaderRights(position);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Obtain downloader rights failed, error code: 0x%08X.", returnCode);
return returnCode;
}
returnCode = DjiCameraManager_DownloadFileList(position, &s_meidaFileList);
@ -2180,7 +2239,7 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
returnCode = DjiCameraManager_DownloadFileByIndex(position, s_meidaFileList.fileListInfo[i].fileIndex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Download media file by index failed, error code: 0x%08X.", returnCode);
s_nextDownloadFileIndex--;
if(s_nextDownloadFileIndex > 0)s_nextDownloadFileIndex--;
goto redownload;
}
if (s_meidaFileList.fileListInfo[i].type == DJI_CAMERA_FILE_TYPE_LDRT) {
@ -2198,11 +2257,12 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
}
}
if (s_meidaFileList.fileListInfo[0].type == DJI_CAMERA_FILE_TYPE_JPEG) {
if (s_meidaFileList.fileListInfo[0].type == DJI_CAMERA_FILE_TYPE_JPEG ||
s_meidaFileList.fileListInfo[0].type == DJI_CAMERA_FILE_TYPE_MP4) {
USER_LOG_INFO("delete camera file of index %d", s_meidaFileList.fileListInfo[0].fileIndex);
returnCode = DjiCameraManager_DeleteFileByIndex(position, s_meidaFileList.fileListInfo[0].fileIndex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Delete media file by index failed, error code: 0x%08X.", returnCode);
return returnCode;
}
}
@ -2211,6 +2271,7 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
USER_LOG_WARN("Media file is not existed in sdcard.\r\n");
}
ReleaseDownloaderRights:
returnCode = DjiCameraManager_ReleaseDownloaderRights(position);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Release downloader rights failed, error code: 0x%08X.", returnCode);
@ -2427,6 +2488,7 @@ static T_DjiReturnCode DjiTest_CameraManagerDownloadFileDataCallback(T_DjiDownlo
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
#endif
static T_DjiReturnCode DjiTest_CameraManagerGetPointThermometryData(E_DjiMountPosition position)
{
@ -2559,6 +2621,7 @@ T_DjiReturnCode DjiTest_CameraManagerSubscribePointCloud(E_DjiMountPosition posi
uint32_t colorPointCloudDataByte = 0;
uint32_t colorPointsNum = 0;
static bool isMopInit = false;
E_DjiChannelAddress mopChannelAddress = 0;
returnCode = DjiCameraManager_StartRecordPointCloud(position);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -2597,7 +2660,10 @@ T_DjiReturnCode DjiTest_CameraManagerSubscribePointCloud(E_DjiMountPosition posi
RECONNECT:
osalHandler->TaskSleepMs(TEST_CAMERA_MOP_CHANNEL_WAIT_TIME_MS);
returnCode = DjiMopChannel_Connect(s_mopChannelHandle, DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO1,
mopChannelAddress = position - DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1 + DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO1;
USER_LOG_INFO("connect to mop channel addr %d, channel id %d",
mopChannelAddress, TEST_CAMERA_MOP_CHANNEL_SUBSCRIBE_POINT_CLOUD_CHANNEL_ID);
returnCode = DjiMopChannel_Connect(s_mopChannelHandle, mopChannelAddress,
TEST_CAMERA_MOP_CHANNEL_SUBSCRIBE_POINT_CLOUD_CHANNEL_ID);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Connect point cloud mop channel error, stat:0x%08llX.", returnCode);

View File

@ -38,6 +38,10 @@
#define DATA_TRANSMISSION_TASK_STACK_SIZE (2048)
/* Private types -------------------------------------------------------------*/
typedef struct {
E_DjiChannelAddress channelAddress;
T_DjiReturnCode (*callback)(const uint8_t *data, uint16_t len);
} ChannelCallbackEntry;
/* Private functions declaration ---------------------------------------------*/
static void *UserDataTransmission_Task(void *arg);
@ -49,10 +53,25 @@ static T_DjiReturnCode ReceiveDataFromPayload1(const uint8_t *data, uint16_t len
static T_DjiReturnCode ReceiveDataFromPayload2(const uint8_t *data, uint16_t len);
static T_DjiReturnCode ReceiveDataFromPayload3(const uint8_t *data, uint16_t len);
static T_DjiReturnCode ReceiveDataFromPayload4(const uint8_t *data, uint16_t len);
static T_DjiReturnCode ReceiveDataFromPayload5(const uint8_t *data, uint16_t len);
static T_DjiReturnCode ReceiveDataFromPayload6(const uint8_t *data, uint16_t len);
static T_DjiReturnCode ReceiveDataFromPayload7(const uint8_t *data, uint16_t len);
static T_DjiReturnCode ReceiveDataFromPayload8(const uint8_t *data, uint16_t len);
/* Private variables ---------------------------------------------------------*/
static T_DjiTaskHandle s_userDataTransmissionThread;
static T_DjiAircraftInfoBaseInfo s_aircraftInfoBaseInfo;
static const ChannelCallbackEntry g_channelCallbacks[] = {
{DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO1, ReceiveDataFromPayload1},
{DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO2, ReceiveDataFromPayload2},
{DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO3, ReceiveDataFromPayload3},
{DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO4, ReceiveDataFromPayload4},
{DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO5, ReceiveDataFromPayload5},
{DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO6, ReceiveDataFromPayload6},
{DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO7, ReceiveDataFromPayload7},
{DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO8, ReceiveDataFromPayload8},
};
/* Exported functions definition ---------------------------------------------*/
T_DjiReturnCode DjiTest_DataTransmissionStartService(void)
{
@ -83,8 +102,13 @@ T_DjiReturnCode DjiTest_DataTransmissionStartService(void)
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
if (s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M30 ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M30T) {
if ((s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M30 ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M30T ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3D ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3TD ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M4D ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M4TD) &&
s_aircraftInfoBaseInfo.mountPositionType != DJI_MOUNT_POSITION_TYPE_MANIFOLD3_ONBOARD) {
channelAddress = DJI_CHANNEL_ADDRESS_CLOUD_API;
djiStat = DjiLowSpeedDataChannel_RegRecvDataCallback(channelAddress, ReceiveDataFromCloud);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -93,7 +117,20 @@ T_DjiReturnCode DjiTest_DataTransmissionStartService(void)
}
}
if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1 ||
if (s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M400) {
uint8_t Channel_Callback_count = (sizeof(g_channelCallbacks) / sizeof(g_channelCallbacks[0]));
for (uint8_t i = 0; i < Channel_Callback_count; i++) {
const ChannelCallbackEntry *entry = &g_channelCallbacks[i];
T_DjiReturnCode djiStat =
DjiLowSpeedDataChannel_RegRecvDataCallback(entry->channelAddress, entry->callback);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("register receive data from channel %d error.", entry->channelAddress);
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
}
USER_LOG_INFO("Only supports small data transmission between PSDK and MSDK.");
} else if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1 ||
s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_PAYLOAD_PORT_NO2 ||
s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_PAYLOAD_PORT_NO3) {
channelAddress = DJI_CHANNEL_ADDRESS_EXTENSION_PORT;
@ -206,8 +243,12 @@ static void *UserDataTransmission_Task(void *arg)
USER_LOG_ERROR("get send to mobile channel state error.");
}
if (s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M30 ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M30T) {
if (s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M30 ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M30T ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3D ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3TD ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M4D ||
s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M4TD ) {
channelAddress = DJI_CHANNEL_ADDRESS_CLOUD_API;
djiStat = DjiLowSpeedDataChannel_SendData(channelAddress, dataToBeSent, sizeof(dataToBeSent));
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
@ -224,55 +265,75 @@ static void *UserDataTransmission_Task(void *arg)
}
}
if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1 ||
s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_PAYLOAD_PORT_NO2 ||
s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_PAYLOAD_PORT_NO3) {
channelAddress = DJI_CHANNEL_ADDRESS_EXTENSION_PORT;
if (s_aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M400){
/*!< Code Example for Data Transmission Between PSDK and PSDK. */
/*!< Only support Psdk on M400. */
/*
channelAddress = DJI_CHANNEL_ADDRESS_EXTENSION_PORT_V2_NO1;
djiStat = DjiLowSpeedDataChannel_SendData(channelAddress, dataToBeSent, sizeof(dataToBeSent));
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
USER_LOG_ERROR("send data to extension port error.");
USER_LOG_ERROR("send data to psdk error port1.");
djiStat = DjiLowSpeedDataChannel_GetSendDataState(channelAddress, &state);
if (djiStat == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_DEBUG(
"send to extension port state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.",
"send to psdk state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.",
state.realtimeBandwidthBeforeFlowController, state.realtimeBandwidthAfterFlowController,
state.busyState);
} else {
USER_LOG_ERROR("get send to extension port channel state error.");
USER_LOG_ERROR("get send to psdk channel state error.");
}
if (DjiPlatform_GetSocketHandler() != NULL) {
#ifdef SYSTEM_ARCH_LINUX
djiStat = DjiHighSpeedDataChannel_SendDataStreamData(dataToBeSent, sizeof(dataToBeSent));
*/
}else{
if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1 ||
s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_PAYLOAD_PORT_NO2 ||
s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_PAYLOAD_PORT_NO3) {
channelAddress = DJI_CHANNEL_ADDRESS_EXTENSION_PORT;
djiStat = DjiLowSpeedDataChannel_SendData(channelAddress, dataToBeSent, sizeof(dataToBeSent));
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
USER_LOG_ERROR("send data to data stream error.");
USER_LOG_ERROR("send data to extension port error.");
djiStat = DjiHighSpeedDataChannel_GetDataStreamState(&state);
djiStat = DjiLowSpeedDataChannel_GetSendDataState(channelAddress, &state);
if (djiStat == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_DEBUG(
"data stream state: realtimeBandwidthLimit: %d, realtimeBandwidthBeforeFlowController: %d, busyState: %d.",
state.realtimeBandwidthLimit, state.realtimeBandwidthBeforeFlowController, state.busyState);
"send to extension port state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.",
state.realtimeBandwidthBeforeFlowController, state.realtimeBandwidthAfterFlowController,
state.busyState);
} else {
USER_LOG_ERROR("get data stream state error.");
USER_LOG_ERROR("get send to extension port channel state error.");
}
#endif
}
} else if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT
|| DJI_MOUNT_POSITION_EXTENSION_LITE_PORT == s_aircraftInfoBaseInfo.mountPosition) {
channelAddress = DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO1;
djiStat = DjiLowSpeedDataChannel_SendData(channelAddress, dataToBeSent, sizeof(dataToBeSent));
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
USER_LOG_ERROR("send data to extension port error.");
djiStat = DjiLowSpeedDataChannel_GetSendDataState(channelAddress, &state);
if (djiStat == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_DEBUG(
"send to extension port state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.",
state.realtimeBandwidthBeforeFlowController, state.realtimeBandwidthAfterFlowController,
state.busyState);
} else {
USER_LOG_ERROR("get send to extension port channel state error.");
if (DjiPlatform_GetSocketHandler() != NULL) {
#ifdef SYSTEM_ARCH_LINUX
djiStat = DjiHighSpeedDataChannel_SendDataStreamData(dataToBeSent, sizeof(dataToBeSent));
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
USER_LOG_ERROR("send data to data stream error.");
djiStat = DjiHighSpeedDataChannel_GetDataStreamState(&state);
if (djiStat == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_DEBUG(
"data stream state: realtimeBandwidthLimit: %d, realtimeBandwidthBeforeFlowController: %d, busyState: %d.",
state.realtimeBandwidthLimit, state.realtimeBandwidthBeforeFlowController, state.busyState);
} else {
USER_LOG_ERROR("get data stream state error.");
}
#endif
}
} else if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT) {
channelAddress = DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO1;
djiStat = DjiLowSpeedDataChannel_SendData(channelAddress, dataToBeSent, sizeof(dataToBeSent));
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
USER_LOG_ERROR("send data to extension port error.");
djiStat = DjiLowSpeedDataChannel_GetSendDataState(channelAddress, &state);
if (djiStat == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_DEBUG(
"send to extension port state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.",
state.realtimeBandwidthBeforeFlowController, state.realtimeBandwidthAfterFlowController,
state.busyState);
} else {
USER_LOG_ERROR("get send to extension port channel state error.");
}
}
}
}
@ -384,4 +445,32 @@ static T_DjiReturnCode ReceiveDataFromPayload3(const uint8_t *data, uint16_t len
return ReceiveDataFromPayload(data, len);
}
static T_DjiReturnCode ReceiveDataFromPayload4(const uint8_t *data, uint16_t len)
{
USER_LOG_INFO("Receive from payload on port 4");
return ReceiveDataFromPayload(data, len);
}
static T_DjiReturnCode ReceiveDataFromPayload5(const uint8_t *data, uint16_t len)
{
USER_LOG_INFO("Receive from payload on port 5");
return ReceiveDataFromPayload(data, len);
}
static T_DjiReturnCode ReceiveDataFromPayload6(const uint8_t *data, uint16_t len)
{
USER_LOG_INFO("Receive from payload on port 6");
return ReceiveDataFromPayload(data, len);
}
static T_DjiReturnCode ReceiveDataFromPayload7(const uint8_t *data, uint16_t len)
{
USER_LOG_INFO("Receive from payload on port 7");
return ReceiveDataFromPayload(data, len);
}
static T_DjiReturnCode ReceiveDataFromPayload8(const uint8_t *data, uint16_t len)
{
USER_LOG_INFO("Receive from payload on port 8");
return ReceiveDataFromPayload(data, len);
}
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/

View File

@ -32,7 +32,7 @@
/* Private constants ---------------------------------------------------------*/
#define FC_SUBSCRIPTION_TASK_FREQ (1)
#define FC_SUBSCRIPTION_TASK_STACK_SIZE (1024)
#define FC_SUBSCRIPTION_TASK_STACK_SIZE (2048)
/* Private types -------------------------------------------------------------*/
@ -173,8 +173,8 @@ T_DjiReturnCode DjiTest_FcSubscriptionRunSample(void)
USER_LOG_INFO("gps position: x = %d y = %d z = %d.", gpsPosition.x, gpsPosition.y, gpsPosition.z);
}
//Attention: if you want to subscribe the single battery info on M300 RTK, you need connect USB cable to
//OSDK device or use topic DJI_FC_SUBSCRIPTION_TOPIC_BATTERY_INFO instead.
// Attention: if you want to subscribe the single battery info on M300 RTK, you need connect USB cable to
// OSDK device or use topic DJI_FC_SUBSCRIPTION_TOPIC_BATTERY_INFO instead.
djiStat = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_BATTERY_SINGLE_INFO_INDEX1,
(uint8_t *) &singleBatteryInfo,
sizeof(T_DjiFcSubscriptionSingleBatteryInfo),

View File

@ -31,6 +31,7 @@
#include <math.h>
#include <widget_interaction_test/test_widget_interaction.h>
#include <dji_aircraft_info.h>
#include "dji_fts.h"
/* Private constants ---------------------------------------------------------*/
/* Private types -------------------------------------------------------------*/
@ -45,6 +46,7 @@ static const double s_earthCenter = 6378137.0;
static const double s_degToRad = 0.01745329252;
static bool s_isFtsCallbackRegistered = false;
static int32_t s_ftsTriggerCount = 0;
static uint8_t s_mission_state_machine = 0;
static const T_DjiTestFlightControlDisplayModeStr s_flightControlDisplayModeStr[] = {
{.displayMode = DJI_FC_SUBSCRIPTION_DISPLAY_MODE_ATTITUDE, .displayModeStr = "attitude mode"},
@ -98,9 +100,12 @@ static void DjiTest_FlightControlGoHomeForceLandingSample(void);
static void DjiTest_FlightControlVelocityControlSample(void);
static void DjiTest_FlightControlArrestFlyingSample(void);
static void DjiTest_FlightControlSetGetParamSample(void);
static void DjiTest_FlightControlSetGetPerceptionParamSample(void);
static void DjiTest_FlightControlPassiveTriggerFtsSample(void);
static void DjiTest_FlightControlSlowRotateMotorSample(void);
static T_DjiReturnCode DjiTest_TriggerFtsEventCallback(void);
static void DjiTest_FlightControlSample(E_DjiTestFlightCtrlSampleSelect flightCtrlSampleSelect);
static void DjiTest_FlightControlSetModeStartMission(void);
/* Exported functions definition ---------------------------------------------*/
T_DjiReturnCode DjiTest_FlightControlRunSample(E_DjiTestFlightCtrlSampleSelect flightCtrlSampleSelect)
@ -888,6 +893,163 @@ out:
DjiTest_WidgetLogAppend("Flight control set-get-param sample end");
}
void DjiTest_FlightControlSetGetPerceptionParamSample()
{
T_DjiReturnCode returnCode;
uint16_t exit_reason;
T_DjiAircraftInfoBaseInfo aircraftInfoBaseInfo;
returnCode = DjiAircraftInfo_GetBaseInfo(&aircraftInfoBaseInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get aircraft base info error");
return;
}
switch (aircraftInfoBaseInfo.aircraftType)
{
case DJI_AIRCRAFT_TYPE_M4T:
case DJI_AIRCRAFT_TYPE_M4E:
case DJI_AIRCRAFT_TYPE_M4D:
case DJI_AIRCRAFT_TYPE_M4TD:
case DJI_AIRCRAFT_TYPE_M400:
break;
default:
USER_LOG_WARN("aircraft type %d not support", aircraftInfoBaseInfo.aircraftType);
return;
}
USER_LOG_INFO("Flight control set-get-perception-param sample start");
DjiTest_WidgetLogAppend("Flight control set-get-perception-param sample start");
/* perception parameter test*/
USER_LOG_INFO("--> Step 1: DjiFlightController_SetPlanningAlgo");
DjiTest_WidgetLogAppend("--> Step 1: DjiFlightController_SetPlanningAlgo");
returnCode = DjiFlightController_SetPlanningAlgo(1);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("DjiFlightController_SetPlanningAlgo failed, error code: 0x%08X", returnCode);
};
s_osalHandler->TaskSleepMs(1000);
USER_LOG_INFO("--> Step 2: DjiFlightController_SetMaxVelocity");
DjiTest_WidgetLogAppend("--> Step 2: DjiFlightController_SetMaxVelocity");
returnCode = DjiFlightController_SetMaxVelocity(10);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("DjiFlightController_SetMaxVelocity failed, error code: 0x%08X", returnCode);
};
s_osalHandler->TaskSleepMs(1000);
USER_LOG_INFO("--> Step 3: DjiFlightController_SetMinFlightHeight");
DjiTest_WidgetLogAppend("--> Step 3: DjiFlightController_SetMinFlightHeight");
returnCode = DjiFlightController_SetMinFlightHeight(50.0f);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("DjiFlightController_SetMinFlightHeight failed, error code: 0x%08X", returnCode);
};
s_osalHandler->TaskSleepMs(1000);
USER_LOG_INFO("--> Step 4: DjiFlightController_GetExitReason");
DjiTest_WidgetLogAppend("--> Step 4: DjiFlightController_GetExitReason");
returnCode = DjiFlightController_GetExitReason(&exit_reason);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("DjiFlightController_GetExitReason failed, error code: 0x%08X", returnCode);
};
USER_LOG_INFO("DjiFlightController_GetExitReason is %d\r\n", exit_reason);
s_osalHandler->TaskSleepMs(1000);
out:
USER_LOG_INFO("Flight control set-get-perception-param sample end");
DjiTest_WidgetLogAppend("Flight control set-get-perception-param perceptionsample end");
}
T_DjiReturnCode DjiTest_FlightControlOpenMisInfoCallback(T_DjiFlightControllerOpenMis eventData)
{
s_mission_state_machine = eventData.mission_state_machine;
USER_LOG_INFO("OpenMisInfoCallback state_machine = %d, planning_algo = %d, goal_index = %d, distance_remaining = %f, time_remaining = %f, soe_remaining = %d",
eventData.mission_state_machine, eventData.mission_planning_algo, eventData.goal_index,
eventData.distance_remaining, eventData.time_remaining, eventData.soe_remaining);
}
T_DjiReturnCode DjiTest_FlightControlCoreTrajCallback(T_DjiFlightControllerCoreTraj eventData)
{
USER_LOG_INFO("DjiTest_FlightControlCoreTrajCallback code_name = %d, point_num = %d, byte_per_point = %d",
eventData.code_name, eventData.point_num, eventData.byte_per_point);
}
void DjiTest_FlightControlSetModeStartMission()
{
T_DjiReturnCode returnCode;
T_DjiFlightControllerStartMissionReq req = {0};
T_DjiFlightControllerStartMissionRsp rsp = {0};
T_DjiAircraftInfoBaseInfo aircraftInfoBaseInfo;
returnCode = DjiAircraftInfo_GetBaseInfo(&aircraftInfoBaseInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get aircraft base info error");
return;
}
switch (aircraftInfoBaseInfo.aircraftType)
{
case DJI_AIRCRAFT_TYPE_M4T:
case DJI_AIRCRAFT_TYPE_M4E:
case DJI_AIRCRAFT_TYPE_M4D:
case DJI_AIRCRAFT_TYPE_M4TD:
case DJI_AIRCRAFT_TYPE_M400:
break;
default:
USER_LOG_WARN("aircraft type %d not support", aircraftInfoBaseInfo.aircraftType);
return;
}
req.version = 1;
req.operation = 0;
req.mea = 10.0f;
req.fly_vel = 10;
req.goal_num = 1;
req.cmd_mode_point_info->lat = 22.578111231;
req.cmd_mode_point_info->lon = 113.93696;
req.cmd_mode_point_info->alt = 50.0;
USER_LOG_INFO("Flight control SetModeStartMission sample start");
DjiTest_WidgetLogAppend("Flight control SetModeStartMission sample start");
returnCode = DjiFlightController_SetModeStartMission(req, &rsp);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("DjiTest_FlightControlSetModeStartMission failed, error code: 0x%08X", returnCode);
} else {
USER_LOG_INFO("DjiTest_FlightControlSetModeStartMission success ret = %d", returnCode);
}
USER_LOG_INFO("Flight control SetModeStartMission sample end");
DjiTest_WidgetLogAppend("Flight control SetModeStartMission sample end");
USER_LOG_INFO("Flight control register callback sample start");
DjiTest_WidgetLogAppend("Flight control register callback sample start");
returnCode = DjiFlightController_RegisterOpenMisInfoCallBack(DjiTest_FlightControlOpenMisInfoCallback);
USER_LOG_INFO("RegisterOpenMisInfoCallBack ret = %d", returnCode);
returnCode = DjiFlightController_RegisterCoreTrajCallBack(DjiTest_FlightControlCoreTrajCallback);
USER_LOG_INFO("RegisterCoreTrajCallBack ret = %d", returnCode);
s_osalHandler->TaskSleepMs(10000);
while (true) {
if (s_mission_state_machine == 0) {
USER_LOG_INFO("Mission is finished.");
break;
}
s_osalHandler->TaskSleepMs(1000);
}
DjiFlightController_AntiRegisterCoreTrajCallBack();
DjiFlightController_AntiRegisterOpenMisInfoCallBack();
USER_LOG_INFO("Flight control register callback sample end");
DjiTest_WidgetLogAppend("Flight control register callback sample end");
return;
}
T_DjiReturnCode DjiTest_TriggerFtsEventCallback(void)
{
USER_LOG_INFO("Received FTS Trigger event, count = %d.", s_ftsTriggerCount);
@ -899,8 +1061,6 @@ T_DjiReturnCode DjiTest_TriggerFtsEventCallback(void)
USER_LOG_WARN("Note: This is an empty implementation, and the FTS signal needs to be triggered by the PWM signal.");
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
}
void DjiTest_FlightControlPassiveTriggerFtsSample(void)
@ -924,6 +1084,77 @@ void DjiTest_FlightControlPassiveTriggerFtsSample(void)
}
}
static void DjiTest_FlightControlSlowRotateMotorSample(void)
{
E_DjiFlightControllerElectronicSpeedControllerStatus escStatus;
T_DjiReturnCode returnCode = 0;
DjiTest_WidgetLogAppend("Start rotating.");
USER_LOG_INFO("Start rotating.");
returnCode = DjiFlightController_StartSlowRotateMotor();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Start slow rotate blade failed, error code is 0x%08X", returnCode);
return ;
}
returnCode = DjiFlightController_GetElectronicSpeedControllerStatus(&escStatus);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Fail to get ESC status, error code is 0x%08X", returnCode);
}
DjiTest_WidgetLogAppend("ESC status: %s motor(s) rotate mode",
escStatus == DJI_FLIGHT_CONTROLLER_NO_MOTOR_IN_SLOW_ROTATE_MODE ? "no" :
escStatus == DJI_FLIGHT_CONTROLLER_SOME_MOTOR_IN_SLOW_ROTATE_MODE ? "some" :
escStatus == DJI_FLIGHT_CONTROLLER_ALL_MOTOR_IN_SLOW_ROTATE_MODE ? "all" : "(error)");
USER_LOG_INFO("ESC status: %s motor(s) rotate mode",
escStatus == DJI_FLIGHT_CONTROLLER_NO_MOTOR_IN_SLOW_ROTATE_MODE ? "no" :
escStatus == DJI_FLIGHT_CONTROLLER_SOME_MOTOR_IN_SLOW_ROTATE_MODE ? "some" :
escStatus == DJI_FLIGHT_CONTROLLER_ALL_MOTOR_IN_SLOW_ROTATE_MODE ? "all" : "(error)");
for (int32_t i = 0; i < 8; i++) {
s_osalHandler->TaskSleepMs(1000);
returnCode = DjiFlightController_GetElectronicSpeedControllerStatus(&escStatus);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Fail to get ESC status, error code is 0x%08X", returnCode);
}
DjiTest_WidgetLogAppend("ESC status: %s motor(s) rotate mode",
escStatus == DJI_FLIGHT_CONTROLLER_NO_MOTOR_IN_SLOW_ROTATE_MODE ? "no" :
escStatus == DJI_FLIGHT_CONTROLLER_SOME_MOTOR_IN_SLOW_ROTATE_MODE ? "some" :
escStatus == DJI_FLIGHT_CONTROLLER_ALL_MOTOR_IN_SLOW_ROTATE_MODE ? "all" : "(error)");
USER_LOG_INFO("ESC status: %s motor(s) rotate mode",
escStatus == DJI_FLIGHT_CONTROLLER_NO_MOTOR_IN_SLOW_ROTATE_MODE ? "no" :
escStatus == DJI_FLIGHT_CONTROLLER_SOME_MOTOR_IN_SLOW_ROTATE_MODE ? "some" :
escStatus == DJI_FLIGHT_CONTROLLER_ALL_MOTOR_IN_SLOW_ROTATE_MODE ? "all" : "(error)");
}
DjiTest_WidgetLogAppend("Stop rotating.");
USER_LOG_INFO("Stop rotating.");
returnCode = DjiFlightController_StopSlowRotateMotor();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_INFO("Stop slow rotate blade failed, error code is 0x%08X", returnCode);
return ;
}
s_osalHandler->TaskSleepMs(1000);
returnCode = DjiFlightController_GetElectronicSpeedControllerStatus(&escStatus);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Fail to get ESC status, error code is 0x%08X", returnCode);
}
DjiTest_WidgetLogAppend("ESC status: %s motor(s) rotate mode",
escStatus == DJI_FLIGHT_CONTROLLER_NO_MOTOR_IN_SLOW_ROTATE_MODE ? "no" :
escStatus == DJI_FLIGHT_CONTROLLER_SOME_MOTOR_IN_SLOW_ROTATE_MODE ? "some" :
escStatus == DJI_FLIGHT_CONTROLLER_ALL_MOTOR_IN_SLOW_ROTATE_MODE ? "all" : "(error)");
USER_LOG_INFO("ESC status: %s motor(s) rotate mode",
escStatus == DJI_FLIGHT_CONTROLLER_NO_MOTOR_IN_SLOW_ROTATE_MODE ? "no" :
escStatus == DJI_FLIGHT_CONTROLLER_SOME_MOTOR_IN_SLOW_ROTATE_MODE ? "some" :
escStatus == DJI_FLIGHT_CONTROLLER_ALL_MOTOR_IN_SLOW_ROTATE_MODE ? "all" : "(error)");
}
void DjiTest_FlightControlSample(E_DjiTestFlightCtrlSampleSelect flightCtrlSampleSelect)
{
switch (flightCtrlSampleSelect) {
@ -955,6 +1186,18 @@ void DjiTest_FlightControlSample(E_DjiTestFlightCtrlSampleSelect flightCtrlSampl
DjiTest_FlightControlPassiveTriggerFtsSample();
break;
}
case E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_SLOW_ROTATE_BLADE: {
DjiTest_FlightControlSlowRotateMotorSample();
break;
}
case E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_SET_GET_PERCEPTION_PARAM: {
DjiTest_FlightControlSetGetPerceptionParamSample();
break;
}
case E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_SET_CMD_START_MISSION: {
DjiTest_FlightControlSetModeStartMission();
break;
}
default:
break;
}
@ -1304,10 +1547,16 @@ bool DjiTest_FlightControlGoHomeAndConfirmLanding(void)
DjiTest_FlightControlGetValueOfFlightStatus() == DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_IN_AIR) {
T_DjiFcSubscriptionHeightFusion heightFusion = DjiTest_FlightControlGetValueOfHeightFusion();
s_osalHandler->TaskSleepMs(1000);
if (aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3E ||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3T ||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3D ||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3TD) {
if (DJI_AIRCRAFT_TYPE_M3E == aircraftInfoBaseInfo.aircraftType || DJI_AIRCRAFT_TYPE_M3T == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M3D == aircraftInfoBaseInfo.aircraftType || DJI_AIRCRAFT_TYPE_M3TD == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M3TA == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4T == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4TD == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4D == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4E == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4TD == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4D == aircraftInfoBaseInfo.aircraftType
) {
if ((dji_f64_t) 0.45 < heightFusion && heightFusion < (dji_f64_t) 0.55) {
break;
}
@ -1551,60 +1800,123 @@ DjiTest_FlightControlJoystickCtrlAuthSwitchEventCallback(T_DjiFlightControllerJo
switch (eventData.joystickCtrlAuthoritySwitchEvent) {
case DJI_FLIGHT_CONTROLLER_MSDK_GET_JOYSTICK_CTRL_AUTH_EVENT: {
if (eventData.curJoystickCtrlAuthority == DJI_FLIGHT_CONTROLLER_JOYSTICK_CTRL_AUTHORITY_MSDK) {
DjiTest_WidgetLogAppend("Msdk request ctrl authority!");
USER_LOG_INFO("[Event]Msdk request to obtain joystick ctrl authority\r\n");
} else {
DjiTest_WidgetLogAppend("Msdk release ctrl authority!");
USER_LOG_INFO("[Event]Msdk request to release joystick ctrl authority\r\n");
}
break;
}
case DJI_FLIGHT_CONTROLLER_INTERNAL_GET_JOYSTICK_CTRL_AUTH_EVENT: {
if (eventData.curJoystickCtrlAuthority == DJI_FLIGHT_CONTROLLER_JOYSTICK_CTRL_AUTHORITY_INTERNAL) {
DjiTest_WidgetLogAppend("Internal request ctrl authority!");
USER_LOG_INFO("[Event]Internal request to obtain joystick ctrl authority\r\n");
} else {
DjiTest_WidgetLogAppend("Internal release ctrl authority!");
USER_LOG_INFO("[Event]Internal request to release joystick ctrl authority\r\n");
}
break;
}
case DJI_FLIGHT_CONTROLLER_OSDK_GET_JOYSTICK_CTRL_AUTH_EVENT: {
if (eventData.curJoystickCtrlAuthority == DJI_FLIGHT_CONTROLLER_JOYSTICK_CTRL_AUTHORITY_OSDK) {
DjiTest_WidgetLogAppend("request ctrl authority!");
USER_LOG_INFO("[Event] Request to obtain joystick ctrl authority\r\n");
} else {
DjiTest_WidgetLogAppend("release ctrl authority!");
USER_LOG_INFO("[Event] Request to release joystick ctrl authority\r\n");
}
break;
}
case DJI_FLIGHT_CONTROLLER_RC_LOST_GET_JOYSTICK_CTRL_AUTH_EVENT :
DjiTest_WidgetLogAppend("rc lost! reset ctrl authority");
USER_LOG_INFO("[Event]Current joystick ctrl authority is reset to rc due to rc lost\r\n");
break;
case DJI_FLIGHT_CONTROLLER_RC_NOT_P_MODE_RESET_JOYSTICK_CTRL_AUTH_EVENT :
DjiTest_WidgetLogAppend("rc P mode! rc get authority");
USER_LOG_INFO("[Event]Current joystick ctrl authority is reset to rc for rc is not in P mode\r\n");
break;
case DJI_FLIGHT_CONTROLLER_RC_SWITCH_MODE_GET_JOYSTICK_CTRL_AUTH_EVENT :
DjiTest_WidgetLogAppend("rc switching mode! rc get authority");
USER_LOG_INFO("[Event]Current joystick ctrl authority is reset to rc due to rc switching mode\r\n");
break;
case DJI_FLIGHT_CONTROLLER_RC_PAUSE_GET_JOYSTICK_CTRL_AUTH_EVENT :
DjiTest_WidgetLogAppend("rc pausing! rc get authority");
USER_LOG_INFO("[Event]Current joystick ctrl authority is reset to rc due to rc pausing\r\n");
break;
case DJI_FLIGHT_CONTROLLER_RC_REQUEST_GO_HOME_GET_JOYSTICK_CTRL_AUTH_EVENT :
DjiTest_WidgetLogAppend("rc request return! rc get authority");
USER_LOG_INFO("[Event]Current joystick ctrl authority is reset to rc due to rc request for return\r\n");
break;
case DJI_FLIGHT_CONTROLLER_LOW_BATTERY_GO_HOME_RESET_JOYSTICK_CTRL_AUTH_EVENT :
DjiTest_WidgetLogAppend("low battery return! rc get authority");
USER_LOG_INFO("[Event]Current joystick ctrl authority is reset to rc for low battery return\r\n");
break;
case DJI_FLIGHT_CONTROLLER_LOW_BATTERY_LANDING_RESET_JOYSTICK_CTRL_AUTH_EVENT :
DjiTest_WidgetLogAppend("low battery land! rc get authority");
USER_LOG_INFO("[Event]Current joystick ctrl authority is reset to rc for low battery land\r\n");
break;
case DJI_FLIGHT_CONTROLLER_OSDK_LOST_GET_JOYSTICK_CTRL_AUTH_EVENT:
DjiTest_WidgetLogAppend("sdk lost! rc get authority");
USER_LOG_INFO("[Event]Current joystick ctrl authority is reset to rc due to sdk lost\r\n");
break;
case DJI_FLIGHT_CONTROLLER_NERA_FLIGHT_BOUNDARY_RESET_JOYSTICK_CTRL_AUTH_EVENT :
DjiTest_WidgetLogAppend("near boundary! rc get authority");
USER_LOG_INFO("[Event]Current joystick ctrl authority is reset to rc due to near boundary\r\n");
break;
case DJI_FLIGHT_CONTROLLER_DOCK_REQUEST_CHANGE_JOYSTICK_CTRL_AUTH_EVENT :
DjiTest_WidgetLogAppend("dock request! dock get authority");
USER_LOG_INFO("[Event]Current joystick ctrl authority is change due to the dock request\r\n");
break;
default:
DjiTest_WidgetLogAppend("Unknown ctrl authority event");
USER_LOG_INFO("[Event]Unknown joystick ctrl authority event\r\n");
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_DjiReturnCode DjiTest_SetFtsTrigger(E_DjiMountPosition position, const char* desc)
{
T_DjiReturnCode djiStat;
T_DjiFtsPwmEscTriggerStatus esc_status;
djiStat = DjiFts_SelectFtsPwmTrigger(position);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("select fts pwm trigger E-PORT error, error code: 0x%08X", djiStat);
return djiStat;
}
djiStat = DjiFts_GetFtsPwmTriggerStatus(&esc_status);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get pwm trigger status error, error code: 0x%08X", djiStat);
return djiStat;
}
if (esc_status.ESC[0].fts_select != position || esc_status.ESC[1].fts_select != position)
{
USER_LOG_ERROR("pwm trigger status incorrect");
return djiStat;
}
if (esc_status.ESC[0].fts_status == DJI_FLIGHT_CONTROLLER_FTS_NOT_TRIGGERD && esc_status.ESC[1].fts_status == DJI_FLIGHT_CONTROLLER_FTS_NOT_TRIGGERD)
USER_LOG_INFO("Set fts trigger position %s success", desc);
return djiStat;
}
T_DjiReturnCode DjiTest_FtsPwmTriggerSample(E_DjiMountPosition position, const char* port_name)
{
T_DjiReturnCode returnCode;
returnCode = DjiTest_SetFtsTrigger(position, port_name);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Test select %s fts pwm trigger failed", port_name);
return returnCode;
}
return returnCode;
}
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/

View File

@ -43,6 +43,9 @@ typedef enum {
E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_ARREST_FLYING,
E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_SET_GET_PARAM,
E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_FTS_TRIGGER,
E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_SLOW_ROTATE_BLADE,
E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_SET_GET_PERCEPTION_PARAM,
E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_SET_CMD_START_MISSION,
} E_DjiTestFlightCtrlSampleSelect;
#pragma pack(1)
@ -59,6 +62,7 @@ typedef struct {
T_DjiReturnCode DjiTest_FlightControlRunSample(E_DjiTestFlightCtrlSampleSelect flightCtrlSampleSelect);
void DjiTest_FlightControlVelocityAndYawRateCtrl(const T_DjiTestFlightControlVector3f offsetDesired, float yawRate,
uint32_t timeMs);
T_DjiReturnCode DjiTest_FtsPwmTriggerSample(E_DjiMountPosition position, const char* port_name);
#ifdef __cplusplus
}

View File

@ -30,6 +30,7 @@
#include "dji_logger.h"
#include "dji_platform.h"
#include "utils/util_misc.h"
#include "widget_interaction_test/test_widget_interaction.h"
/* Private constants ---------------------------------------------------------*/
#define PAYLOAD_GIMBAL_EMU_TASK_STACK_SIZE (2048)
@ -237,6 +238,8 @@ T_DjiReturnCode DjiTest_GimbalRotate(E_DjiGimbalRotationMode rotationMode,
case DJI_GIMBAL_ROTATION_MODE_RELATIVE_ANGLE:
USER_LOG_INFO("gimbal relative rotate angle: pitch %d, roll %d, yaw %d.", rotationValue.pitch,
rotationValue.roll, rotationValue.yaw);
DjiTest_WidgetLogAppend("relative mod: pitch %d, roll %d, yaw %d.", rotationValue.pitch,
rotationValue.roll, rotationValue.yaw);
USER_LOG_DEBUG("gimbal relative rotate action time: %d.",
rotationProperty.relativeAngleRotation.actionTime);
@ -277,6 +280,7 @@ T_DjiReturnCode DjiTest_GimbalRotate(E_DjiGimbalRotationMode rotationMode,
break;
case DJI_GIMBAL_ROTATION_MODE_ABSOLUTE_ANGLE:
DjiTest_WidgetLogAppend("abs mode (%d %d %d)", rotationValue.pitch, rotationValue.roll, rotationValue.yaw);
USER_LOG_INFO("gimbal absolute rotate angle: pitch %d, roll %d, yaw %d.", rotationValue.pitch,
rotationValue.roll, rotationValue.yaw);
USER_LOG_DEBUG("gimbal absolute rotate action time: %d.",
@ -325,6 +329,7 @@ T_DjiReturnCode DjiTest_GimbalRotate(E_DjiGimbalRotationMode rotationMode,
break;
case DJI_GIMBAL_ROTATION_MODE_SPEED:
DjiTest_WidgetLogAppend("speed mode (%d %d %d)", rotationValue.pitch, rotationValue.roll, rotationValue.yaw);
USER_LOG_INFO("gimbal rotate speed: pitch %d, roll %d, yaw %d.", rotationValue.pitch,
rotationValue.roll, rotationValue.yaw);
@ -696,6 +701,7 @@ static T_DjiReturnCode StartCalibrate(void)
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
DjiTest_WidgetLogAppend("calibrate gimbal.");
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
@ -721,6 +727,7 @@ static T_DjiReturnCode SetControllerSmoothFactor(uint8_t smoothingFactor, E_DjiG
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
DjiTest_WidgetLogAppend("set smooth factor: factor %d, axis %d.", smoothingFactor, axis);
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
@ -741,6 +748,7 @@ static T_DjiReturnCode SetPitchRangeExtensionEnabled(bool enabledFlag)
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
DjiTest_WidgetLogAppend("set gimbal pitch range extension enable: %d.", enabledFlag);
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
@ -767,6 +775,7 @@ static T_DjiReturnCode SetControllerMaxSpeedPercentage(uint8_t maxSpeedPercentag
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
DjiTest_WidgetLogAppend("set gimbal max speed: %d, axis %d.", maxSpeedPercentage, axis);
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
@ -793,6 +802,8 @@ static T_DjiReturnCode RestoreFactorySettings(void)
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
DjiTest_WidgetLogAppend("restore gimbal factory settings.");
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
@ -814,6 +825,8 @@ static T_DjiReturnCode SetMode(E_DjiGimbalMode mode)
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
DjiTest_WidgetLogAppend("set gimbal mode: %d.", mode);
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
@ -895,6 +908,8 @@ unlock2:
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
DjiTest_WidgetLogAppend("reset gimbal: %d.", mode);
return djiReturnCode;
}
@ -968,6 +983,8 @@ unlock:
return DJI_ERROR_SYSTEM_MODULE_CODE_OUT_OF_RANGE;
}
DjiTest_WidgetLogAppend("gimbal fine tune angle: pitch %d, roll %d, yaw %d.", fineTuneAngle.pitch,
fineTuneAngle.roll, fineTuneAngle.yaw);
return djiReturnCode;
}

View File

@ -77,6 +77,7 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
T_DjiGimbalManagerRotation rotation;
T_DjiAircraftInfoBaseInfo baseInfo;
E_DjiAircraftSeries aircraftSeries;
bool gimbalAnglesSubscribedFlag = false;
returnCode = DjiAircraftInfo_GetBaseInfo(&baseInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -89,10 +90,17 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
USER_LOG_INFO("Gimbal manager sample start");
DjiTest_WidgetLogAppend("Gimbal manager sample start");
returnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES, DJI_DATA_SUBSCRIPTION_TOPIC_50_HZ, NULL);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Failed to subscribe topic %d, 0x%08X", DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES, returnCode);
goto out;
if (DJI_AIRCRAFT_SERIES_M30 == aircraftSeries ||
DJI_AIRCRAFT_SERIES_M3 == aircraftSeries ||
DJI_AIRCRAFT_SERIES_M3D == aircraftSeries ||
DJI_AIRCRAFT_SERIES_M4 == aircraftSeries ||
DJI_AIRCRAFT_SERIES_M4D == aircraftSeries) {
returnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES, DJI_DATA_SUBSCRIPTION_TOPIC_50_HZ, NULL);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Failed to subscribe topic %d, 0x%08X", DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES, returnCode);
goto out;
}
gimbalAnglesSubscribedFlag = true;
}
USER_LOG_INFO("--> Step 1: Init gimbal manager module");
@ -140,8 +148,12 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
rotation = s_rotationActionList[i].rotation;
if (aircraftSeries == DJI_AIRCRAFT_SERIES_M3 || aircraftSeries == DJI_AIRCRAFT_SERIES_M30
|| aircraftSeries == DJI_AIRCRAFT_SERIES_M3D) {
if (DJI_AIRCRAFT_SERIES_M30 == aircraftSeries
|| DJI_AIRCRAFT_SERIES_M3 == aircraftSeries
|| DJI_AIRCRAFT_SERIES_M3D == aircraftSeries
|| DJI_AIRCRAFT_SERIES_M4 == aircraftSeries
|| DJI_AIRCRAFT_SERIES_M4D == aircraftSeries
) {
if (s_rotationActionList[i].rotation.rotationMode == DJI_GIMBAL_ROTATION_MODE_ABSOLUTE_ANGLE) {
T_DjiFcSubscriptionGimbalAngles gimbalAngles = {0};
T_DjiDataTimestamp timestamp = {0};
@ -166,9 +178,12 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
}
}
returnCode = DjiFcSubscription_UnSubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Failed to unsubscribe topic %d, 0x%08X", DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES, returnCode);
if (gimbalAnglesSubscribedFlag) {
returnCode = DjiFcSubscription_UnSubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Failed to unsubscribe topic %d, 0x%08X", DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES, returnCode);
}
gimbalAnglesSubscribedFlag = false;
}
USER_LOG_INFO("--> Step 5: Deinit gimbal manager module");

View File

@ -61,13 +61,13 @@
{
"hms_error_code": "0x1E020004",
"hms_interface": {
"message_title": "HMS测试文案: 我是错误码标题4",
"message_content": "HMS测试文案: 我是错误码内容4"
"message_title": "负载网络较差",
"message_content": "请检查飞行器周围网络或关闭增强图传"
},
"fpv_interface": {
"message_on_the_ground": "HMS测试文案: 我在地面发生了错误4",
"message_on_the_ground": "负载网络较差,请检查飞行器周围网络或关闭增强图传",
"is_keep_history_on_the_ground": true,
"message_in_the_sky": "HMS测试文案: 我在空中发生了错误4",
"message_in_the_sky": "负载网络较差,请检查飞行器周围网络或关闭增强图传",
"is_keep_history_in_the_sky": true
}
}

View File

@ -61,13 +61,13 @@
{
"hms_error_code": "0x1E020004",
"hms_interface": {
"message_title": "HMS test text: I am error code Title 4",
"message_content": "HMS test text: I am error code Content 4"
"message_title": "Payload Network Poor",
"message_content": "Please check the network around the aircraft or disable Enhanced Transmission"
},
"fpv_interface": {
"message_on_the_ground": "HMS test text: I got error on the ground 4",
"message_on_the_ground": "Payload network is poor. Please check the network around the aircraft or disable Enhanced Transmission",
"is_keep_history_on_the_ground": true,
"message_in_the_sky": "HMS test text: I got error in the sky 4",
"message_in_the_sky": "Payload network is poor. Please check the network around the aircraft or disable Enhanced Transmission",
"is_keep_history_in_the_sky": true
}
}

View File

@ -43,7 +43,11 @@
#define MAX_HMS_ERROR_LEVEL (6)
#define HMS_DIR_PATH_LEN_MAX (256)
#ifdef SYSTEM_ARCH_LINUX
#define DJI_CUSTOM_HMS_CODE_INJECT_ON (0)
#else
#define DJI_CUSTOM_HMS_CODE_INJECT_ON (1)
#endif
/* Private types -------------------------------------------------------------*/
@ -51,11 +55,17 @@
static const char *oldReplaceAlarmIdStr = "%alarmid";
static const char *oldReplaceIndexStr = "%index";
static const char *oldReplaceComponentIndexStr = "%component_index";
static bool isHmsManagerInit = false;
static T_DjiHmsFileBinaryArray s_EnHmsTextConfigFileBinaryArrayList[] = {
{hms_text_config_json_fileName, hms_text_config_json_fileSize, hms_text_config_json_fileBinaryArray},
};
#ifdef SYSTEM_ARCH_LINUX
static uint8_t *s_hmsJsonData = NULL;
static T_DjiMutexHandle s_hmsJsonDataMutex = {0};
#endif
static E_DjiMobileAppLanguage s_hmsLanguage = DJI_MOBILE_APP_LANGUAGE_ENGLISH;
static bool s_isHmsConfigFileDirPathConfigured = false;
static char s_hmsConfigFileDirPath[DJI_FILE_PATH_SIZE_MAX] = {0};
/* Private functions declaration ---------------------------------------------*/
static T_DjiReturnCode DjiTest_HmsManagerInit(void);
@ -63,7 +73,9 @@ static T_DjiReturnCode DjiTest_HmsManagerDeInit(void);
static T_DjiFcSubscriptionFlightStatus DjiTest_GetValueOfFlightStatus(void);
static bool DjiTest_ReplaceStr(char *buffer, uint32_t bufferMaxLen, const char *target, const char *dest);
static bool DjiTest_MarchErrCodeInfoTable(T_DjiHmsInfoTable hmsInfoTable);
#ifdef SYSTEM_ARCH_LINUX
static bool DjiTest_MarchErrCodeInfoTableByJson(T_DjiHmsInfoTable hmsInfoTable);
#endif
static T_DjiReturnCode DjiTest_HmsInfoCallback(T_DjiHmsInfoTable hmsInfoTable);
/* Exported functions definition ---------------------------------------------*/
@ -86,6 +98,7 @@ T_DjiReturnCode DjiTest_HmsManagerRunSample(E_DjiMobileAppLanguage language)
}
osalHandler = DjiPlatform_GetOsalHandler();
USER_LOG_INFO("--> Step 2: Register callback function of push HMS information");
DjiTest_WidgetLogAppend("--> Step 2: Register callback function of push HMS information");
returnCode = DjiHmsManager_RegHmsInfoCallback(DjiTest_HmsInfoCallback);
@ -132,7 +145,11 @@ T_DjiReturnCode DjiTest_HmsCustomizationStartService(void)
return returnCode;
}
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/en", curFileDirPath);
if (s_isHmsConfigFileDirPathConfigured == true) {
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/en", s_hmsConfigFileDirPath);
} else {
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/en", curFileDirPath);
}
//set default hms text config path
returnCode = DjiHmsCustomization_RegDefaultHmsTextConfigByDirPath(tempPath);
@ -150,7 +167,12 @@ T_DjiReturnCode DjiTest_HmsCustomizationStartService(void)
}
//set hms text config for Chinese language
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/cn", curFileDirPath);
if (s_isHmsConfigFileDirPathConfigured == true) {
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/cn", s_hmsConfigFileDirPath);
} else {
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/cn", curFileDirPath);
}
returnCode = DjiHmsCustomization_RegHmsTextConfigByDirPath(DJI_MOBILE_APP_LANGUAGE_CHINESE,
tempPath);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -174,21 +196,40 @@ T_DjiReturnCode DjiTest_HmsCustomizationStartService(void)
#if DJI_CUSTOM_HMS_CODE_INJECT_ON
DjiHmsCustomization_InjectHmsErrorCode(0x1E020000, DJI_HMS_ERROR_LEVEL_FATAL);
DjiHmsCustomization_InjectHmsErrorCode(0x1E020001, DJI_HMS_ERROR_LEVEL_CRITICAL);
DjiHmsCustomization_InjectHmsErrorCode(0x1E020002, DJI_HMS_ERROR_LEVEL_WARN);
DjiHmsCustomization_InjectHmsErrorCode(0x1E020003, DJI_HMS_ERROR_LEVEL_HINT);
#endif
return returnCode;
}
T_DjiReturnCode DjiTest_HmsCustomizationSetConfigFilePath(const char *path)
{
memset(s_hmsConfigFileDirPath, 0, sizeof(s_hmsConfigFileDirPath));
memcpy(s_hmsConfigFileDirPath, path, USER_UTIL_MIN(strlen(path), sizeof(s_hmsConfigFileDirPath) - 1));
s_isHmsConfigFileDirPathConfigured = true;
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
/* Private functions definition-----------------------------------------------*/
static T_DjiReturnCode DjiTest_HmsManagerInit(void)
{
T_DjiReturnCode returnCode;
#ifdef SYSTEM_ARCH_LINUX
char curFileDirPath[HMS_DIR_PATH_LEN_MAX];
char tempFileDirPath[HMS_DIR_PATH_LEN_MAX];
uint32_t fileSize = 0;
uint32_t readRealSize = 0;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
returnCode = osalHandler->MutexCreate(&s_hmsJsonDataMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Create mutex error: 0x%08llX.", returnCode);
return returnCode;
}
#endif
returnCode = DjiFcSubscription_Init();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Hms sample init data subscription module failed, error code:0x%08llX", returnCode);
@ -199,13 +240,13 @@ static T_DjiReturnCode DjiTest_HmsManagerInit(void)
returnCode = DjiFcSubscription_SubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_STATUS_FLIGHT,
DJI_DATA_SUBSCRIPTION_TOPIC_10_HZ,
NULL);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("HMS sample subscribe topic flight status error, error code:0x%08llX", returnCode);
return returnCode;
}
#ifdef SYSTEM_ARCH_LINUX
returnCode = DjiUserUtil_GetCurrentFileDirPath(__FILE__, HMS_DIR_PATH_LEN_MAX, curFileDirPath);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get file current path error, stat = 0x%08llX", returnCode);
@ -230,13 +271,17 @@ static T_DjiReturnCode DjiTest_HmsManagerInit(void)
UtilFile_GetFileDataByPath(tempFileDirPath, 0, fileSize, s_hmsJsonData, &readRealSize);
#endif
isHmsManagerInit = true;
return DjiHmsManager_Init();
}
static T_DjiReturnCode DjiTest_HmsManagerDeInit(void)
{
T_DjiReturnCode returnCode;
#ifdef SYSTEM_ARCH_LINUX
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
#endif
returnCode = DjiFcSubscription_DeInit();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -246,9 +291,19 @@ static T_DjiReturnCode DjiTest_HmsManagerDeInit(void)
}
#ifdef SYSTEM_ARCH_LINUX
osalHandler->MutexLock(s_hmsJsonDataMutex);
osalHandler->Free(s_hmsJsonData);
s_hmsJsonData = NULL;
osalHandler->MutexUnlock(s_hmsJsonDataMutex);
returnCode = osalHandler->MutexDestroy(s_hmsJsonDataMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Destroy mutex error: 0x%08llX.", returnCode);
}
#endif
isHmsManagerInit = false;
return DjiHmsManager_DeInit();
}
@ -258,6 +313,10 @@ static T_DjiFcSubscriptionFlightStatus DjiTest_GetValueOfFlightStatus(void)
T_DjiFcSubscriptionFlightStatus flightStatus;
T_DjiDataTimestamp flightStatusTimestamp = {0};
if (isHmsManagerInit == false) {
return DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_ON_GROUND;
}
returnCode = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_STATUS_FLIGHT,
(uint8_t *) &flightStatus,
sizeof(T_DjiFcSubscriptionFlightStatus),
@ -357,17 +416,29 @@ static bool DjiTest_MarchErrCodeInfoTable(T_DjiHmsInfoTable hmsInfoTable)
return true;
}
#ifdef SYSTEM_ARCH_LINUX
static bool DjiTest_MarchErrCodeInfoTableByJson(T_DjiHmsInfoTable hmsInfoTable)
{
cJSON *hmsJsonRoot = NULL;
cJSON *hmsErrorCode = NULL;
cJSON *hmsLanguage = NULL;
char alarmIdStr[20] = {0};
char sensorIdStr[20] = {0};
char componentIdStr[20] = {0};
char printBuff[256] = {0};
char hmsErrorCodeString[HMS_DIR_PATH_LEN_MAX] = {0};
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
osalHandler->MutexLock(s_hmsJsonDataMutex);
if (s_hmsJsonData == NULL) {
return 0;
}
hmsJsonRoot = cJSON_Parse((char *) s_hmsJsonData);
if (hmsJsonRoot == NULL) {
return 0;
}
osalHandler->MutexUnlock(s_hmsJsonDataMutex);
for (int i = 0; i < hmsInfoTable.hmsInfoNum; i++) {
if (DjiTest_GetValueOfFlightStatus() == DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_IN_AIR) {
@ -388,14 +459,22 @@ static bool DjiTest_MarchErrCodeInfoTableByJson(T_DjiHmsInfoTable hmsInfoTable)
hmsLanguage = cJSON_GetObjectItem(hmsErrorCode, "fr");
}
if (hmsLanguage != NULL) {
snprintf(alarmIdStr, sizeof(alarmIdStr), "%u", hmsInfoTable.hmsInfo[i].errorCode);
snprintf(sensorIdStr, sizeof(sensorIdStr), "%d", hmsInfoTable.hmsInfo[i].componentIndex + 1);
snprintf(componentIdStr, sizeof(componentIdStr), "0x%02X", hmsInfoTable.hmsInfo[i].componentIndex + 1);
snprintf(printBuff, sizeof(printBuff), "%s", hmsLanguage->valuestring);
DjiTest_ReplaceStr(printBuff, sizeof(printBuff), oldReplaceAlarmIdStr, alarmIdStr);
DjiTest_ReplaceStr(printBuff, sizeof(printBuff), oldReplaceIndexStr, sensorIdStr);
DjiTest_ReplaceStr(printBuff, sizeof(printBuff), oldReplaceComponentIndexStr, componentIdStr);
if (hmsInfoTable.hmsInfo[i].errorLevel > MIN_HMS_ERROR_LEVEL &&
hmsInfoTable.hmsInfo[i].errorLevel < MID_HMS_ERROR_LEVEL) {
USER_LOG_WARN("[ErrorCode: 0x%2x]: %s", hmsInfoTable.hmsInfo[i].errorCode,
hmsLanguage->valuestring);
printBuff);
} else if (hmsInfoTable.hmsInfo[i].errorLevel >= MID_HMS_ERROR_LEVEL &&
hmsInfoTable.hmsInfo[i].errorLevel < MAX_HMS_ERROR_LEVEL) {
USER_LOG_ERROR("[ErrorCode: 0x%2x]: %s", hmsInfoTable.hmsInfo[i].errorCode,
hmsLanguage->valuestring);
printBuff);
}
} else {
USER_LOG_WARN("[ErrorCode: 0x%2x] There are no matching documents for this language for now.",
@ -409,6 +488,7 @@ static bool DjiTest_MarchErrCodeInfoTableByJson(T_DjiHmsInfoTable hmsInfoTable)
cJSON_Delete(hmsJsonRoot);
}
#endif
static T_DjiReturnCode DjiTest_HmsInfoCallback(T_DjiHmsInfoTable hmsInfoTable)
{

View File

@ -41,6 +41,7 @@ extern "C" {
/* Exported functions --------------------------------------------------------*/
T_DjiReturnCode DjiTest_HmsManagerRunSample(E_DjiMobileAppLanguage language);
T_DjiReturnCode DjiTest_HmsCustomizationStartService(void);
T_DjiReturnCode DjiTest_HmsCustomizationSetConfigFilePath(const char *path);
#ifdef __cplusplus
}

View File

@ -28,6 +28,7 @@
#include "dji_logger.h"
#include "dji_flight_controller.h"
#include "flight_control/test_flight_control.h"
#include "dji_aircraft_info.h"
/* Private constants ---------------------------------------------------------*/
@ -45,11 +46,18 @@ T_DjiReturnCode DjiTest_InterestPointRunSample(void)
T_DjiInterestPointSettings interestPointSettings = {0};
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
T_DjiFlightControllerRidInfo ridInfo = {0};
T_DjiAircraftInfoBaseInfo aircraftInfoBaseInfo = {0};
ridInfo.latitude = 22.542812;
ridInfo.longitude = 113.958902;
ridInfo.altitude = 10;
returnCode = DjiAircraftInfo_GetBaseInfo(&aircraftInfoBaseInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get aircraft base info error");
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
}
returnCode = DjiFlightController_Init(ridInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Flight control init failed, errno=%lld", returnCode);
@ -59,7 +67,7 @@ T_DjiReturnCode DjiTest_InterestPointRunSample(void)
returnCode = DjiInterestPoint_Init();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Point interest init failed, errno=%lld", returnCode);
return returnCode;
goto controller_deinit;
}
osalHandler->TaskSleepMs(1000);
@ -74,55 +82,70 @@ T_DjiReturnCode DjiTest_InterestPointRunSample(void)
osalHandler->TaskSleepMs(1000);
DjiTest_FlightControlVelocityAndYawRateCtrl((T_DjiTestFlightControlVector3f) {3, 0, 0}, 0, 5000);
interestPointSettings.latitude = 22.542812;
interestPointSettings.longitude = 113.958902;
interestPointSettings.latitude = 22.57775;
interestPointSettings.longitude = 113.94265;
returnCode = DjiInterestPoint_RegMissionStateCallback(DjiUser_InterestPointMissionStateCallback);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Register mission state callback failed, errno=%lld", returnCode);
return returnCode;
goto point_deinit;
}
if (aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M400) {
interestPointSettings.payloadCameraIndex = 1;
USER_LOG_INFO("The sample try to use payload camera on position %d for poi, please make sure that DJI camera mounted on this position.",
interestPointSettings.payloadCameraIndex);
}
USER_LOG_INFO("Start interest point circle, circumcenter(%f, %f)", interestPointSettings.latitude, interestPointSettings.longitude);
returnCode = DjiInterestPoint_Start(interestPointSettings);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Point interest start failed, errno=%lld", returnCode);
return returnCode;
goto point_deinit;
}
DjiInterestPoint_SetSpeed(5.0f);
osalHandler->TaskSleepMs(1000);
USER_LOG_INFO("set speed to 15");
DjiInterestPoint_SetSpeed(15.0f);
for (int i = 0; i < 60; ++i) {
USER_LOG_INFO("Interest point mission running %d.", i);
osalHandler->TaskSleepMs(1000);
}
USER_LOG_INFO("Stop interest point circle");
returnCode = DjiInterestPoint_Stop();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Point interest stop failed, errno=%lld", returnCode);
return returnCode;
}
point_deinit:
USER_LOG_INFO("Force landing");
DjiFlightController_StartForceLanding();
returnCode = DjiInterestPoint_DeInit();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Point interest deinit failed, errno=%lld", returnCode);
return returnCode;
}
controller_deinit:
returnCode = DjiFlightController_DeInit();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Flight control init failed, errno=%lld", returnCode);
return returnCode;
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
return returnCode;
}
/* Private functions definition-----------------------------------------------*/
static T_DjiReturnCode DjiUser_InterestPointMissionStateCallback(T_DjiInterestPointMissionState missionState)
{
USER_LOG_INFO("Interest point state: %d, radius: %.2f m, speed: %.2f m/s", missionState.state, missionState.radius,
USER_LOG_INFO("Interest point state: %s, radius: %.2f m, speed: %.2f m/s",
missionState.state == DJI_INTEREST_POINT_MISSION_ACTION_STATE_NOT_STARTED ? "not started" :
missionState.state == DJI_INTEREST_POINT_MISSION_ACTION_STATE_PAUSE ? "pause" :
missionState.state == DJI_INTEREST_POINT_MISSION_ACTION_STATE_RUNNING ? "running" : "unknown",
missionState.radius,
missionState.curSpeed);
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;

View File

@ -52,6 +52,23 @@ static void DjiTest_PayloadCameraStreamCallback(E_DjiLiveViewCameraPosition posi
uint32_t bufLen);
/* Exported functions definition ---------------------------------------------*/
void DjiTest_LiveviewSample(void)
{
int pos;
do {
printf("Please enter the camera mount position (valid values: 1 or 2): ");
scanf("%d", &pos);
if (pos != 1 && pos != 2) {
printf("Invalid input, please enter 1 or 2.\n");
}
} while (pos != 1 && pos != 2);
DjiTest_LiveviewRunSample((E_DjiMountPosition)pos);
}
T_DjiReturnCode DjiTest_LiveviewRunSample(E_DjiMountPosition mountPosition)
{
T_DjiReturnCode returnCode;
@ -77,12 +94,13 @@ T_DjiReturnCode DjiTest_LiveviewRunSample(E_DjiMountPosition mountPosition)
goto out;
}
USER_LOG_INFO("--> Step 2: Start h264 stream of the fpv and selected payload\r\n");
USER_LOG_INFO("--> Step 2: Start h264 stream of the fpv and default of selected payload\r\n");
DjiTest_WidgetLogAppend("--> Step 2: Start h264 stream of the fpv and selected payload\r\n");
if (aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M300 ||
aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M350 ||
aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M30) {
aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M30 ||
aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M400) {
localTime = localtime(&currentTime);
sprintf(s_fpvCameraStreamFilePath, "fpv_stream_%04d%02d%02d_%02d-%02d-%02d.h264",
@ -97,8 +115,23 @@ T_DjiReturnCode DjiTest_LiveviewRunSample(E_DjiMountPosition mountPosition)
}
}
if (aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M400
&& aircraftInfoBaseInfo.mountPositionType == DJI_MOUNT_POSITION_TYPE_MANIFOLD3_ONBOARD)
{
// XXX: On MANIFOLD3, FPV and MAIN CAMERA SOURCE_DEFAULT streams cannot be subscribed to at the same time.
for (int i = 0; i < TEST_LIVEVIEW_STREAM_STROING_TIME_IN_SECONDS; ++i) {
USER_LOG_INFO("Storing camera h264 stream, second: %d.", i + 1);
osalHandler->TaskSleepMs(1000);
}
returnCode = DjiLiveview_StopH264Stream(DJI_LIVEVIEW_CAMERA_POSITION_FPV, DJI_LIVEVIEW_CAMERA_SOURCE_DEFAULT);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Request to stop h264 of fpv failed, error code: 0x%08X", returnCode);
goto out;
}
}
localTime = localtime(&currentTime);
sprintf(s_payloadCameraStreamFilePath, "payload%d_vis_stream_%04d%02d%02d_%02d-%02d-%02d.h264",
sprintf(s_payloadCameraStreamFilePath, "payload%d_default_stream_%04d%02d%02d_%02d-%02d-%02d.h264",
mountPosition, localTime->tm_year + 1900, localTime->tm_mon + 1, localTime->tm_mday,
localTime->tm_hour, localTime->tm_min, localTime->tm_sec);
@ -112,12 +145,17 @@ T_DjiReturnCode DjiTest_LiveviewRunSample(E_DjiMountPosition mountPosition)
for (int i = 0; i < TEST_LIVEVIEW_STREAM_STROING_TIME_IN_SECONDS; ++i) {
USER_LOG_INFO("Storing camera h264 stream, second: %d.", i + 1);
#if TEST_LIVEVIEW_STREAM_REQUEST_I_FRAME_ON
if (i % TEST_LIVEVIEW_STREAM_REQUEST_I_FRAME_TICK_IN_SECONDS == 0) {
returnCode = DjiLiveview_RequestIntraframeFrameData((E_DjiLiveViewCameraPosition) mountPosition,
DJI_LIVEVIEW_CAMERA_SOURCE_DEFAULT);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Request stream I frame of payload %d failed, error code: 0x%08X", mountPosition,
returnCode);
if (aircraftInfoBaseInfo.mountPositionType != DJI_MOUNT_POSITION_TYPE_MANIFOLD3_ONBOARD)
{
if (i % TEST_LIVEVIEW_STREAM_REQUEST_I_FRAME_TICK_IN_SECONDS == 0)
{
returnCode = DjiLiveview_RequestIntraframeFrameData((E_DjiLiveViewCameraPosition)mountPosition,
DJI_LIVEVIEW_CAMERA_SOURCE_DEFAULT);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
USER_LOG_ERROR("Request stream I frame of payload %d failed, error code: 0x%08X", mountPosition,
returnCode);
}
}
}
#endif
@ -128,7 +166,9 @@ T_DjiReturnCode DjiTest_LiveviewRunSample(E_DjiMountPosition mountPosition)
DjiTest_WidgetLogAppend("--> Step 3: Stop h264 stream of the fpv and selected payload");
if (aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M300 ||
aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M350 ||
aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M30) {
aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M30 ||
(aircraftInfoBaseInfo.aircraftSeries == DJI_AIRCRAFT_SERIES_M400
&& aircraftInfoBaseInfo.mountPositionType != DJI_MOUNT_POSITION_TYPE_MANIFOLD3_ONBOARD)) {
returnCode = DjiLiveview_StopH264Stream(DJI_LIVEVIEW_CAMERA_POSITION_FPV, DJI_LIVEVIEW_CAMERA_SOURCE_DEFAULT);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Request to stop h264 of fpv failed, error code: 0x%08X", returnCode);
@ -143,11 +183,12 @@ T_DjiReturnCode DjiTest_LiveviewRunSample(E_DjiMountPosition mountPosition)
goto out;
}
USER_LOG_INFO("Fpv stream is saved to file: %s", s_fpvCameraStreamFilePath);
USER_LOG_INFO("Payload%d stream is saved to file: %s\r\n", mountPosition, s_payloadCameraStreamFilePath);
if (aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3T ||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3TD) {
if (DJI_AIRCRAFT_TYPE_M3T == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M3TA == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M3TD == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4T == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4TD == aircraftInfoBaseInfo.aircraftType
) {
USER_LOG_INFO("--> Start h264 stream of the fpv and selected payload\r\n");
localTime = localtime(&currentTime);

View File

@ -39,6 +39,7 @@ extern "C" {
/* Exported types ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
void DjiTest_LiveviewSample(void);
T_DjiReturnCode DjiTest_LiveviewRunSample(E_DjiMountPosition mountPosition);
#ifdef __cplusplus

View File

@ -180,7 +180,7 @@ REWAIT:
}
sendDataCount++;
memset(sendBuf, sendDataCount, TEST_MOP_CHANNEL_NORMAL_TRANSFOR_SEND_BUFFER);
memset(sendBuf, 'A' - 1 + (sendDataCount % 26), TEST_MOP_CHANNEL_NORMAL_TRANSFOR_SEND_BUFFER);
returnCode = DjiMopChannel_SendData(s_testMopChannelNormalOutHandle, sendBuf,
TEST_MOP_CHANNEL_NORMAL_TRANSFOR_SEND_BUFFER, &realLen);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -723,6 +723,8 @@ static void *DjiTest_MopChannelFileServiceRecvTask(void *arg)
s_fileServiceContent[clientNum].uploadState = MOP_FILE_SERVICE_UPLOAD_DATA_SENDING;
s_fileServiceContent[clientNum].uploadSeqNum = fileTransfor->seqNum;
USER_LOG_INFO("fileTransfor->seqNum %d", fileTransfor->seqNum);
uploadWriteLen = fwrite(&recvBuf[UTIL_OFFSETOF(T_DjiMopChannel_FileTransfor, data)], 1,
fileTransfor->dataLen, uploadFile);
if (uploadWriteLen < 0) {

View File

@ -65,7 +65,7 @@ T_DjiReturnCode DjiTest_PerceptionRunSample(E_DjiPerceptionDirection direction)
DjiTest_WidgetLogAppend("Perception sample start");
USER_LOG_INFO("--> Step 1: Init Perception module");
DjiTest_WidgetLogAppend("--> Step 1: Init Perception module");
DjiTest_WidgetLogAppend("Step 1: Init Perception module");
returnCode = DjiPerception_Init();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Perception init failed, error code: 0x%08X", returnCode);
@ -75,7 +75,7 @@ T_DjiReturnCode DjiTest_PerceptionRunSample(E_DjiPerceptionDirection direction)
s_perceptionImageCount = 0;
USER_LOG_INFO("--> Step 2: Get stereo camera parameters\r\n");
DjiTest_WidgetLogAppend("--> Step 2: Get stereo camera parameters\r\n");
DjiTest_WidgetLogAppend("Step 2: Get stereo camera parameters\r\n");
returnCode = DjiPerception_GetStereoCameraParameters(&cameraParametersetersPacket);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get stereo camera parameters failed, error code: 0x%08X", returnCode);
@ -95,6 +95,8 @@ T_DjiReturnCode DjiTest_PerceptionRunSample(E_DjiPerceptionDirection direction)
cameraParametersetersPacket.cameraParameters[i].leftIntrinsics[6],
cameraParametersetersPacket.cameraParameters[i].leftIntrinsics[7],
cameraParametersetersPacket.cameraParameters[i].leftIntrinsics[8]);
DjiTest_WidgetLogAppend("rcv [%-05s] leftIntrinsics ",
directionName[cameraParametersetersPacket.cameraParameters[i].direction].name);
USER_LOG_INFO("[%-05s] rightIntrinsics = {%f, %f, %f, %f, %f, %f, %f, %f, %f }",
directionName[cameraParametersetersPacket.cameraParameters[i].direction].name,
cameraParametersetersPacket.cameraParameters[i].rightIntrinsics[0],
@ -106,6 +108,8 @@ T_DjiReturnCode DjiTest_PerceptionRunSample(E_DjiPerceptionDirection direction)
cameraParametersetersPacket.cameraParameters[i].rightIntrinsics[6],
cameraParametersetersPacket.cameraParameters[i].rightIntrinsics[7],
cameraParametersetersPacket.cameraParameters[i].rightIntrinsics[8]);
DjiTest_WidgetLogAppend("rcv [%-05s] rightIntrinsics",
directionName[cameraParametersetersPacket.cameraParameters[i].direction].name);
USER_LOG_INFO("[%-05s] rotationLeftInRight = {%f, %f, %f, %f, %f, %f, %f, %f, %f }",
directionName[cameraParametersetersPacket.cameraParameters[i].direction].name,
cameraParametersetersPacket.cameraParameters[i].rotationLeftInRight[0],
@ -117,16 +121,20 @@ T_DjiReturnCode DjiTest_PerceptionRunSample(E_DjiPerceptionDirection direction)
cameraParametersetersPacket.cameraParameters[i].rotationLeftInRight[6],
cameraParametersetersPacket.cameraParameters[i].rotationLeftInRight[7],
cameraParametersetersPacket.cameraParameters[i].rotationLeftInRight[8]);
DjiTest_WidgetLogAppend("rcv [%-05s] rotationLeftInRight",
directionName[cameraParametersetersPacket.cameraParameters[i].direction].name);
USER_LOG_INFO("[%-05s] translationLeftInRight = {%f, %f, %f }\r\n",
directionName[cameraParametersetersPacket.cameraParameters[i].direction].name,
cameraParametersetersPacket.cameraParameters[i].translationLeftInRight[0],
cameraParametersetersPacket.cameraParameters[i].translationLeftInRight[1],
cameraParametersetersPacket.cameraParameters[i].translationLeftInRight[2]);
DjiTest_WidgetLogAppend("rcv [%-05s] translationLeftInRight\r\n",
directionName[cameraParametersetersPacket.cameraParameters[i].direction].name);
osalHandler->TaskSleepMs(100);
}
USER_LOG_INFO("--> Step 3: Subscribe perception image\r\n");
DjiTest_WidgetLogAppend("--> Step 3: Subscribe perception image\r\n");
DjiTest_WidgetLogAppend("Step 3: Subscribe perception image\r\n");
returnCode = DjiPerception_SubscribePerceptionImage(direction, DjiTest_PerceptionImageCallback);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Subscribe perception image failed, error code: 0x%08X", returnCode);
@ -136,7 +144,7 @@ T_DjiReturnCode DjiTest_PerceptionRunSample(E_DjiPerceptionDirection direction)
osalHandler->TaskSleepMs(5000);
USER_LOG_INFO("--> Step 4: Unsubscribe perception image");
DjiTest_WidgetLogAppend("--> Step 4: Unsubscribe perception image");
DjiTest_WidgetLogAppend("Step 4: Unsubscribe perception image");
returnCode = DjiPerception_UnsubscribePerceptionImage(direction);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Unsubscribe perception image failed, error code: 0x%08X", returnCode);
@ -144,7 +152,7 @@ T_DjiReturnCode DjiTest_PerceptionRunSample(E_DjiPerceptionDirection direction)
}
USER_LOG_INFO("--> Step 5: Deinit Perception module");
DjiTest_WidgetLogAppend("--> Step 5: Deinit Perception module");
DjiTest_WidgetLogAppend("Step 5: Deinit Perception module");
returnCode = DjiPerception_Deinit();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Perception deinit failed, error code: 0x%08X", returnCode);
@ -153,6 +161,7 @@ T_DjiReturnCode DjiTest_PerceptionRunSample(E_DjiPerceptionDirection direction)
out:
USER_LOG_INFO("Perception sample end");
DjiTest_WidgetLogAppend("Perception sample end");
return returnCode;
}
@ -202,6 +211,11 @@ static void DjiTest_PerceptionImageCallback(T_DjiPerceptionImageInfo imageInfo,
imageInfo.dataType,
imageInfo.rawInfo.width,
imageInfo.rawInfo.height);
DjiTest_WidgetLogAppend(
"Save image: dir:%s, pos:%d, size:%dx%d",
imageInfo.dataType,
imageInfo.rawInfo.width,
imageInfo.rawInfo.height);
s_perceptionImageCount++;
}

View File

@ -27,6 +27,7 @@
#include <fc_subscription/test_fc_subscription.h>
#include "test_positioning.h"
#include "dji_positioning.h"
#include "dji_network_rtk.h"
#include "dji_logger.h"
#include "utils/util_misc.h"
#include "dji_platform.h"
@ -39,11 +40,11 @@
#endif
/* Private constants ---------------------------------------------------------*/
#define POSITIONING_TASK_FREQ (1)
#define POSITIONING_TASK_STACK_SIZE (2048)
#define POSITIONING_TASK_FREQ (0.1)
#define POSITIONING_TASK_STACK_SIZE (3 * 1024)
#define TEST_RTCM_FILE_PATH_STR_MAX_SIZE (64)
#define DJI_TEST_POSITIONING_EVENT_COUNT (2)
#define DJI_TEST_POSITIONING_EVENT_COUNT (1)
#define DJI_TEST_TIME_INTERVAL_AMONG_EVENTS_US (200000)
/* Private types -------------------------------------------------------------*/
@ -58,8 +59,10 @@ static T_DjiReturnCode DjiTest_ReceiveRtkBaseStationRtcmDataCallback(uint8_t ind
/* Private variables ---------------------------------------------------------*/
static T_DjiTaskHandle s_userPositioningThread;
static int32_t s_eventIndex = 0;
#ifdef SYSTEM_ARCH_LINUX
static char s_rtkOnAircraftRtcmFilePath[TEST_RTCM_FILE_PATH_STR_MAX_SIZE];
static char s_rtkBaseStationRtcmFilePath[TEST_RTCM_FILE_PATH_STR_MAX_SIZE];
#endif
/* Exported functions definition ---------------------------------------------*/
T_DjiReturnCode DjiTest_PositioningStartService(void)
@ -79,7 +82,7 @@ T_DjiReturnCode DjiTest_PositioningStartService(void)
if (osalHandler->TaskCreate("user_positioning_task", DjiTest_PositioningTask,
POSITIONING_TASK_STACK_SIZE, NULL, &s_userPositioningThread) !=
DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("user positioning task create error.");
USER_LOG_ERROR("user ps_extensionPortSampleIndexositioning task create error.");
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
#else
@ -113,6 +116,51 @@ T_DjiReturnCode DjiTest_PositioningStartService(void)
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static void DjiTest_ReceiveNetworkRtkStateCallback(E_DjiNetworkRtkOnboardState state)
{
USER_LOG_INFO("Network rtk state: %d", state);
}
T_DjiReturnCode DjiTest_NetworkRtkOnBoardService(E_DjiTestNetworkRtkCtrl ctrl)
{
T_DjiReturnCode djiStat;
USER_LOG_INFO("Network rtk service %s..", ctrl == DJI_TEST_NETWORK_RTK_START ? "start":"stop");
switch (ctrl)
{
case DJI_TEST_NETWORK_RTK_START:
djiStat = DjiNetworkRtk_RegReceiveNetworkRtkStateCallback(DjiTest_ReceiveNetworkRtkStateCallback);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
USER_LOG_ERROR("Register receive network rtk state callback error.");
return djiStat;
}
/* example account */
T_DjiNetworkRtkServiceConfig config = {
.account = "12345",
.password = "12345",
.host = "12345",
.port = "123",
.mountPoint = "234",
};
djiStat = DjiNetworkRtk_StartService(&config);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
USER_LOG_ERROR("start network rtk on aircraft error.");
return djiStat;
}
break;
case DJI_TEST_NETWORK_RTK_STOP:
djiStat = DjiNetworkRtk_StopService();
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
USER_LOG_ERROR("stop network rtk on aircraft error.");
return djiStat;
}
break;
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
/* Private functions definition-----------------------------------------------*/
#ifndef __CC_ARM
#pragma GCC diagnostic push
@ -168,22 +216,22 @@ static void *DjiTest_PositioningTask(void *arg)
continue;
}
USER_LOG_DEBUG("request position of target points success.");
USER_LOG_DEBUG("detail position information:");
USER_LOG_INFO("request position of target points success.");
USER_LOG_INFO("detail position information:");
for (i = 0; i < DJI_TEST_POSITIONING_EVENT_COUNT; ++i) {
USER_LOG_DEBUG("position solution property: %d.", positionInfo[i].positionSolutionProperty);
USER_LOG_DEBUG("pitchAttitudeAngle: %d\trollAttitudeAngle: %d\tyawAttitudeAngle: %d",
USER_LOG_INFO("position solution property: %d.", positionInfo[i].positionSolutionProperty);
USER_LOG_INFO("pitchAttitudeAngle: %d\trollAttitudeAngle: %d\tyawAttitudeAngle: %d",
positionInfo[i].uavAttitude.pitch, positionInfo[i].uavAttitude.roll,
positionInfo[i].uavAttitude.yaw);
USER_LOG_DEBUG("northPositionOffset: %d\tearthPositionOffset: %d\tdownPositionOffset: %d",
USER_LOG_INFO("northPositionOffset: %d\tearthPositionOffset: %d\tdownPositionOffset: %d",
positionInfo[i].offsetBetweenMainAntennaAndTargetPoint.x,
positionInfo[i].offsetBetweenMainAntennaAndTargetPoint.y,
positionInfo[i].offsetBetweenMainAntennaAndTargetPoint.z);
USER_LOG_DEBUG("longitude: %.8f\tlatitude: %.8f\theight: %.8f",
USER_LOG_INFO("longitude: %.8f\tlatitude: %.8f\theight: %.8f",
positionInfo[i].targetPointPosition.longitude,
positionInfo[i].targetPointPosition.latitude,
positionInfo[i].targetPointPosition.height);
USER_LOG_DEBUG(
USER_LOG_INFO(
"longStandardDeviation: %.8f\tlatStandardDeviation: %.8f\thgtStandardDeviation: %.8f",
positionInfo[i].targetPointPositionStandardDeviation.longitude,
positionInfo[i].targetPointPositionStandardDeviation.latitude,
@ -198,9 +246,9 @@ static void *DjiTest_PositioningTask(void *arg)
#pragma GCC diagnostic pop
#endif
#ifdef SYSTEM_ARCH_LINUX
static int32_t DjiTest_SaveRtcmData(char *filePath, const uint8_t *data, uint32_t len)
{
#ifdef SYSTEM_ARCH_LINUX
FILE *fp = NULL;
size_t size;
@ -218,9 +266,9 @@ static int32_t DjiTest_SaveRtcmData(char *filePath, const uint8_t *data, uint32_
fflush(fp);
fclose(fp);
#endif
return 0;
}
#endif
static T_DjiReturnCode DjiTest_ReceiveRtkOnAircraftRtcmDataCallback(uint8_t index, const uint8_t *data,
uint16_t dataLen)

View File

@ -36,12 +36,18 @@ extern "C" {
/* Exported constants --------------------------------------------------------*/
typedef enum {
DJI_TEST_NETWORK_RTK_START = 0,
DJI_TEST_NETWORK_RTK_STOP = 1,
} E_DjiTestNetworkRtkCtrl;
/* Exported types ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
T_DjiReturnCode DjiTest_PositioningStartService(void);
T_DjiReturnCode DjiTest_NetworkRtkOnBoardService(E_DjiTestNetworkRtkCtrl ctrl);
#ifdef __cplusplus
}

View File

@ -87,9 +87,11 @@ T_DjiReturnCode DjiTest_PowerManagementStartService(void)
return returnCode;
}
if (((baseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M300_RTK || baseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M350_RTK) &&
(baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 || baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_XPORT)) ||
baseInfo.aircraftType == DJI_AIRCRAFT_TYPE_FC30) {
if (baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 ||
baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_XPORT ||
baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V3 ||
baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_EPORT_V2_RIBBON_CABLE ||
baseInfo.aircraftType == DJI_AIRCRAFT_TYPE_FC30) {
// apply high power
if (s_applyHighPowerHandler.pinInit == NULL) {
USER_LOG_ERROR("apply high power pin init interface is NULL error");
@ -113,10 +115,30 @@ T_DjiReturnCode DjiTest_PowerManagementStartService(void)
return returnCode;
}
returnCode = DjiPowerManagement_ApplyHighPowerSync();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("apply high power error");
return returnCode;
if (baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V3 ||
baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_EPORT_V2_RIBBON_CABLE) {
E_DjiHighPowerVoltage voltage = E_DJI_HIGH_POWER_VOLTAGE_17V;
USER_LOG_INFO("Start to apply high power.");
returnCode = DjiPowerManagement_ApplyHighPowerSyncV2(voltage);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("apply high power error");
return returnCode;
}
USER_LOG_INFO("Success to apply high power %s.",
voltage == E_DJI_HIGH_POWER_VOLTAGE_13V6 ? "13V6" :
voltage == E_DJI_HIGH_POWER_VOLTAGE_17V ? "17V" :
voltage == E_DJI_HIGH_POWER_VOLTAGE_24V ? "24V" : "???");
} else {
USER_LOG_INFO("Start to apply high power.");
returnCode = DjiPowerManagement_ApplyHighPowerSync();
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("apply high power error");
return returnCode;
}
USER_LOG_INFO("Success to apply high power.");
}
}

View File

@ -160,9 +160,16 @@ static void *DjiTest_TimeSyncTask(void *arg)
continue;
}
USER_LOG_DEBUG("current aircraft time is %04d-%02d-%02d %02d:%02d:%02d %d.",
aircraftTime.year, aircraftTime.month, aircraftTime.day,
aircraftTime.hour, aircraftTime.minute, aircraftTime.second, aircraftTime.microsecond);
if ((aircraftTime.second % 30) == 0) {
USER_LOG_INFO("current aircraft time is %04d-%02d-%02d %02d:%02d:%02d %d.",
aircraftTime.year, aircraftTime.month, aircraftTime.day,
aircraftTime.hour, aircraftTime.minute, aircraftTime.second, aircraftTime.microsecond);
} else {
USER_LOG_DEBUG("current aircraft time is %04d-%02d-%02d %02d:%02d:%02d %d.",
aircraftTime.year, aircraftTime.month, aircraftTime.day,
aircraftTime.hour, aircraftTime.minute, aircraftTime.second, aircraftTime.microsecond);
}
}
}

View File

@ -90,6 +90,7 @@ bool DjiUserConfigManager_IsEnable(void)
/* Private functions definition-----------------------------------------------*/
static T_DjiReturnCode DjiUserConfigManager_GetAppInfoInner(const char *path, T_DjiUserInfo *userInfo)
{
#ifdef SYSTEM_ARCH_LINUX
T_DjiReturnCode returnCode;
uint32_t fileSize = 0;
uint32_t readRealSize = 0;
@ -99,7 +100,6 @@ static T_DjiReturnCode DjiUserConfigManager_GetAppInfoInner(const char *path, T_
cJSON *jsonItem = NULL;
cJSON *jsonValue = NULL;
#ifdef SYSTEM_ARCH_LINUX
returnCode = UtilFile_GetFileSizeByPath(path, &fileSize);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get file size by path failed, stat = 0x%08llX", returnCode);
@ -191,6 +191,7 @@ jsonDataFree:
static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path, T_DjiUserLinkConfig *linkConfig)
{
#ifdef SYSTEM_ARCH_LINUX
T_DjiReturnCode returnCode;
uint32_t fileSize = 0;
uint32_t readRealSize = 0;
@ -202,8 +203,6 @@ static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path,
cJSON *jsonConfig = NULL;
int32_t configValue;
#ifdef SYSTEM_ARCH_LINUX
returnCode = UtilFile_GetFileSizeByPath(path, &fileSize);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get file size by path failed, stat = 0x%08llX", returnCode);
@ -240,6 +239,10 @@ static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path,
linkConfig->type = DJI_USER_LINK_CONFIG_USE_UART_AND_NETWORK_DEVICE;
} else if (strcmp(jsonValue->valuestring, "use_uart_and_usb_bulk_device") == 0) {
linkConfig->type = DJI_USER_LINK_CONFIG_USE_UART_AND_USB_BULK_DEVICE;
} else if (strcmp(jsonValue->valuestring, "use_only_usb_bulk_device") == 0) {
linkConfig->type = DJI_USER_LINK_CONFIG_USE_ONLY_USB_BULK_DEVICE;
} else if (strcmp(jsonValue->valuestring, "use_only_network_device") == 0) {
linkConfig->type = DJI_USER_LINK_CONFIG_USE_ONLY_NETWORK_DEVICE;
}
}
@ -326,6 +329,23 @@ static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path,
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk2_endpoint_out");
printf("Config usb bulk2 endpoint out: %s\r\n", jsonConfig->valuestring);
linkConfig->usbBulkConfig.usbBulk2EndpointOut = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_device_name");
printf("Config usb bulk2 device name: %s\r\n", jsonConfig->valuestring);
strcpy(linkConfig->usbBulkConfig.usbBulk3DeviceName, jsonConfig->valuestring);
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_interface_num");
printf("Config usb bulk2 interface num: %s\r\n", jsonConfig->valuestring);
sscanf(jsonConfig->valuestring, "%X", &configValue);
linkConfig->usbBulkConfig.usbBulk3InterfaceNum = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_endpoint_in");
printf("Config usb bulk2 endpoint in: %s\r\n", jsonConfig->valuestring);
linkConfig->usbBulkConfig.usbBulk3EndpointIn = configValue;
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk3_endpoint_out");
printf("Config usb bulk2 endpoint out: %s\r\n", jsonConfig->valuestring);
linkConfig->usbBulkConfig.usbBulk3EndpointOut = configValue;
}
}

View File

@ -43,6 +43,8 @@ typedef enum {
DJI_USER_LINK_CONFIG_USE_ONLY_UART,
DJI_USER_LINK_CONFIG_USE_UART_AND_NETWORK_DEVICE,
DJI_USER_LINK_CONFIG_USE_UART_AND_USB_BULK_DEVICE,
DJI_USER_LINK_CONFIG_USE_ONLY_USB_BULK_DEVICE,
DJI_USER_LINK_CONFIG_USE_ONLY_NETWORK_DEVICE,
} E_DjiUserLinkConfigType;
typedef struct {
@ -71,6 +73,11 @@ typedef struct {
uint8_t usbBulk2InterfaceNum;
uint8_t usbBulk2EndpointIn;
uint8_t usbBulk2EndpointOut;
char usbBulk3DeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
uint8_t usbBulk3InterfaceNum;
uint8_t usbBulk3EndpointIn;
uint8_t usbBulk3EndpointOut;
} usbBulkConfig;
} T_DjiUserLinkConfig;

View File

@ -27,12 +27,12 @@
#ifndef UTIL_FILE_H
#define UTIL_FILE_H
#ifdef SYSTEM_ARCH_LINUX
#ifdef __cplusplus
extern "C" {
#endif
#ifdef SYSTEM_ARCH_LINUX
/* Includes ------------------------------------------------------------------*/
#include <dji_typedef.h>
#include <stdio.h>

View File

@ -30,6 +30,7 @@
#include "dji_waypoint_v3.h"
#include "waypoint_file_c/waypoint_v3_test_file_kmz.h"
#include "dji_fc_subscription.h"
#include "widget_interaction_test/test_widget_interaction.h"
/* Private constants ---------------------------------------------------------*/
#define DJI_TEST_WAYPOINT_V3_KMZ_FILE_PATH_LEN_MAX (256)
@ -37,22 +38,26 @@
/* Private types -------------------------------------------------------------*/
/* Private values -------------------------------------------------------------*/
#ifdef SYSTEM_ARCH_LINUX
static T_DjiWaypointV3MissionState s_lastWaypointV3MissionState = {0};
#endif
/* Private functions declaration ---------------------------------------------*/
#ifdef SYSTEM_ARCH_LINUX
static T_DjiReturnCode DjiTest_WaypointV3MissionStateCallback(T_DjiWaypointV3MissionState missionState);
static T_DjiReturnCode DjiTest_WaypointV3ActionStateCallback(T_DjiWaypointV3ActionState actionState);
#endif
static T_DjiReturnCode DjiTest_WaypointV3WaitEndFlightStatus(T_DjiFcSubscriptionFlightStatus status);
/* Exported functions definition ---------------------------------------------*/
T_DjiReturnCode DjiTest_WaypointV3RunSample(void)
{
T_DjiReturnCode returnCode;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
T_DjiFcSubscriptionFlightStatus flightStatus = 0;
T_DjiDataTimestamp flightStatusTimestamp = {0};
#ifdef SYSTEM_ARCH_LINUX
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
FILE *kmzFile = NULL;
uint32_t kmzFileSize = 0;
uint8_t *kmzFileBuf;
@ -88,7 +93,7 @@ T_DjiReturnCode DjiTest_WaypointV3RunSample(void)
/*! Attention: suggest use the exported kmz file by DJI pilot. If use this test file, you need set the longitude as
* 113.94255, latitude as 22.57765 on DJI Assistant 2 simulator */
snprintf(tempPath, DJI_TEST_WAYPOINT_V3_KMZ_FILE_PATH_LEN_MAX, "%s/waypoint_file/waypoint_v3_test_file.kmz",
curFileDirPath);
curFileDirPath);
kmzFile = fopen(tempPath, "r");
if (kmzFile == NULL) {
@ -130,6 +135,7 @@ T_DjiReturnCode DjiTest_WaypointV3RunSample(void)
}
#endif
DjiTest_WidgetLogAppend("Execute start action");
USER_LOG_INFO("Execute start action");
returnCode = DjiWaypointV3_Action(DJI_WAYPOINT_V3_ACTION_START);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -154,6 +160,7 @@ close_file:
goto out;
}
DjiTest_WidgetLogAppend("aircraft on the ground, motors stoped...");
USER_LOG_INFO("The aircraft is on the ground and motors are stoped...");
returnCode = DjiTest_WaypointV3WaitEndFlightStatus(DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_STOPED);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -161,6 +168,7 @@ close_file:
goto out;
}
DjiTest_WidgetLogAppend("aircraft on the ground, motors rotating...");
USER_LOG_INFO("The aircraft is on the ground and motors are rotating...");
returnCode = DjiTest_WaypointV3WaitEndFlightStatus(DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_ON_GROUND);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -168,6 +176,7 @@ close_file:
goto out;
}
DjiTest_WidgetLogAppend("aircraft in the air...");
USER_LOG_INFO("The aircraft is in the air...");
returnCode = DjiTest_WaypointV3WaitEndFlightStatus(DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_IN_AIR);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -175,6 +184,7 @@ close_file:
goto out;
}
DjiTest_WidgetLogAppend("aircraft on the ground, motors rotating...");
USER_LOG_INFO("The aircraft is on the ground and motors are rotating...");
returnCode = DjiTest_WaypointV3WaitEndFlightStatus(DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_ON_GROUND);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -196,6 +206,7 @@ close_file:
goto out;
}
DjiTest_WidgetLogAppend("aircraft on the ground, motor toped.");
USER_LOG_INFO("The aircraft is on the ground now, and motor are stoped.");
out:
@ -209,6 +220,7 @@ out:
}
/* Private functions definition-----------------------------------------------*/
#ifdef SYSTEM_ARCH_LINUX
static T_DjiReturnCode DjiTest_WaypointV3MissionStateCallback(T_DjiWaypointV3MissionState missionState)
{
if (s_lastWaypointV3MissionState.state == missionState.state
@ -220,6 +232,9 @@ static T_DjiReturnCode DjiTest_WaypointV3MissionStateCallback(T_DjiWaypointV3Mis
USER_LOG_INFO("Waypoint v3 mission state: %d, current waypoint index: %d, wayLine id: %d", missionState.state,
missionState.currentWaypointIndex, missionState.wayLineId);
DjiTest_WidgetLogAppend("WP3 mission: %d, wp idx: %d, wL id: %d", missionState.state,
missionState.currentWaypointIndex, missionState.wayLineId);
memcpy(&s_lastWaypointV3MissionState, &missionState, sizeof(T_DjiWaypointV3MissionState));
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -233,8 +248,13 @@ static T_DjiReturnCode DjiTest_WaypointV3ActionStateCallback(T_DjiWaypointV3Acti
actionState.currentWaypointIndex, actionState.wayLineId,
actionState.actionGroupId, actionState.actionId);
DjiTest_WidgetLogAppend("WP3 action :%d, wp idx:%d, wL id:%d, ac:%d-%d",
actionState.state,
actionState.currentWaypointIndex, actionState.wayLineId,
actionState.actionGroupId, actionState.actionId);
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
#endif
static T_DjiReturnCode DjiTest_WaypointV3WaitEndFlightStatus(T_DjiFcSubscriptionFlightStatus status) {
T_DjiReturnCode returnCode;

View File

@ -31,15 +31,21 @@
#include <stdio.h>
#include "dji_sdk_config.h"
#include "file_binary_array_list_en.h"
#include <stdarg.h>
/* Private constants ---------------------------------------------------------*/
#define WIDGET_DIR_PATH_LEN_MAX (256)
#define WIDGET_TASK_STACK_SIZE (2048)
#define WIDGET_LOG_STRING_MAX_SIZE (64)
#define WIDGET_LOG_LINE_MAX_NUM (4)
/* Private types -------------------------------------------------------------*/
typedef struct {
bool valid;
char content[WIDGET_LOG_STRING_MAX_SIZE];
} T_DjiTestWidgetLog;
/* Private functions declaration ---------------------------------------------*/
static void *DjiTest_WidgetTask(void *arg);
static T_DjiReturnCode DjiTestWidget_SetWidgetValue(E_DjiWidgetType widgetType, uint32_t index, int32_t value,
void *userData);
static T_DjiReturnCode DjiTestWidget_GetWidgetValue(E_DjiWidgetType widgetType, uint32_t index, int32_t *value,
@ -49,7 +55,7 @@ static T_DjiReturnCode DjiTestWidget_GetWidgetValue(E_DjiWidgetType widgetType,
static T_DjiTaskHandle s_widgetTestThread;
static bool s_isWidgetFileDirPathConfigured = false;
static char s_widgetFileDirPath[DJI_FILE_PATH_SIZE_MAX] = {0};
static T_DjiTestWidgetLog s_djiTestWidgetLog[WIDGET_LOG_LINE_MAX_NUM] = {0};
static const T_DjiWidgetHandlerListItem s_widgetHandlerList[] = {
{0, DJI_WIDGET_TYPE_BUTTON, DjiTestWidget_SetWidgetValue, DjiTestWidget_GetWidgetValue, NULL},
{1, DJI_WIDGET_TYPE_LIST, DjiTestWidget_SetWidgetValue, DjiTestWidget_GetWidgetValue, NULL},
@ -75,6 +81,34 @@ static const uint32_t s_widgetHandlerListCount = sizeof(s_widgetHandlerList) / s
static int32_t s_widgetValueList[sizeof(s_widgetHandlerList) / sizeof(T_DjiWidgetHandlerListItem)] = {0};
/* Exported functions definition ---------------------------------------------*/
void DjiTest_WidgetLogAppend(const char *fmt, ...)
{
va_list args;
char string[WIDGET_LOG_STRING_MAX_SIZE];
int32_t i;
va_start(args, fmt);
vsnprintf(string, WIDGET_LOG_STRING_MAX_SIZE, fmt, args);
va_end(args);
for (i = 0; i < WIDGET_LOG_LINE_MAX_NUM; ++i) {
if (s_djiTestWidgetLog[i].valid == false) {
s_djiTestWidgetLog[i].valid = true;
strcpy(s_djiTestWidgetLog[i].content, string);
break;
}
}
if (i == WIDGET_LOG_LINE_MAX_NUM) {
for (i = 0; i < WIDGET_LOG_LINE_MAX_NUM - 1; i++) {
strcpy(s_djiTestWidgetLog[i].content, s_djiTestWidgetLog[i + 1].content);
}
strcpy(s_djiTestWidgetLog[WIDGET_LOG_LINE_MAX_NUM - 1].content, string);
}
}
T_DjiReturnCode DjiTest_WidgetStartService(void)
{
T_DjiReturnCode djiStat;
@ -104,6 +138,7 @@ T_DjiReturnCode DjiTest_WidgetStartService(void)
}
//set default ui config path
USER_LOG_INFO("widget file: %s", tempPath);
djiStat = DjiWidget_RegDefaultUiConfigByDirPath(tempPath);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Add default widget ui config error, stat = 0x%08llX", djiStat);
@ -173,20 +208,13 @@ T_DjiReturnCode DjiTest_WidgetSetConfigFilePath(const char *path)
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
__attribute__((weak)) void DjiTest_WidgetLogAppend(const char *fmt, ...)
{
}
#ifndef __CC_ARM
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
#pragma GCC diagnostic ignored "-Wreturn-type"
#pragma GCC diagnostic ignored "-Wformat"
#endif
/* Private functions definition-----------------------------------------------*/
static void *DjiTest_WidgetTask(void *arg)
void *DjiTest_WidgetTask(void *arg)
{
char message[DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN];
uint32_t sysTimeMs = 0;
@ -201,35 +229,34 @@ static void *DjiTest_WidgetTask(void *arg)
USER_LOG_ERROR("Get system time ms error, stat = 0x%08llX", djiStat);
}
#ifndef USER_FIRMWARE_MAJOR_VERSION
snprintf(message, DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN, "System time : %u ms", sysTimeMs);
#else
snprintf(message, DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN,
"System time : %u ms\r\nVersion: v%02d.%02d.%02d.%02d\r\nBuild time: %s %s", sysTimeMs,
USER_FIRMWARE_MAJOR_VERSION, USER_FIRMWARE_MINOR_VERSION,
USER_FIRMWARE_MODIFY_VERSION, USER_FIRMWARE_DEBUG_VERSION,
__DATE__, __TIME__);
#endif
"System time : %ld ms \r\n%s \r\n%s \r\n%s \r\n%s \r\n",
sysTimeMs,
s_djiTestWidgetLog[0].content,
s_djiTestWidgetLog[1].content,
s_djiTestWidgetLog[2].content,
s_djiTestWidgetLog[3].content);
djiStat = DjiWidgetFloatingWindow_ShowMessage(message);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Floating window show message error, stat = 0x%08llX", djiStat);
}
osalHandler->TaskSleepMs(1000);
osalHandler->TaskSleepMs(200);
}
}
#ifndef __CC_ARM
#pragma GCC diagnostic pop
#endif
/* Private functions definition-----------------------------------------------*/
static T_DjiReturnCode DjiTestWidget_SetWidgetValue(E_DjiWidgetType widgetType, uint32_t index, int32_t value,
void *userData)
{
USER_UTIL_UNUSED(userData);
DjiTest_WidgetLogAppend("Set widget: typ %s idx %d val %d\n", s_widgetTypeNameArray[widgetType], index, value);
USER_LOG_INFO("Set widget value, widgetType = %s, widgetIndex = %d ,widgetValue = %d",
s_widgetTypeNameArray[widgetType], index, value);
s_widgetValueList[index] = value;

View File

@ -41,8 +41,8 @@ extern "C" {
/* Exported functions --------------------------------------------------------*/
T_DjiReturnCode DjiTest_WidgetStartService(void);
T_DjiReturnCode DjiTest_WidgetSetConfigFilePath(const char *path);
__attribute__((weak)) void DjiTest_WidgetLogAppend(const char *fmt, ...);
void DjiTest_WidgetLogAppend(const char *fmt, ...);
void *DjiTest_WidgetTask(void *arg);
#ifdef __cplusplus
}
#endif

View File

@ -71,10 +71,13 @@
static T_DjiWidgetSpeakerHandler s_speakerHandler = {0};
static T_DjiMutexHandle s_speakerMutex = {0};
static T_DjiWidgetSpeakerState s_speakerState = {0};
#ifdef SYSTEM_ARCH_LINUX
static T_DjiTaskHandle s_widgetSpeakerTestThread;
static FILE *s_ttsFile = NULL;
#endif
static FILE *s_audioFile = NULL;
static FILE *s_ttsFile = NULL;
static bool s_isDecodeFinished = true;
static uint16_t s_decodeBitrate = 0;
@ -321,10 +324,16 @@ static T_DjiReturnCode DjiTest_PlayTtsData(void)
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
}
if (aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3E ||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3T ||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3D ||
aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3TD) {
if (DJI_AIRCRAFT_TYPE_M3E == aircraftInfoBaseInfo.aircraftType || DJI_AIRCRAFT_TYPE_M3T == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M3D == aircraftInfoBaseInfo.aircraftType || DJI_AIRCRAFT_TYPE_M3TD == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M3TA == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4T == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4TD == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4D == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4E == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4TD == aircraftInfoBaseInfo.aircraftType
|| DJI_AIRCRAFT_TYPE_M4D == aircraftInfoBaseInfo.aircraftType
) {
return DjiTest_PlayAudioData();
} else {
txtFile = fopen(WIDGET_SPEAKER_TTS_FILE_NAME, "r");
@ -512,7 +521,9 @@ static T_DjiReturnCode SetPlayMode(E_DjiWidgetSpeakerPlayMode playMode)
static T_DjiReturnCode StartPlay(void)
{
#ifdef SYSTEM_ARCH_LINUX
uint32_t pid;
#endif
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
#ifdef SYSTEM_ARCH_LINUX
@ -533,7 +544,9 @@ static T_DjiReturnCode StopPlay(void)
{
T_DjiReturnCode returnCode;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
#ifdef SYSTEM_ARCH_LINUX
uint32_t pid;
#endif
returnCode = osalHandler->MutexLock(s_speakerMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -564,9 +577,11 @@ static T_DjiReturnCode SetVolume(uint8_t volume)
{
T_DjiReturnCode returnCode;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
char cmdStr[128];
int32_t ret = 0;
#ifdef PLATFORM_ARCH_x86_64
float realVolume;
int32_t ret = 0;
char cmdStr[128];
#endif
returnCode = osalHandler->MutexLock(s_speakerMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -574,7 +589,6 @@ static T_DjiReturnCode SetVolume(uint8_t volume)
return returnCode;
}
realVolume = 1.5f * (float) volume;
s_speakerState.volume = volume;
USER_LOG_INFO("Set widget speaker volume: %d", volume);
@ -584,6 +598,7 @@ static T_DjiReturnCode SetVolume(uint8_t volume)
ret = system(cmdStr);
if (ret == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
memset(cmdStr, 0, sizeof(cmdStr));
realVolume = 1.5f * (float) volume;
snprintf(cmdStr, sizeof(cmdStr), "pactl set-sink-volume %s %d%%", WIDGET_SPEAKER_USB_AUDIO_DEVICE_NAME,
(int32_t) realVolume);
@ -610,8 +625,10 @@ static T_DjiReturnCode SetVolume(uint8_t volume)
static T_DjiReturnCode ReceiveTtsData(E_DjiWidgetTransmitDataEvent event,
uint32_t offset, uint8_t *buf, uint16_t size)
{
#ifdef SYSTEM_ARCH_LINUX
uint16_t writeLen;
T_DjiReturnCode returnCode;
#endif
if (event == DJI_WIDGET_TRANSMIT_DATA_EVENT_START) {
USER_LOG_INFO("Create tts file.");
@ -662,8 +679,11 @@ static T_DjiReturnCode ReceiveTtsData(E_DjiWidgetTransmitDataEvent event,
static T_DjiReturnCode ReceiveAudioData(E_DjiWidgetTransmitDataEvent event,
uint32_t offset, uint8_t *buf, uint16_t size)
{
#ifdef SYSTEM_ARCH_LINUX
uint16_t writeLen;
T_DjiReturnCode returnCode;
#endif
T_DjiWidgetTransDataContent transDataContent = {0};
if (event == DJI_WIDGET_TRANSMIT_DATA_EVENT_START) {

View File

@ -1,148 +1,612 @@
{
"version": {
"major": 1,
"minor": 0
},
"main_interface": {
"floating_window": {
"is_enable": true
"version": {
"major": 1,
"minor": 0
},
"speaker": {
"is_enable_tts": true,
"is_enable_voice": true
},
"widget_list": [
{
"widget_index": 0,
"widget_type": "button",
"widget_name": "按钮",
"icon_file_set": {
"icon_file_name_selected": "icon_button1.png",
"icon_file_name_unselected": "icon_button1.png"
},
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 0
}
},
{
"widget_index": 1,
"widget_type": "list",
"widget_name": "列表",
"list_item": [
{
"item_name": "选项_1",
"icon_file_set": {
"icon_file_name_selected": "icon_list_item1.png",
"icon_file_name_unselected": "icon_list_item1.png"
"ar_config": {
"circleStyleList": [
{
"face": {
"bottom": {
"backColor": -256,
"faceColor": -65536
},
"distAlpha": {
"maxAlpha": 0.4,
"maxDist": 100,
"minAlpha": 0,
"minDist": 50
},
"side": {
"backColor": -256,
"faceColor": -65536
},
"top": {
"backColor": -256,
"faceColor": -65536
}
},
"stroke": {
"bottom": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"side": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"top": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
}
},
"styleId": 10
},
{
"face": {
"bottom": {
"backColor": -256,
"faceColor": -65536
},
"distAlpha": {
"maxAlpha": 0.4,
"maxDist": 100,
"minAlpha": 0,
"minDist": 50
},
"side": {
"backColor": -256,
"faceColor": -65536
},
"top": {
"backColor": -256,
"faceColor": -65536
}
},
"stroke": {
"bottom": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"side": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"top": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
}
},
"styleId": 11
}
},
{
"item_name": "选项_2",
"icon_file_set": {
"icon_file_name_selected": "icon_list_item2.png",
"icon_file_name_unselected": "icon_list_item2.png"
],
"commonPointStyleList": [
{
"alwaysInEdge": false,
"arTextAttribute": {
"color": -65536
},
"isIgnoreBorder": true,
"styleId": 10
},
{
"alwaysInEdge": false,
"arTextAttribute": {
"color": -65536
},
"isIgnoreBorder": true,
"styleId": 11
}
}
],
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 1
}
},
{
"widget_index": 2,
"widget_type": "switch",
"widget_name": "开关",
"icon_file_set": {
"icon_file_name_selected": "icon_switch_select.png",
"icon_file_name_unselected": "icon_switch_unselect.png"
},
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 2
}
},
{
"widget_index": 3,
"widget_type": "scale",
"widget_name": "范围条",
"icon_file_set": {
"icon_file_name_selected": "icon_scale.png",
"icon_file_name_unselected": "icon_scale.png"
},
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 3,
"button_value_step_length": 5
}
}
]
},
"config_interface": {
"text_input_box": {
"widget_name": "文本输入框",
"placeholder_text": "请输入消息",
"is_enable": true
"lineStyleList": [
{
"color": -256,
"stokeInfo": {
"color": -65536,
"dash": false,
"width": {
"maxStrokeWidth": 2,
"maxWidthDist": 2,
"minStrokeWidth": 2,
"minWidthDist": 2
}
},
"styleId": 10,
"useDepth": false
},
{
"color": -256,
"stokeInfo": {
"color": -65536,
"dash": false,
"width": {
"maxStrokeWidth": 2,
"maxWidthDist": 2,
"minStrokeWidth": 2,
"minWidthDist": 2
}
},
"styleId": 11,
"useDepth": false
}
],
"pointStyleList": [
{
"keyName": 0,
"pointConfig": {
"arrowConfig": {
"customIcon": false,
"defaultDeg": 0,
"img": "",
"imgHeight": 0,
"imgWidth": 0,
"showMode": 0,
"translate": 0,
"type": 0
},
"needFont": true,
"needOrthographic": true,
"needPerspective": false,
"oConfig": {
"displayHeight": 20.0,
"displayWidth": 20.0,
"img": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" fill=\"none\"\n version=\"1.1\" width=\"8\" height=\"8\" viewBox=\"0 0 8 8\">\n <g>\n <ellipse id=\"point_normal_bg\"\n cx=\"4\" cy=\"4\" rx=\"2\" ry=\"2\"\n fill=\"#FFFFFF\" fill-opacity=\"1\" />\n </g>\n\n</svg>",
"imgHeight": 20.0,
"imgWidth": 20.0
},
"pConfig": {
"maxSVG": "",
"maxSize": 0,
"minSVG": "",
"minSize": 0,
"realSize": 0,
"strokeWidthRadio": 0
},
"textConfig": {
"backgroundColor": 1427379220,
"cornerRadius": 5,
"paddingB": 5,
"paddingL": 10,
"paddingR": 10,
"paddingT": 5,
"shadow": false,
"textGravity": 1,
"textSize": 20
}
}
},
{
"keyName": 1,
"pointConfig": {
"arrowConfig": {
"customIcon": false,
"defaultDeg": 0,
"img": "",
"imgHeight": 0,
"imgWidth": 0,
"showMode": 0,
"translate": 0,
"type": 0
},
"needFont": true,
"needOrthographic": true,
"needPerspective": false,
"oConfig": {
"displayHeight": 20.0,
"displayWidth": 20.0,
"img": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" fill=\"none\"\n version=\"1.1\" width=\"8\" height=\"8\" viewBox=\"0 0 8 8\">\n <g>\n <ellipse id=\"point_normal_bg\"\n cx=\"4\" cy=\"4\" rx=\"2\" ry=\"2\"\n fill=\"#FFFFFF\" fill-opacity=\"1\" />\n </g>\n\n</svg>",
"imgHeight": 20.0,
"imgWidth": 20.0
},
"pConfig": {
"maxSVG": "",
"maxSize": 0,
"minSVG": "",
"minSize": 0,
"realSize": 0,
"strokeWidthRadio": 0
},
"textConfig": {
"backgroundColor": 1427379220,
"cornerRadius": 5,
"paddingB": 5,
"paddingL": 10,
"paddingR": 10,
"paddingT": 5,
"shadow": false,
"textGravity": 1,
"textSize": 20
}
}
}
],
"polygonStyleList": [
{
"face": {
"bottom": {
"backColor": -256,
"faceColor": -65536
},
"distAlpha": {
"maxAlpha": 0.4,
"maxDist": 100,
"minAlpha": 0,
"minDist": 50
},
"side": {
"backColor": -256,
"faceColor": -65536
},
"top": {
"backColor": -256,
"faceColor": -65536
}
},
"is3DMesh": false,
"stroke": {
"bottom": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"side": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"top": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
}
},
"styleId": 10
},
{
"face": {
"bottom": {
"backColor": -256,
"faceColor": -65536
},
"distAlpha": {
"maxAlpha": 0.4,
"maxDist": 100,
"minAlpha": 0,
"minDist": 50
},
"side": {
"backColor": -256,
"faceColor": -65536
},
"top": {
"backColor": -256,
"faceColor": -65536
}
},
"is3DMesh": false,
"stroke": {
"bottom": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"side": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"top": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
}
},
"styleId": 11
}
]
},
"widget_list": [
{
"widget_index": 4,
"widget_type": "button",
"widget_name": "按钮 4",
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 4
}
},
{
"widget_index": 5,
"widget_type": "scale",
"widget_name": "范围条 5",
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 5,
"button_value_step_length": 5
}
},
{
"widget_index": 6,
"widget_type": "int_input_box",
"widget_name": "整形值输入框 6",
"int_input_box_hint": "unit:s"
},
{
"widget_index": 7,
"widget_type": "switch",
"widget_name": "开关 7",
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 7
}
},
{
"widget_index": 8,
"widget_type": "list",
"widget_name": "列表 8",
"list_item": [
{
"item_name": "选项 1"
},
{
"item_name": "选项 2"
},
{
"item_name": "选项 3"
},
{
"item_name": "选项 4"
}
],
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 8
}
}
]
}
}
"main_interface": {
"floating_window": {
"is_enable": true
},
"speaker": {
"is_enable_tts": true,
"is_enable_voice": true
},
"widget_list": [
{
"widget_index": 0,
"widget_type": "button",
"widget_name": "按钮",
"icon_file_set": {
"icon_file_name_selected": "icon_button1.png",
"icon_file_name_unselected": "icon_button1.png"
},
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 0
}
},
{
"widget_index": 1,
"widget_type": "list",
"widget_name": "列表",
"list_item": [
{
"item_name": "选项_1",
"icon_file_set": {
"icon_file_name_selected": "icon_list_item1.png",
"icon_file_name_unselected": "icon_list_item1.png"
}
},
{
"item_name": "选项_2",
"icon_file_set": {
"icon_file_name_selected": "icon_list_item2.png",
"icon_file_name_unselected": "icon_list_item2.png"
}
}
],
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 1
}
},
{
"widget_index": 2,
"widget_type": "switch",
"widget_name": "开关",
"icon_file_set": {
"icon_file_name_selected": "icon_switch_select.png",
"icon_file_name_unselected": "icon_switch_unselect.png"
},
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 2
}
},
{
"widget_index": 3,
"widget_type": "scale",
"widget_name": "范围条",
"icon_file_set": {
"icon_file_name_selected": "icon_scale.png",
"icon_file_name_unselected": "icon_scale.png"
},
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 3,
"button_value_step_length": 5
}
}
]
},
"config_interface": {
"text_input_box": {
"widget_name": "文本输入框",
"placeholder_text": "请输入消息",
"is_enable": true
},
"widget_list": [
{
"widget_index": 4,
"widget_type": "button",
"widget_name": "按钮 4",
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 4
}
},
{
"widget_index": 5,
"widget_type": "scale",
"widget_name": "范围条 5",
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 5,
"button_value_step_length": 5
}
},
{
"widget_index": 6,
"widget_type": "int_input_box",
"widget_name": "整形值输入框 6",
"int_input_box_hint": "unit:s"
},
{
"widget_index": 7,
"widget_type": "switch",
"widget_name": "开关 7",
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 7
}
},
{
"widget_index": 8,
"widget_type": "list",
"widget_name": "列表 8",
"list_item": [
{
"item_name": "选项 1"
},
{
"item_name": "选项 2"
},
{
"item_name": "选项 3"
},
{
"item_name": "选项 4"
}
],
"customize_rc_buttons_config": {
"is_enable": true,
"mapping_config_display_order": 8
}
}
]
}
}

View File

@ -3,6 +3,470 @@
"major": 1,
"minor": 0
},
"ar_config": {
"circleStyleList": [
{
"face": {
"bottom": {
"backColor": -256,
"faceColor": -65536
},
"distAlpha": {
"maxAlpha": 0.4,
"maxDist": 100,
"minAlpha": 0,
"minDist": 50
},
"side": {
"backColor": -256,
"faceColor": -65536
},
"top": {
"backColor": -256,
"faceColor": -65536
}
},
"stroke": {
"bottom": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"side": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"top": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
}
},
"styleId": 10
},
{
"face": {
"bottom": {
"backColor": -256,
"faceColor": -65536
},
"distAlpha": {
"maxAlpha": 0.4,
"maxDist": 100,
"minAlpha": 0,
"minDist": 50
},
"side": {
"backColor": -256,
"faceColor": -65536
},
"top": {
"backColor": -256,
"faceColor": -65536
}
},
"stroke": {
"bottom": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"side": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"top": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
}
},
"styleId": 11
}
],
"commonPointStyleList": [
{
"alwaysInEdge": false,
"arTextAttribute": {
"color": -65536
},
"isIgnoreBorder": true,
"styleId": 10
},
{
"alwaysInEdge": false,
"arTextAttribute": {
"color": -65536
},
"isIgnoreBorder": true,
"styleId": 11
}
],
"lineStyleList": [
{
"color": -256,
"stokeInfo": {
"color": -65536,
"dash": false,
"width": {
"maxStrokeWidth": 2,
"maxWidthDist": 2,
"minStrokeWidth": 2,
"minWidthDist": 2
}
},
"styleId": 10,
"useDepth": false
},
{
"color": -256,
"stokeInfo": {
"color": -65536,
"dash": false,
"width": {
"maxStrokeWidth": 2,
"maxWidthDist": 2,
"minStrokeWidth": 2,
"minWidthDist": 2
}
},
"styleId": 11,
"useDepth": false
}
],
"pointStyleList": [
{
"keyName": 0,
"pointConfig": {
"arrowConfig": {
"customIcon": false,
"defaultDeg": 0,
"img": "",
"imgHeight": 0,
"imgWidth": 0,
"showMode": 0,
"translate": 0,
"type": 0
},
"needFont": true,
"needOrthographic": true,
"needPerspective": false,
"oConfig": {
"displayHeight": 20.0,
"displayWidth": 20.0,
"img": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" fill=\"none\"\n version=\"1.1\" width=\"8\" height=\"8\" viewBox=\"0 0 8 8\">\n <g>\n <ellipse id=\"point_normal_bg\"\n cx=\"4\" cy=\"4\" rx=\"2\" ry=\"2\"\n fill=\"#FFFFFF\" fill-opacity=\"1\" />\n </g>\n\n</svg>",
"imgHeight": 20.0,
"imgWidth": 20.0
},
"pConfig": {
"maxSVG": "",
"maxSize": 0,
"minSVG": "",
"minSize": 0,
"realSize": 0,
"strokeWidthRadio": 0
},
"textConfig": {
"backgroundColor": 1427379220,
"cornerRadius": 5,
"paddingB": 5,
"paddingL": 10,
"paddingR": 10,
"paddingT": 5,
"shadow": false,
"textGravity": 1,
"textSize": 20
}
}
},
{
"keyName": 1,
"pointConfig": {
"arrowConfig": {
"customIcon": false,
"defaultDeg": 0,
"img": "",
"imgHeight": 0,
"imgWidth": 0,
"showMode": 0,
"translate": 0,
"type": 0
},
"needFont": true,
"needOrthographic": true,
"needPerspective": false,
"oConfig": {
"displayHeight": 20.0,
"displayWidth": 20.0,
"img": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" fill=\"none\"\n version=\"1.1\" width=\"8\" height=\"8\" viewBox=\"0 0 8 8\">\n <g>\n <ellipse id=\"point_normal_bg\"\n cx=\"4\" cy=\"4\" rx=\"2\" ry=\"2\"\n fill=\"#FFFFFF\" fill-opacity=\"1\" />\n </g>\n\n</svg>",
"imgHeight": 20.0,
"imgWidth": 20.0
},
"pConfig": {
"maxSVG": "",
"maxSize": 0,
"minSVG": "",
"minSize": 0,
"realSize": 0,
"strokeWidthRadio": 0
},
"textConfig": {
"backgroundColor": 1427379220,
"cornerRadius": 5,
"paddingB": 5,
"paddingL": 10,
"paddingR": 10,
"paddingT": 5,
"shadow": false,
"textGravity": 1,
"textSize": 20
}
}
}
],
"polygonStyleList": [
{
"face": {
"bottom": {
"backColor": -256,
"faceColor": -65536
},
"distAlpha": {
"maxAlpha": 0.4,
"maxDist": 100,
"minAlpha": 0,
"minDist": 50
},
"side": {
"backColor": -256,
"faceColor": -65536
},
"top": {
"backColor": -256,
"faceColor": -65536
}
},
"is3DMesh": false,
"stroke": {
"bottom": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"side": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"top": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
}
},
"styleId": 10
},
{
"face": {
"bottom": {
"backColor": -256,
"faceColor": -65536
},
"distAlpha": {
"maxAlpha": 0.4,
"maxDist": 100,
"minAlpha": 0,
"minDist": 50
},
"side": {
"backColor": -256,
"faceColor": -65536
},
"top": {
"backColor": -256,
"faceColor": -65536
}
},
"is3DMesh": false,
"stroke": {
"bottom": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"side": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
},
"top": {
"distAlpha": {
"maxAlpha": 0.6,
"maxDist": 100,
"minAlpha": 1,
"minDist": 50
},
"strokeInfo": {
"color": -65536,
"dash": true,
"width": {
"maxStrokeWidth": 20,
"maxWidthDist": 20,
"minStrokeWidth": 2.5,
"minWidthDist": 100
}
}
}
},
"styleId": 11
}
]
},
"main_interface": {
"floating_window": {
"is_enable": true

View File

@ -47,14 +47,12 @@
#include "dji_sdk_config.h"
#include "hms/hms_text_c/en/hms_text_config_json.h"
#include "dji_hms.h"
#include "positioning/test_positioning.h"
/* Private constants ---------------------------------------------------------*/
#define WIDGET_DIR_PATH_LEN_MAX (256)
#define WIDGET_TASK_STACK_SIZE (2048)
#define WIDGET_LOG_STRING_MAX_SIZE (40)
#define WIDGET_LOG_LINE_MAX_NUM (5)
#define DJI_HMS_ERROR_CODE_VALUE0 0x1E020000
#define DJI_HMS_ERROR_CODE_VALUE1 0x1E020001
#define DJI_HMS_ERROR_CODE_VALUE2 0x1E020002
@ -92,6 +90,8 @@ typedef enum {
E_DJI_SAMPLE_INDEX_CAMMGR_RECORDER_VIDEO = 25,
E_DJI_SAMPLE_INDEX_CAMMGR_MEDIA_DOWNLOAD = 26,
E_DJI_SAMPLE_INDEX_CAMMGR_THERMOMETRY = 27,
E_DJI_SAMPLE_INDEX_ON_BOARD_NETWORK_RTK_START = 28,
E_DJI_SAMPLE_INDEX_ON_BOARD_NETWORK_RTK_STOP = 29,
E_DJI_SAMPLE_INDEX_UNKNOWN = 0xFF,
} E_DjiExtensionPortSampleIndex;
@ -111,13 +111,7 @@ typedef enum {
E_DJI_HMS_ERROR_LEVEL_INDEX5,
} E_DjiExtensionPortHmsErrorLevelIndex;
typedef struct {
bool valid;
char content[WIDGET_LOG_STRING_MAX_SIZE];
} T_DjiTestWidgetLog;
/* Private functions declaration ---------------------------------------------*/
static void *DjiTest_WidgetTask(void *arg);
static void *DjiTest_WidgetInteractionTask(void *arg);
static T_DjiReturnCode DjiTestWidget_SetWidgetValue(E_DjiWidgetType widgetType, uint32_t index, int32_t value,
void *userData);
@ -136,7 +130,6 @@ static bool s_isEliminateErrcode = false;
static bool s_isallowRunFlightControlSample = false;
static bool s_isSampleStart = false;
static E_DjiMountPosition s_mountPosition = DJI_MOUNT_POSITION_PAYLOAD_PORT_NO1;
static T_DjiTestWidgetLog s_djiTestWidgetLog[WIDGET_LOG_LINE_MAX_NUM] = {0};
static T_DjiAircraftInfoBaseInfo s_aircraftInfoBaseInfo = {0};
static bool s_isAliasChanged = false;
@ -173,32 +166,6 @@ static bool s_isWidgetFileDirPathConfigured = false;
static char s_widgetFileDirPath[DJI_FILE_PATH_SIZE_MAX] = {0};
/* Exported functions definition ---------------------------------------------*/
void DjiTest_WidgetLogAppend(const char *fmt, ...)
{
va_list args;
char string[WIDGET_LOG_STRING_MAX_SIZE];
int32_t i;
va_start(args, fmt);
vsnprintf(string, WIDGET_LOG_STRING_MAX_SIZE, fmt, args);
va_end(args);
for (i = 0; i < WIDGET_LOG_LINE_MAX_NUM; ++i) {
if (s_djiTestWidgetLog[i].valid == false) {
s_djiTestWidgetLog[i].valid = true;
strcpy(s_djiTestWidgetLog[i].content, string);
break;
}
}
if (i == WIDGET_LOG_LINE_MAX_NUM) {
for (i = 0; i < WIDGET_LOG_LINE_MAX_NUM - 1; i++) {
strcpy(s_djiTestWidgetLog[i].content, s_djiTestWidgetLog[i + 1].content);
}
strcpy(s_djiTestWidgetLog[WIDGET_LOG_LINE_MAX_NUM - 1].content, string);
}
}
T_DjiReturnCode DjiTest_WidgetInteractionStartService(void)
{
T_DjiReturnCode djiStat;
@ -211,10 +178,11 @@ T_DjiReturnCode DjiTest_WidgetInteractionStartService(void)
return djiStat;
}
#ifdef SYSTEM_ARCH_LINUX_DISABLEED
#ifdef SYSTEM_ARCH_LINUX_DISABLE
//Step 2 : Set UI Config (Linux environment)
char curFileDirPath[WIDGET_DIR_PATH_LEN_MAX];
char tempPath[WIDGET_DIR_PATH_LEN_MAX];
djiStat = DjiUserUtil_GetCurrentFileDirPath(__FILE__, WIDGET_DIR_PATH_LEN_MAX, curFileDirPath);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get file current path error, stat = 0x%08llX", djiStat);
@ -227,7 +195,9 @@ T_DjiReturnCode DjiTest_WidgetInteractionStartService(void)
snprintf(tempPath, WIDGET_DIR_PATH_LEN_MAX, "%swidget_file/en_big_screen", curFileDirPath);
}
USER_LOG_ERROR("Dji test widget set path");
//set default ui config path
USER_LOG_INFO("widget file: %s", tempPath);
djiStat = DjiWidget_RegDefaultUiConfigByDirPath(tempPath);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Add default widget ui config error, stat = 0x%08llX", djiStat);
@ -311,45 +281,6 @@ T_DjiReturnCode DjiTest_WidgetInteractionSetConfigFilePath(const char *path)
#endif
/* Private functions definition-----------------------------------------------*/
static void *DjiTest_WidgetTask(void *arg)
{
char message[DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN];
uint32_t sysTimeMs = 0;
T_DjiReturnCode djiStat;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
USER_UTIL_UNUSED(arg);
while (1) {
djiStat = osalHandler->GetTimeMs(&sysTimeMs);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get system time ms error, stat = 0x%08llX", djiStat);
}
#ifndef USER_FIRMWARE_MAJOR_VERSION
snprintf(message, DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN,
"System time : %u ms \r\n%s \r\n%s \r\n%s \r\n%s \r\n%s \r\n",
sysTimeMs,
s_djiTestWidgetLog[0].content,
s_djiTestWidgetLog[1].content,
s_djiTestWidgetLog[2].content,
s_djiTestWidgetLog[3].content,
s_djiTestWidgetLog[4].content);
#else
snprintf(message, DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN,
"System time : %u ms\r\nVersion: v%02d.%02d.%02d.%02d\r\nBuild time: %s %s", sysTimeMs,
USER_FIRMWARE_MAJOR_VERSION, USER_FIRMWARE_MINOR_VERSION,
USER_FIRMWARE_MODIFY_VERSION, USER_FIRMWARE_DEBUG_VERSION,
__DATE__, __TIME__);
#endif
djiStat = DjiWidgetFloatingWindow_ShowMessage(message);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Floating window show message error, stat = 0x%08llX", djiStat);
}
osalHandler->TaskSleepMs(200);
}
}
#ifndef __CC_ARM
#pragma GCC diagnostic pop
@ -461,14 +392,16 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
USER_LOG_INFO("--------------------------------------------------------------------------------------------->");
DjiTest_WidgetLogAppend("-> Sample Start");
if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT
|| DJI_MOUNT_POSITION_EXTENSION_LITE_PORT == s_aircraftInfoBaseInfo.mountPosition) {
if (s_aircraftInfoBaseInfo.mountPositionType == DJI_MOUNT_POSITION_TYPE_EXTENSION_PORT ||
s_aircraftInfoBaseInfo.mountPositionType == DJI_MOUNT_POSITION_TYPE_EXTENSION_LITE_PORT ||
s_aircraftInfoBaseInfo.mountPositionType == DJI_MOUNT_POSITION_TYPE_MANIFOLD3_ONBOARD ||
s_aircraftInfoBaseInfo.mountPositionType == DJI_MOUNT_POSITION_TYPE_EXTENSION_PORT_V2) {
switch (s_extensionPortSampleIndex) {
case E_DJI_SAMPLE_INDEX_WAYPOINT_V2:
if (s_isallowRunFlightControlSample == true) {
DjiTest_WaypointV2RunSample();
} else {
DjiTest_WidgetLogAppend("Please turn on the 'unlock flight control restrictions'");
DjiTest_WidgetLogAppend("turn on 'unlock flight control restrictions!!'");
USER_LOG_WARN("Please turn on the 'unlock flight control restrictions' switch.");
}
break;
@ -476,7 +409,7 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
if (s_isallowRunFlightControlSample == true) {
DjiTest_WaypointV3RunSample();
} else {
DjiTest_WidgetLogAppend("Please turn on the 'unlock flight control restrictions'");
DjiTest_WidgetLogAppend("turn on 'unlock flight control restrictions!!'");
USER_LOG_WARN("Please turn on the 'unlock flight control restrictions' switch.");
}
break;
@ -484,6 +417,7 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
if (s_isallowRunFlightControlSample == true) {
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_LANDING);
} else {
DjiTest_WidgetLogAppend("should turn on 'unlock flight control restrictions.");
USER_LOG_WARN("Please turn on the 'unlock flight control restrictions' switch.");
}
break;
@ -492,6 +426,7 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
DjiTest_FlightControlRunSample(
E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_POSITION_CTRL_LANDING);
} else {
DjiTest_WidgetLogAppend("should turn on 'unlock flight control restrictions..");
USER_LOG_WARN("Please turn on the 'unlock flight control restrictions' switch.");
}
break;
@ -500,6 +435,7 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
DjiTest_FlightControlRunSample(
E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_GO_HOME_FORCE_LANDING);
} else {
DjiTest_WidgetLogAppend("should turn on 'unlock flight control restrictions.");
USER_LOG_WARN("Please turn on the 'unlock flight control restrictions' switch.");
}
break;
@ -508,6 +444,7 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
DjiTest_FlightControlRunSample(
E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_TAKE_OFF_VELOCITY_CTRL_LANDING);
} else {
DjiTest_WidgetLogAppend("should turn on 'unlock flight control restrictions.");
USER_LOG_WARN("Please turn on the 'unlock flight control restrictions' switch.");
}
break;
@ -515,6 +452,7 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
if (s_isallowRunFlightControlSample == true) {
DjiTest_FlightControlRunSample(E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_ARREST_FLYING);
} else {
DjiTest_WidgetLogAppend("should turn on 'unlock flight control restrictions.");
USER_LOG_WARN("Please turn on the 'unlock flight control restrictions' switch.");
}
break;
@ -602,6 +540,12 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
DjiTest_CameraManagerRunSample(s_mountPosition,
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_THERMOMETRY);
break;
case E_DJI_SAMPLE_INDEX_ON_BOARD_NETWORK_RTK_START:
DjiTest_NetworkRtkOnBoardService(DJI_TEST_NETWORK_RTK_START);
break;
case E_DJI_SAMPLE_INDEX_ON_BOARD_NETWORK_RTK_STOP:
DjiTest_NetworkRtkOnBoardService(DJI_TEST_NETWORK_RTK_STOP);
break;
default:
break;
}

View File

@ -29,7 +29,7 @@
/* Includes ------------------------------------------------------------------*/
#include <dji_typedef.h>
#include <widget/test_widget.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -218,6 +218,12 @@
},
{
"item_name": "28_test_cammgr-thermometry"
},
{
"item_name": "29_test_network-rtk-start"
},
{
"item_name": "30_test_network-rtk-stop"
}
]
},

View File

@ -218,6 +218,12 @@
},
{
"item_name": "28_test_cammgr-thermometry"
},
{
"item_name": "29_test_network-rtk-start"
},
{
"item_name": "30_test_network-rtk-stop"
}
]
},

View File

@ -88,6 +88,7 @@ T_DjiReturnCode DjiTest_XPortStartService(void)
limitAngle.upperLimit = 300;
limitAngle.lowerLimit = -1000;
USER_LOG_INFO("Set joint angle limit of pitch axis, upperLimit %d, lowerLimit %d", limitAngle.upperLimit, limitAngle.lowerLimit);
djiStat = DjiXPort_SetLimitAngleSync(DJI_XPORT_LIMIT_ANGLE_CATEGORY_PITCH_JOINT_ANGLE, limitAngle);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("set pitch joint angle limit angle for XPort error: 0x%08llX.", djiStat);
@ -96,6 +97,7 @@ T_DjiReturnCode DjiTest_XPortStartService(void)
limitAngle.upperLimit = 300;
limitAngle.lowerLimit = -800;
USER_LOG_INFO("Set euler angle limit of pitch axis, upperLimit %d, lowerLimit %d", limitAngle.upperLimit, limitAngle.lowerLimit);
djiStat = DjiXPort_SetLimitAngleSync(DJI_XPORT_LIMIT_ANGLE_CATEGORY_PITCH_EULER_ANGLE, limitAngle);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("set pitch euler angle limit angle for XPort error: 0x%08llX.", djiStat);
@ -104,6 +106,7 @@ T_DjiReturnCode DjiTest_XPortStartService(void)
limitAngle.upperLimit = 300;
limitAngle.lowerLimit = -1000;
USER_LOG_INFO("Set extended euler angle limit of pitch axis, upperLimit %d, lowerLimit %d", limitAngle.upperLimit, limitAngle.lowerLimit);
djiStat = DjiXPort_SetLimitAngleSync(DJI_XPORT_LIMIT_ANGLE_CATEGORY_PITCH_EULER_ANGLE_EXTENSION, limitAngle);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("set pitch extension euler angle limit angle for XPort error: 0x%08llX.", djiStat);
@ -126,10 +129,12 @@ T_DjiReturnCode DjiTest_XPortStartService(void)
limitAngle.upperLimit = 1500;
limitAngle.lowerLimit = -1500;
} else {
USER_LOG_WARN("payload mount position is unknown.");
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
USER_LOG_WARN("unknown mounposition.");
limitAngle.upperLimit = 300;
limitAngle.lowerLimit = -1500;
}
USER_LOG_INFO("Set joint angle limit of yaw axis, upperLimit %d, lowerLimit %d", limitAngle.upperLimit, limitAngle.lowerLimit);
djiStat = DjiXPort_SetLimitAngleSync(DJI_XPORT_LIMIT_ANGLE_CATEGORY_YAW_JOINT_ANGLE, limitAngle);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("set yaw joint angle limit angle for XPort error: 0x%08llX.", djiStat);