NEW: release DJI Payload-SDK version 3.6
Signed-off-by: DJI-Martin <DJI-Martin@dji.com>
This commit is contained in:
@ -155,7 +155,7 @@ T_DjiReturnCode DjiMediaFile_GetMediaFileAttr(T_DjiMediaFileHandle mediaFileHand
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrg(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
uint8_t *data, uint32_t *realLen)
|
||||
{
|
||||
if (mediaFileHandle->mediaFileOptItem.getDataOrgFunc == NULL) {
|
||||
USER_LOG_ERROR("Media file handle getDataOrgFunc null error");
|
||||
|
||||
@ -57,7 +57,7 @@ typedef struct {
|
||||
T_DjiReturnCode (*getAttrFunc)(struct _DjiMediaFile *mediaFileHandle, T_DjiCameraMediaFileAttr *mediaFileAttr);
|
||||
|
||||
T_DjiReturnCode (*getDataOrgFunc)(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
uint8_t *data, uint32_t *realLen);
|
||||
T_DjiReturnCode (*getFileSizeOrgFunc)(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
|
||||
T_DjiReturnCode (*createThmFunc)(struct _DjiMediaFile *mediaFileHandle);
|
||||
@ -91,7 +91,7 @@ T_DjiReturnCode DjiMediaFile_GetMediaFileAttr(T_DjiMediaFileHandle mediaFileHand
|
||||
T_DjiCameraMediaFileAttr *mediaFileAttr);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_GetDataOrg(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
uint8_t *data, uint32_t *realLen);
|
||||
T_DjiReturnCode DjiMediaFile_GetFileSizeOrg(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
|
||||
|
||||
T_DjiReturnCode DjiMediaFile_CreateThm(T_DjiMediaFileHandle mediaFileHandle);
|
||||
|
||||
@ -770,7 +770,7 @@ static T_DjiReturnCode GetMediaFileDir(char *dirPath)
|
||||
static T_DjiReturnCode GetMediaFileOriginData(const char *filePath, uint32_t offset, uint32_t length, uint8_t *data)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
uint16_t realLen = 0;
|
||||
uint32_t realLen = 0;
|
||||
T_DjiMediaFileHandle mediaFileHandle;
|
||||
|
||||
returnCode = DjiMediaFile_CreateHandle(filePath, &mediaFileHandle);
|
||||
|
||||
@ -55,6 +55,7 @@ static const T_DjiTestCameraTypeStr s_cameraTypeStrList[] = {
|
||||
{DJI_CAMERA_TYPE_H20T, "Zenmuse H20T"},
|
||||
{DJI_CAMERA_TYPE_P1, "Zenmuse P1"},
|
||||
{DJI_CAMERA_TYPE_L1, "Zenmuse L1"},
|
||||
{DJI_CAMERA_TYPE_L2, "Zenmuse L2"},
|
||||
{DJI_CAMERA_TYPE_H20N, "Zenmuse H20N"},
|
||||
{DJI_CAMERA_TYPE_M30, "M30 Camera"},
|
||||
{DJI_CAMERA_TYPE_M30T, "M30T Camera"},
|
||||
@ -906,7 +907,8 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
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_M3T || cameraType == DJI_CAMERA_TYPE_M3T ||
|
||||
cameraType == DJI_CAMERA_TYPE_L2) {
|
||||
USER_LOG_INFO("Set mounted position %d camera's exposure mode to manual mode.",
|
||||
mountPosition);
|
||||
returnCode = DjiTest_CameraManagerSetExposureMode(mountPosition,
|
||||
@ -945,7 +947,7 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
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_M3T || cameraType == DJI_CAMERA_TYPE_L2) {
|
||||
USER_LOG_INFO("Set mounted position %d camera's exposure mode to manual mode.",
|
||||
mountPosition);
|
||||
returnCode = DjiTest_CameraManagerSetExposureMode(mountPosition,
|
||||
@ -1245,6 +1247,876 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_NIGHT_SCENE_MODE: {
|
||||
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) {
|
||||
USER_LOG_INFO("Camera type %d does not support night scene mode!", cameraType);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Step 1: Change camera stream source to zoom camera.");
|
||||
returnCode = DjiCameraManager_SetStreamSource(mountPosition, DJI_CAMERA_MANAGER_SOURCE_ZOOM_CAM);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
if (returnCode == DJI_ERROR_CAMERA_MANAGER_MODULE_CODE_UNSUPPORTED_COMMAND) {
|
||||
USER_LOG_WARN("For camera type %d, it does not need to change stream source.\r\n", cameraType);
|
||||
}
|
||||
else {
|
||||
goto exitCameraModule;
|
||||
}
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Step 2: Get night scene mode range.");
|
||||
returnCode = DjiCameraManager_GetNightSceneModeRange(mountPosition, &nightSceneModeRange);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get night scene mode range of camera at position %d failed, return code 0x%08llX",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(10);
|
||||
printf("Supported night scene mode:");
|
||||
for(uint32_t i = 0; i < nightSceneModeRange.size; i++) {
|
||||
printf(" %d", nightSceneModeRange.nightSceneMode[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
USER_LOG_INFO("Step 3: Set ningh scene mode as enable.");
|
||||
returnCode = DjiCameraManager_SetNightSceneMode(mountPosition, DJI_CAMERA_MANAGER_NIGHT_SCENE_MODE_ENABLE);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Set ningh scene mode as enable failed at position %d, error code: 0x%08X\r\n",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_GetNightSceneMode(mountPosition, &nightSceneMode);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get night scene mode failed at position %d, error code: 0x%08X\r\n",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Now the night scene mode is %d", nightSceneMode);
|
||||
|
||||
USER_LOG_INFO("Sleep 2s...");
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
|
||||
USER_LOG_INFO("Step 4: Set night scene mode as auto.");
|
||||
if (cameraType == DJI_CAMERA_TYPE_H20T) {
|
||||
USER_LOG_WARN("Camera H20T does not support set night scene mode as auto");
|
||||
}
|
||||
else {
|
||||
returnCode = DjiCameraManager_SetNightSceneMode(mountPosition, DJI_CAMERA_MANAGER_NIGHT_SCENE_MODE_AUTO);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Set ningh scene mode as auto failed at position %d, error code: 0x%08X\r\n",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_GetNightSceneMode(mountPosition, &nightSceneMode);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get night scene mode failed at position %d, error code: 0x%08X\r\n",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Now the night scene mode is %d", nightSceneMode);
|
||||
|
||||
USER_LOG_INFO("Sleep 2s...");
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Step 5: Set ningt scene mode as disable.");
|
||||
returnCode = DjiCameraManager_SetNightSceneMode(mountPosition, DJI_CAMERA_MANAGER_NIGHT_SCENE_MODE_DISABLE);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get lidar ranging info failed at position %d, error code: 0x%08X\r\n",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_GetNightSceneMode(mountPosition, &nightSceneMode);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get lidar ranging info failed at position %d, error code: 0x%08X\r\n",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Now the night scene mode is %d", nightSceneMode);
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_CAPTURE_RECORDING_STREAMS: {
|
||||
T_DjiCameraManagerStreamList streamList;
|
||||
T_DjiCameraManagerStreamList getStreamList = {0};
|
||||
T_DjiCameraManagerRangeList streamStorageRange = {0};
|
||||
|
||||
if (cameraType == DJI_CAMERA_TYPE_Z30 || cameraType == DJI_CAMERA_TYPE_XT2 ||
|
||||
cameraType == DJI_CAMERA_TYPE_XTS || cameraType == DJI_CAMERA_TYPE_P1 ||
|
||||
cameraType == DJI_CAMERA_TYPE_L1) {
|
||||
USER_LOG_INFO("Camera type %d does not support set capture or recording stream(s) to storage.",
|
||||
cameraType);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_SetMode(mountPosition, DJI_CAMERA_MANAGER_WORK_MODE_SHOOT_PHOTO);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_WARN("Set camera work mode failed, position %d, error code: 0x%08X\r\n", mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_GetStreamStorageRange(mountPosition,
|
||||
&streamStorageRange);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < streamStorageRange.size; i++) {
|
||||
streamList.streamStorage[i] = streamStorageRange.streamStorage[i];
|
||||
}
|
||||
streamList.size = streamStorageRange.size;
|
||||
|
||||
USER_LOG_INFO("Step 1: Select all capture stream to be storaged.");
|
||||
returnCode = DjiCameraManager_SetCaptureRecordingStreams(mountPosition,
|
||||
DJI_CAMERA_MANAGER_CAPTURE_OR_RECORDING_CAPTURE,
|
||||
&streamList);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_WARN("Set capture storaged streams failed %d, error code: 0x%08X\r\n", mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Step 2: Read back capture storage streams:");
|
||||
returnCode = DjiCameraManager_GetCaptureRecordingStreams(mountPosition,
|
||||
DJI_CAMERA_MANAGER_CAPTURE_OR_RECORDING_CAPTURE,
|
||||
&getStreamList);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_WARN("Get capture storage streams failed %d, error code: 0x%08X\r\n", mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < getStreamList.size; i++) {
|
||||
USER_LOG_INFO(" stream %d is %d", i, getStreamList.streamStorage[i]);
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Sleep 2s...");
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
|
||||
USER_LOG_INFO("Step 3: Select all video stream to be storaged.");
|
||||
returnCode = DjiCameraManager_SetMode(mountPosition, DJI_CAMERA_MANAGER_WORK_MODE_RECORD_VIDEO);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_WARN("Failed %d, error code: 0x%08X\r\n", mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_SetCaptureRecordingStreams(mountPosition,
|
||||
DJI_CAMERA_MANAGER_CAPTURE_OR_RECORDING_RECORDING,
|
||||
&streamList);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_WARN("Set recording storage streams failed %d, error code: 0x%08X\r\n", mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Step 4: Read back video storage streams:");
|
||||
returnCode = DjiCameraManager_GetCaptureRecordingStreams(mountPosition,
|
||||
DJI_CAMERA_MANAGER_CAPTURE_OR_RECORDING_RECORDING,
|
||||
&getStreamList);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_WARN("Get capture storage streams failed %d, error code: 0x%08X\r\n", mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < getStreamList.size; i++) {
|
||||
USER_LOG_INFO(" stream %d is %d", i, getStreamList.streamStorage[i]);
|
||||
}
|
||||
|
||||
streamList.streamStorage[0] = streamStorageRange.streamStorage[0];
|
||||
streamList.size = 1;
|
||||
|
||||
USER_LOG_INFO("Sleep 2s...");
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
|
||||
USER_LOG_INFO("Step 5: Select default video stream to storage.");
|
||||
returnCode = DjiCameraManager_SetMode(mountPosition, DJI_CAMERA_MANAGER_WORK_MODE_RECORD_VIDEO);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_WARN("Failed %d, error code: 0x%08X\r\n", mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_SetCaptureRecordingStreams(mountPosition,
|
||||
DJI_CAMERA_MANAGER_CAPTURE_OR_RECORDING_RECORDING,
|
||||
&streamList);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_WARN("Set recording storage streams failed %d, error code: 0x%08X\r\n", mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Step 6: Read back video storage streams:");
|
||||
returnCode = DjiCameraManager_GetCaptureRecordingStreams(mountPosition,
|
||||
DJI_CAMERA_MANAGER_CAPTURE_OR_RECORDING_RECORDING,
|
||||
&getStreamList);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_WARN("Get capture storage streams failed %d, error code: 0x%08X\r\n", mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < getStreamList.size; i++) {
|
||||
USER_LOG_INFO(" stream %d is %d", i, getStreamList.streamStorage[i]);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOW_STORAGE_INFO: {
|
||||
T_DjiCameraManagerStorageInfo storageInfo;
|
||||
|
||||
for (uint32_t i = 0; i < 30; i++) {
|
||||
returnCode = DjiCameraManager_GetStorageInfo(mountPosition, &storageInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_INFO("Get storage info failed!");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("total capacity: %d, remainCapcity: %d", storageInfo.totalCapacity, storageInfo.remainCapacity);
|
||||
|
||||
osalHandler->TaskSleepMs(200);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_FORMAT_SD_CARD: {
|
||||
returnCode = DjiCameraManager_FormatStorage(mountPosition);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Faile to Format SD card.");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
USER_LOG_INFO("Format SD card successfully!");
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_LINK_ZOOM: {
|
||||
|
||||
USER_LOG_INFO("Set synchronized split screen zoom enabled");
|
||||
returnCode = DjiCameraManager_SetSynchronizedSplitScreenZoomEnabled(mountPosition, true);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Sleep 5s...");
|
||||
osalHandler->TaskSleepMs(5000);
|
||||
|
||||
USER_LOG_INFO("Set synchronized split screen zoom disabled");
|
||||
returnCode = DjiCameraManager_SetSynchronizedSplitScreenZoomEnabled(mountPosition, false);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_USER_CUSTOM_DIR_FILE_NAME: {
|
||||
uint8_t dirName[240] = {0};
|
||||
uint32_t dirNameSize = 0;
|
||||
uint8_t fileName[240] = {0};
|
||||
uint32_t fileNameSize = 0;
|
||||
uint8_t getNameString[100] = {0};
|
||||
uint32_t getNameStringSize;
|
||||
|
||||
osalHandler->TaskSleepMs(5);
|
||||
printf("Input expand directory name: ");
|
||||
scanf("%s", dirName);
|
||||
dirNameSize = strlen(dirName);
|
||||
|
||||
returnCode = DjiCameraManager_SetCustomExpandName(mountPosition,
|
||||
DJI_CAMERA_MANAGER_EXPAND_NAME_TYPE_DIR,
|
||||
dirName,
|
||||
dirNameSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Set Custom expand directory name failed");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
if (cameraType != DJI_CAMERA_TYPE_L1) {
|
||||
osalHandler->TaskSleepMs(5);
|
||||
printf("Input expand file name: ");
|
||||
scanf("%s", fileName);
|
||||
fileNameSize = strlen(fileName);
|
||||
|
||||
returnCode = DjiCameraManager_SetCustomExpandName(mountPosition,
|
||||
DJI_CAMERA_MANAGER_EXPAND_NAME_TYPE_FILE,
|
||||
fileName,
|
||||
fileNameSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Set Custom expand file name failed");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getNameStringSize = sizeof(getNameString) - 1;
|
||||
returnCode = DjiCameraManager_GetCustomExpandName(mountPosition,
|
||||
DJI_CAMERA_MANAGER_EXPAND_NAME_TYPE_DIR,
|
||||
getNameString,
|
||||
&getNameStringSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get Custom expand directory name failed, stat = 0x%08llX", returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
getNameString[getNameStringSize] = '\0';
|
||||
USER_LOG_INFO("Latest directory name: %s", getNameString);
|
||||
|
||||
if (cameraType != DJI_CAMERA_TYPE_L1) {
|
||||
getNameStringSize = sizeof(getNameString) - 1;
|
||||
returnCode = DjiCameraManager_GetCustomExpandName(mountPosition,
|
||||
DJI_CAMERA_MANAGER_EXPAND_NAME_TYPE_FILE,
|
||||
getNameString,
|
||||
&getNameStringSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get Custom expand file name failed");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
getNameString[getNameStringSize] = '\0';
|
||||
USER_LOG_INFO("Latest file name: %s", getNameString);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_RESET_CAMERA_SETTINGS: {
|
||||
returnCode = DjiCameraManager_ResetCameraSetting(mountPosition);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("reset camera at position %d failed", mountPosition);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Reset camera settings success!");
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_AE_LOCK_MODE: {
|
||||
bool enable;
|
||||
|
||||
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) {
|
||||
returnCode = DjiCameraManager_SetStreamSource(mountPosition, DJI_CAMERA_MANAGER_SOURCE_ZOOM_CAM);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_WARN("Change camera stream source to zoom camera failed at position %d, error code: 0x%08X\r\n",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Try to set ae locked...");
|
||||
returnCode = DjiCameraManager_SetAELockEnabled(mountPosition, true);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Set camera ae lock mode at position %d failed", mountPosition);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
USER_LOG_INFO("Sleep 2s...");
|
||||
|
||||
returnCode = DjiCameraManager_GetAELockEnabled(mountPosition, &enable);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get camera ae lock mode at position %d failed", mountPosition);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("The camera ae lock mode now is %d", enable);
|
||||
|
||||
USER_LOG_INFO("Try to set ae unlocked...");
|
||||
returnCode = DjiCameraManager_SetAELockEnabled(mountPosition, false);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Set camera ae lock mode at position %d failed", mountPosition);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
USER_LOG_INFO("Sleep 2s...");
|
||||
|
||||
if (cameraType == DJI_CAMERA_TYPE_L1 || cameraType == DJI_CAMERA_TYPE_P1) {
|
||||
USER_LOG_INFO("Camera type %d does not support get AE lock mode, please check by yourself.",
|
||||
cameraType);
|
||||
}
|
||||
else {
|
||||
returnCode = DjiCameraManager_GetAELockEnabled(mountPosition, &enable);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get camera ae lock mode at position %d failed", mountPosition);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("The camera ae lock mode now is %d", enable);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_FOCUS_RING_VALUE: {
|
||||
uint16_t focusRingValue;
|
||||
T_DjiCameraManagerRangeList focusRingRange;
|
||||
|
||||
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) {
|
||||
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) {
|
||||
USER_LOG_WARN("Change camera stream source to zoom camera failed at position %d, error code: 0x%08X\r\n",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Set camera's focus mode to manual mode.");
|
||||
returnCode = DjiCameraManager_SetFocusMode(mountPosition, DJI_CAMERA_MANAGER_FOCUS_MODE_MANUAL);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Set mounted position %d camera's focus mode(%d) failed,"
|
||||
" error code :0x%08X.", mountPosition, DJI_CAMERA_MANAGER_FOCUS_MODE_MANUAL,
|
||||
returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_GetFocusRingRange(mountPosition, &focusRingRange);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get range failed!");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Focus ring vlaue range: %d to %d.", focusRingRange.minValue, focusRingRange.maxValue);
|
||||
|
||||
osalHandler->TaskSleepMs(10);
|
||||
printf("Input focus ring value to set: ");
|
||||
scanf("%d", &focusRingValue);
|
||||
|
||||
USER_LOG_INFO("Try to set focus ring value as %d", focusRingValue);
|
||||
returnCode = DjiCameraManager_SetFocusRingValue(mountPosition, focusRingValue);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Set camera focus ring value at position %d failed", mountPosition);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
|
||||
if (cameraType != DJI_CAMERA_TYPE_Z30) {
|
||||
returnCode = DjiCameraManager_GetFocusRingValue(mountPosition, &focusRingValue);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get camera focus ring value at position %d failed", mountPosition);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
USER_LOG_INFO("Current focus ring value is %d", focusRingValue);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_CONNECT_STATUS_TEST: {
|
||||
bool connectStatus;
|
||||
uint32_t loopTime = 10;
|
||||
|
||||
osalHandler->TaskSleepMs(10);
|
||||
printf("Please input checking time: ");
|
||||
scanf("%d", &loopTime);
|
||||
|
||||
do {
|
||||
returnCode = DjiCameraManager_GetCameraConnectStatus(mountPosition,
|
||||
&connectStatus);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Camera's connect state is %d", connectStatus);
|
||||
|
||||
osalHandler->TaskSleepMs(1500);
|
||||
} while(loopTime--);
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_GET_PHOTO_VIDEO_PARAM: {
|
||||
E_DjiCameraManagerPhotoRatio photoRatio;
|
||||
E_DjiCameraManagerPhotoStorageFormat photoFormat;
|
||||
E_DjiCameraManagerVideoStorageFormat videoFormat;
|
||||
T_DjiCameraManagerRangeList photoRatioRange;
|
||||
T_DjiCameraManagerRangeList photoFormatRange;
|
||||
T_DjiCameraManagerRangeList videoFormatRange;
|
||||
T_DjiCameraManagerVideoFormat videoParam;
|
||||
|
||||
returnCode = DjiCameraManager_GetPhotoRatioRange(mountPosition, &photoRatioRange);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get range failed!");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(5);
|
||||
printf("photo ratio range:");
|
||||
for (uint32_t i = 0; i < photoRatioRange.size; i++) {
|
||||
printf(" %d", photoRatioRange.photoRatioFormat[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
returnCode = DjiCameraManager_GetPhotoFormatStorageRange(mountPosition, &photoFormatRange);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get range failed!");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(5);
|
||||
printf("photo storage format range:");
|
||||
for (uint32_t i = 0; i < photoFormatRange.size; i++) {
|
||||
printf(" %d", photoFormatRange.photoStorageFormat[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
returnCode = DjiCameraManager_GetVideoFormatRange(mountPosition, &videoFormatRange);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get range failed!");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(5);
|
||||
printf("video storage format range:");
|
||||
for (uint32_t i = 0; i < videoFormatRange.size; i++) {
|
||||
printf(" %d", videoFormatRange.videoStorageFormat[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
USER_LOG_INFO("Set camera work mode as shoot photo.");
|
||||
returnCode = DjiCameraManager_SetMode(mountPosition, DJI_CAMERA_MANAGER_WORK_MODE_SHOOT_PHOTO);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS &&
|
||||
returnCode != DJI_ERROR_CAMERA_MANAGER_MODULE_CODE_UNSUPPORTED_COMMAND) {
|
||||
USER_LOG_ERROR("set mounted position %d camera's work mode as shoot-photo mode failed,"
|
||||
" error code :0x%08X", mountPosition, returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Set photo ratio to type %d", photoRatioRange.photoRatioFormat[0]);
|
||||
returnCode = DjiCameraManager_SetPhotoRatio(mountPosition,
|
||||
photoRatioRange.photoRatioFormat[0]);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
USER_LOG_ERROR("Set photo ratio failed.");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
if (cameraType == DJI_CAMERA_TYPE_XTS) {
|
||||
USER_LOG_INFO("Camera type %d does not support get photo ratio.", cameraType);
|
||||
}
|
||||
else {
|
||||
returnCode = DjiCameraManager_GetPhotoRatio(mountPosition,
|
||||
&photoRatio);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get camera photo ratio at position %d failed, ret = 0x%08llX",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
USER_LOG_INFO("Current photo ratio type: %d", photoRatio);
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Set photo storage format to type %d", photoFormatRange.photoStorageFormat[0]);
|
||||
returnCode = DjiCameraManager_SetPhotoFormat(mountPosition, photoFormatRange.photoStorageFormat[0]);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
USER_LOG_ERROR("Set photo storage format failed.");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
if (cameraType == DJI_CAMERA_TYPE_XTS) {
|
||||
USER_LOG_INFO("Camera type %d does not support get photo storage format.", cameraType);
|
||||
}
|
||||
else {
|
||||
returnCode = DjiCameraManager_GetPhotoFormat(mountPosition, &photoFormat);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get camera photo storage format at position %d failed, ret = 0x%08llX",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
USER_LOG_INFO("Current photo storage format type: %d", photoFormat);
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Sleep 2s...");
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
|
||||
USER_LOG_INFO("Set camera work mode as record video.");
|
||||
returnCode = DjiCameraManager_SetMode(mountPosition, DJI_CAMERA_MANAGER_WORK_MODE_RECORD_VIDEO);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS &&
|
||||
returnCode != DJI_ERROR_CAMERA_MANAGER_MODULE_CODE_UNSUPPORTED_COMMAND) {
|
||||
USER_LOG_ERROR("set mounted position %d camera's work mode as shoot-photo mode failed,"
|
||||
" error code :0x%08X", mountPosition, returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Set video storage format as type %d", videoFormatRange.videoStorageFormat[0]);
|
||||
returnCode = DjiCameraManager_SetVideoStorageFormat(mountPosition, videoFormatRange.videoStorageFormat[0]);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
{
|
||||
USER_LOG_ERROR("Set video storage format failed.");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
if (cameraType == DJI_CAMERA_TYPE_XTS) {
|
||||
USER_LOG_INFO("Camera type %d does not support get video storage format, video resolution and frame rate.",
|
||||
cameraType);
|
||||
}
|
||||
else {
|
||||
returnCode = DjiCameraManager_GetVideoFormat(mountPosition, &videoFormat);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get camera video storage format at position %d failed, ret = 0x%08llX",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
USER_LOG_INFO("Current video stroage format: %d", videoFormat);
|
||||
|
||||
returnCode = DjiCameraManager_GetVideoResolutionFrameRate(mountPosition,
|
||||
&videoParam);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get camera video resolution and framerate failed at position %d failed",
|
||||
mountPosition);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
USER_LOG_INFO("resolution: %d, frame rate: %d", videoParam.videoResolution, videoParam.videoFrameRate);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_METERING_MODE: {
|
||||
E_DjiCameraManagerMeteringMode meteringMode;
|
||||
|
||||
USER_LOG_INFO("Set metering mode as %d", DJI_CAMERA_MANAGER_METERING_MODE_AVERAGE);
|
||||
returnCode = DjiCameraManager_SetMeteringMode(mountPosition, DJI_CAMERA_MANAGER_METERING_MODE_AVERAGE);
|
||||
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("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;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_METERING_POINT: {
|
||||
int32_t x, y;
|
||||
uint8_t horizonRegionNum;
|
||||
uint8_t viticalRegionNum;
|
||||
|
||||
if (cameraType == DJI_CAMERA_TYPE_XTS) {
|
||||
USER_LOG_INFO("Camera type %d does not support to set metering point.", cameraType);
|
||||
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;
|
||||
}
|
||||
|
||||
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, &x, &y);
|
||||
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)", x, y);
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_FFC_MODE_AND_TRRIGER: {
|
||||
E_DjiCameraManagerFfcMode ffcMode;
|
||||
|
||||
if (cameraType == DJI_CAMERA_TYPE_Z30 || cameraType == DJI_CAMERA_TYPE_XT2 ||
|
||||
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) {
|
||||
USER_LOG_WARN("Camera type %d don't support FFC function.", cameraType);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(10);
|
||||
printf("Input mode to set FFC (0 manual, 1 auto):");
|
||||
scanf("%d", &ffcMode);
|
||||
|
||||
if (cameraType != DJI_CAMERA_TYPE_XTS) {
|
||||
USER_LOG_INFO("Set camera stream source to infrared camera.");
|
||||
returnCode = DjiCameraManager_SetStreamSource(mountPosition, DJI_CAMERA_MANAGER_SOURCE_IR_CAM);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Change camera stream source to infrared camera failed at position %d, error code: 0x%08X\r\n",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_SetFfcMode(mountPosition, ffcMode);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Set FFC mode %d failed, camera position %d, error code 0x%08llX",
|
||||
ffcMode, mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_TriggerFfc(mountPosition);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Trigger FFC mode, camera position %d, error code 0x%08llX",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Trriger FFC successfully!");
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_GAIN_MODE: {
|
||||
E_DjiCameraManagerIrGainMode gainMode;
|
||||
T_DjiCameraManagerIrTempMeterRange tempRange = {0};
|
||||
|
||||
if (cameraType == DJI_CAMERA_TYPE_Z30 || cameraType == DJI_CAMERA_TYPE_XT2 ||
|
||||
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) {
|
||||
USER_LOG_WARN("Camera type %d don't support infrared function.", cameraType);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(10);
|
||||
printf("Input gain mode to set (1 low, 2 high):");
|
||||
scanf("%d", &gainMode);
|
||||
|
||||
if (cameraType != DJI_CAMERA_TYPE_XTS) {
|
||||
USER_LOG_INFO("Set camera stream source to infrared camera.");
|
||||
returnCode = DjiCameraManager_SetStreamSource(mountPosition, DJI_CAMERA_MANAGER_SOURCE_IR_CAM);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Change camera stream source to infrared camera failed at position %d, error code: 0x%08X\r\n",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Get temperature range of different gain mode...");
|
||||
returnCode = DjiCameraManager_GetInfraredCameraGainModeTemperatureRange(mountPosition, &tempRange);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Fail to get infrared mode temperature range. position %d, error code 0x%08llX",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("low_min: %.2f, low_max: %.2f, high_min: %.2f, high_max: %.2f",
|
||||
tempRange.lowGainTempMin, tempRange.lowGainTempMax,
|
||||
tempRange.highGainTempMin, tempRange.highGainTempMax);
|
||||
|
||||
returnCode = DjiCameraManager_SetInfraredCameraGainMode(mountPosition, gainMode);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_INFO("Fail to set infrared camera gain mode. position %d, error code 0x%08llX",
|
||||
mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Set gain mode to %d successfully!", gainMode);
|
||||
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_GET_CAMERA_STATUS: {
|
||||
E_DjiCameraManagerCapturingState capturingState;
|
||||
E_DjiCameraManagerRecordingState recordingState;
|
||||
uint16_t recordingTime;
|
||||
uint8_t remainingTime;
|
||||
|
||||
if (cameraType == DJI_CAMERA_TYPE_L1 || cameraType == DJI_CAMERA_TYPE_P1) {
|
||||
USER_LOG_INFO("Camera type %d does not support to get camera stauts such as "
|
||||
"capturing state, recording state.", cameraType);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 30; i++) {
|
||||
returnCode = DjiCameraManager_GetCapturingState(mountPosition, &capturingState);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_INFO("Get capturing state failed!");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_GetRecordingState(mountPosition, &recordingState);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_INFO("Get recording state failed!");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_GetRecordingTime(mountPosition, &recordingTime);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_INFO("Get recording time failed!");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_GetIntervalShootingRemainTime(mountPosition, &remainingTime);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_INFO("Get interval shooting remain time failed!");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("cap_state: %d, rec_state: %d, rec_time: %d, cap_remain: %d",
|
||||
capturingState,
|
||||
recordingState,
|
||||
recordingTime,
|
||||
remainingTime);
|
||||
|
||||
osalHandler->TaskSleepMs(200);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
USER_LOG_ERROR("There is no valid command input!");
|
||||
break;
|
||||
@ -1289,6 +2161,11 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_ObtainDownloaderRights(position);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Obtain downloader rights failed, error code: 0x%08X.", returnCode);
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_DownloadFileList(position, &s_meidaFileList);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Download file list failed, error code: 0x%08X.", returnCode);
|
||||
@ -1360,6 +2237,11 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
|
||||
USER_LOG_WARN("Media file is not existed in sdcard.\r\n");
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_ReleaseDownloaderRights(position);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Release downloader rights failed, error code: 0x%08X.", returnCode);
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1377,6 +2259,11 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadFileListBySlices(E_DjiM
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_ObtainDownloaderRights(position);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Obtain downloader rights failed, error code: 0x%08X.", returnCode);
|
||||
}
|
||||
|
||||
sliceConfig.countPerSlice = DJI_CAMERA_MANAGER_FILE_LIST_COUNT_ALL_PER_SLICE;
|
||||
sliceConfig.sliceStartIndex = 0;
|
||||
|
||||
@ -1431,6 +2318,11 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadFileListBySlices(E_DjiM
|
||||
USER_LOG_WARN("Media file is not existed in sdcard.\r\n");
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_ReleaseDownloaderRights(position);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Release downloader rights failed, error code: 0x%08X.", returnCode);
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1463,18 +2355,21 @@ static T_DjiReturnCode DjiTest_CameraManagerDownloadFileDataCallback(T_DjiDownlo
|
||||
if (s_downloadMediaFile != NULL) {
|
||||
fwrite(data, 1, len, s_downloadMediaFile);
|
||||
}
|
||||
printf("\033[1;32;40m ### [Complete rate : %0.1f%%] (%s), size: %d, fileIndex: %d\033[0m\r\n",
|
||||
printf("\033[1;32;40m ### [Complete rate : %0.1f%%] (%s), size: %u, fileIndex: %d\033[0m\r\n",
|
||||
packetInfo.progressInPercent, downloadFileName, packetInfo.fileSize, packetInfo.fileIndex);
|
||||
printf("\033[1A");
|
||||
USER_LOG_DEBUG("Transfer download media file data, len: %d, percent: %.1f", len, packetInfo.progressInPercent);
|
||||
} else if (packetInfo.downloadFileEvent == DJI_DOWNLOAD_FILE_EVENT_END) {
|
||||
if (s_downloadMediaFile != NULL) {
|
||||
fwrite(data, 1, len, s_downloadMediaFile);
|
||||
if (s_downloadMediaFile == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
fwrite(data, 1, len, s_downloadMediaFile);
|
||||
|
||||
osalHandler->GetTimeMs(&downloadEndMs);
|
||||
|
||||
downloadSpeed = (float) packetInfo.fileSize / (float) (downloadEndMs - downloadStartMs);
|
||||
printf("\033[1;32;40m ### [Complete rate : %0.1f%%] (%s), size: %d, fileIndex: %d\033[0m\r\n",
|
||||
printf("\033[1;32;40m ### [Complete rate : %0.1f%%] (%s), size: %u, fileIndex: %d\033[0m\r\n",
|
||||
packetInfo.progressInPercent, downloadFileName, packetInfo.fileSize, packetInfo.fileIndex);
|
||||
printf("\033[1A");
|
||||
printf("\r\n");
|
||||
|
||||
@ -56,6 +56,22 @@ typedef enum {
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_THERMOMETRY,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_GET_LIDAR_RANGING_INFO,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_IR_CAMERA_ZOOM_PARAM,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_NIGHT_SCENE_MODE,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_CAPTURE_RECORDING_STREAMS,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOW_STORAGE_INFO,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_FORMAT_SD_CARD,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_LINK_ZOOM,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_USER_CUSTOM_DIR_FILE_NAME,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_RESET_CAMERA_SETTINGS,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_AE_LOCK_MODE,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_FOCUS_RING_VALUE,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_CONNECT_STATUS_TEST,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_GET_PHOTO_VIDEO_PARAM,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_METERING_MODE,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_METERING_POINT,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_FFC_MODE_AND_TRRIGER,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_GAIN_MODE,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_GET_CAMERA_STATUS,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_INDEX_MAX
|
||||
} E_DjiTestCameraManagerSampleSelect;
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
@ -42,7 +42,8 @@
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static void *UserDataTransmission_Task(void *arg);
|
||||
static T_DjiReturnCode ReceiveDataFromMobile(const uint8_t *data, uint16_t len);
|
||||
static T_DjiReturnCode ReceiveDataFromOnboardComputer(const uint8_t *data, uint16_t len);
|
||||
static T_DjiReturnCode ReceiveDataFromCloud(const uint8_t *data, uint16_t len);
|
||||
static T_DjiReturnCode ReceiveDataFromExtensionPort(const uint8_t *data, uint16_t len);
|
||||
static T_DjiReturnCode ReceiveDataFromPayload(const uint8_t *data, uint16_t len);
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
@ -79,13 +80,23 @@ 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) {
|
||||
channelAddress = DJI_CHANNEL_ADDRESS_CLOUD_API;
|
||||
djiStat = DjiLowSpeedDataChannel_RegRecvDataCallback(channelAddress, ReceiveDataFromCloud);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("register receive data from cloud error.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
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_RegRecvDataCallback(channelAddress, ReceiveDataFromOnboardComputer);
|
||||
djiStat = DjiLowSpeedDataChannel_RegRecvDataCallback(channelAddress, ReceiveDataFromExtensionPort);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("register receive data from onboard coputer error.");
|
||||
USER_LOG_ERROR("register receive data from extension port error.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
@ -152,7 +163,7 @@ T_DjiReturnCode DjiTest_DataTransmissionStopService(void)
|
||||
static void *UserDataTransmission_Task(void *arg)
|
||||
{
|
||||
T_DjiReturnCode djiStat;
|
||||
const uint8_t dataToBeSent[] = "DJI Data Transmission Test Data.\r\n";
|
||||
const uint8_t dataToBeSent[] = "DJI Data Transmission Test Data.";
|
||||
T_DjiDataChannelState state = {0};
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
E_DjiChannelAddress channelAddress;
|
||||
@ -177,25 +188,44 @@ 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) {
|
||||
channelAddress = DJI_CHANNEL_ADDRESS_CLOUD_API;
|
||||
djiStat = DjiLowSpeedDataChannel_SendData(channelAddress, dataToBeSent, sizeof(dataToBeSent));
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
|
||||
USER_LOG_ERROR("send data to cloud error.");
|
||||
|
||||
djiStat = DjiLowSpeedDataChannel_GetSendDataState(channelAddress, &state);
|
||||
if (djiStat == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_DEBUG(
|
||||
"send to cloud state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.",
|
||||
state.realtimeBandwidthBeforeFlowController, state.realtimeBandwidthAfterFlowController,
|
||||
state.busyState);
|
||||
} else {
|
||||
USER_LOG_ERROR("get send to cloud channel state error.");
|
||||
}
|
||||
}
|
||||
|
||||
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 onboard computer error.");
|
||||
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 onboard computer state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.",
|
||||
"send to extension port state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.",
|
||||
state.realtimeBandwidthBeforeFlowController, state.realtimeBandwidthAfterFlowController,
|
||||
state.busyState);
|
||||
} else {
|
||||
USER_LOG_ERROR("get send to onboard computer channel state error.");
|
||||
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.");
|
||||
@ -208,21 +238,22 @@ static void *UserDataTransmission_Task(void *arg)
|
||||
} 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 onboard computer error.");
|
||||
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 onboard computer state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.",
|
||||
"send to extension port state: realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController: %d, busyState: %d.",
|
||||
state.realtimeBandwidthBeforeFlowController, state.realtimeBandwidthAfterFlowController,
|
||||
state.busyState);
|
||||
} else {
|
||||
USER_LOG_ERROR("get send to onboard computer channel state error.");
|
||||
USER_LOG_ERROR("get send to extension port channel state error.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -253,7 +284,7 @@ static T_DjiReturnCode ReceiveDataFromMobile(const uint8_t *data, uint16_t len)
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode ReceiveDataFromOnboardComputer(const uint8_t *data, uint16_t len)
|
||||
static T_DjiReturnCode ReceiveDataFromCloud(const uint8_t *data, uint16_t len)
|
||||
{
|
||||
char *printData = NULL;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
@ -266,7 +297,28 @@ static T_DjiReturnCode ReceiveDataFromOnboardComputer(const uint8_t *data, uint1
|
||||
|
||||
strncpy(printData, (const char *) data, len);
|
||||
printData[len] = '\0';
|
||||
USER_LOG_INFO("receive data from onboard computer: %s, len:%d.", printData, len);
|
||||
USER_LOG_INFO("receive data from cloud: %s, len:%d.", printData, len);
|
||||
DjiTest_WidgetLogAppend("receive data: %s, len:%d.", printData, len);
|
||||
|
||||
osalHandler->Free(printData);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode ReceiveDataFromExtensionPort(const uint8_t *data, uint16_t len)
|
||||
{
|
||||
char *printData = NULL;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
printData = osalHandler->Malloc(len + 1);
|
||||
if (printData == NULL) {
|
||||
USER_LOG_ERROR("malloc memory for printData fail.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_MEMORY_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
strncpy(printData, (const char *) data, len);
|
||||
printData[len] = '\0';
|
||||
USER_LOG_INFO("receive data from extension port: %s, len:%d.", printData, len);
|
||||
DjiTest_WidgetLogAppend("receive data: %s, len:%d.", printData, len);
|
||||
|
||||
osalHandler->Free(printData);
|
||||
|
||||
@ -147,9 +147,9 @@ T_DjiReturnCode DjiTest_FcSubscriptionRunSample(void)
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("--> Step 3: Get latest value of the subscribed topics in the next 20 seconds\r\n");
|
||||
USER_LOG_INFO("--> Step 3: Get latest value of the subscribed topics in the next 10 seconds\r\n");
|
||||
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
osalHandler->TaskSleepMs(1000 / FC_SUBSCRIPTION_TASK_FREQ);
|
||||
djiStat = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_VELOCITY,
|
||||
(uint8_t *) &velocity,
|
||||
@ -204,7 +204,26 @@ T_DjiReturnCode DjiTest_FcSubscriptionRunSample(void)
|
||||
}
|
||||
}
|
||||
|
||||
USER_LOG_INFO("--> Step 4: Deinit fc subscription module");
|
||||
USER_LOG_INFO("--> Step 4: Unsubscribe the topics of quaternion, velocity and gps position");
|
||||
djiStat = DjiFcSubscription_UnSubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_QUATERNION);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("UnSubscribe topic quaternion error.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
djiStat = DjiFcSubscription_UnSubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_VELOCITY);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("UnSubscribe topic quaternion error.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
djiStat = DjiFcSubscription_UnSubscribeTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_POSITION);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("UnSubscribe topic quaternion error.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("--> Step 5: Deinit fc subscription module");
|
||||
|
||||
djiStat = DjiFcSubscription_DeInit();
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
|
||||
@ -34,14 +34,6 @@
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
dji_f32_t x;
|
||||
dji_f32_t y;
|
||||
dji_f32_t z;
|
||||
} T_DjiTestFlightControlVector3f; // pack(1)
|
||||
#pragma pack()
|
||||
|
||||
typedef struct {
|
||||
E_DjiFcSubscriptionDisplayMode displayMode;
|
||||
char *displayModeStr;
|
||||
@ -96,8 +88,6 @@ static bool DjiTest_FlightControlMoveByPositionOffset(T_DjiTestFlightControlVect
|
||||
float yawDesiredInDeg,
|
||||
float posThresholdInM,
|
||||
float yawThresholdInDeg);
|
||||
static void DjiTest_FlightControlVelocityAndYawRateCtrl(T_DjiTestFlightControlVector3f offsetDesired, float yawRate,
|
||||
uint32_t timeMs);
|
||||
static T_DjiReturnCode DjiTest_FlightControlInit(void);
|
||||
static T_DjiReturnCode DjiTest_FlightControlDeInit(void);
|
||||
static void DjiTest_FlightControlTakeOffLandingSample(void);
|
||||
@ -138,11 +128,16 @@ T_DjiReturnCode DjiTest_FlightControlRunSample(E_DjiTestFlightCtrlSampleSelect f
|
||||
T_DjiReturnCode DjiTest_FlightControlInit(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiFlightControllerRidInfo ridInfo = {0};
|
||||
|
||||
s_osalHandler = DjiPlatform_GetOsalHandler();
|
||||
if (!s_osalHandler) return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
|
||||
returnCode = DjiFlightController_Init();
|
||||
ridInfo.latitude = 22.542812;
|
||||
ridInfo.longitude = 113.958902;
|
||||
ridInfo.altitude = 10;
|
||||
|
||||
returnCode = DjiFlightController_Init(ridInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Init flight controller module failed, error code:0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
@ -236,7 +231,7 @@ T_DjiReturnCode DjiTest_FlightControlDeInit(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
|
||||
returnCode = DjiFlightController_Deinit();
|
||||
returnCode = DjiFlightController_DeInit();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Deinit flight controller module failed, error code:0x%08llX",
|
||||
returnCode);
|
||||
@ -325,25 +320,25 @@ void DjiTest_FlightControlPositionControlSample()
|
||||
USER_LOG_INFO("Successful take off\r\n");
|
||||
DjiTest_WidgetLogAppend("Successful take off\r\n");
|
||||
|
||||
USER_LOG_INFO("--> Step 3: Move to north:0(m), earth:6(m), up:6(m) , yaw:30(degree) from current point");
|
||||
DjiTest_WidgetLogAppend("--> Step 3: Move to north:0(m), earth:6(m), up:6(m) , yaw:30(degree) from current point");
|
||||
USER_LOG_INFO("--> Step 3: Move to north:0(m), east:6(m), up:6(m) , yaw:30(degree) from current point");
|
||||
DjiTest_WidgetLogAppend("--> Step 3: Move to north:0(m), east:6(m), up:6(m) , yaw:30(degree) from current point");
|
||||
if (!DjiTest_FlightControlMoveByPositionOffset((T_DjiTestFlightControlVector3f) {0, 6, 6}, 30, 0.8, 1)) {
|
||||
USER_LOG_ERROR("Move to north:0(m), earth:6(m), up:6(m) , yaw:30(degree) from current point failed");
|
||||
USER_LOG_ERROR("Move to north:0(m), east:6(m), up:6(m) , yaw:30(degree) from current point failed");
|
||||
goto out;
|
||||
};
|
||||
|
||||
USER_LOG_INFO("--> Step 4: Move to north:6(m), earth:0(m), up:-3(m) , yaw:-30(degree) from current point");
|
||||
USER_LOG_INFO("--> Step 4: Move to north:6(m), east:0(m), up:-3(m) , yaw:-30(degree) from current point");
|
||||
DjiTest_WidgetLogAppend(
|
||||
"--> Step 4: Move to north:6(m), earth:0(m), up:-3(m) , yaw:-30(degree) from current point");
|
||||
"--> Step 4: Move to north:6(m), east:0(m), up:-3(m) , yaw:-30(degree) from current point");
|
||||
if (!DjiTest_FlightControlMoveByPositionOffset((T_DjiTestFlightControlVector3f) {6, 0, -3}, -30, 0.8, 1)) {
|
||||
USER_LOG_ERROR("Move to north:6(m), earth:0(m), up:-3(m) , yaw:-30(degree) from current point failed");
|
||||
USER_LOG_ERROR("Move to north:6(m), east:0(m), up:-3(m) , yaw:-30(degree) from current point failed");
|
||||
goto out;
|
||||
};
|
||||
|
||||
USER_LOG_INFO("--> Step 5: Move to north:-6(m), earth:-6(m), up:0(m) , yaw:0(degree) from current point");
|
||||
DjiTest_WidgetLogAppend("--> Step 5: Move to north:-6(m), earth:-6(m), up:0(m) , yaw:0(degree) from current point");
|
||||
USER_LOG_INFO("--> Step 5: Move to north:-6(m), east:-6(m), up:0(m) , yaw:0(degree) from current point");
|
||||
DjiTest_WidgetLogAppend("--> Step 5: Move to north:-6(m), east:-6(m), up:0(m) , yaw:0(degree) from current point");
|
||||
if (!DjiTest_FlightControlMoveByPositionOffset((T_DjiTestFlightControlVector3f) {-6, -6, 0}, 0, 0.8, 1)) {
|
||||
USER_LOG_ERROR("Move to north:-6(m), earth:-6(m), up:0(m) , yaw:0(degree) from current point failed");
|
||||
USER_LOG_ERROR("Move to north:-6(m), east:-6(m), up:0(m) , yaw:0(degree) from current point failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -394,17 +389,17 @@ void DjiTest_FlightControlGoHomeForceLandingSample()
|
||||
USER_LOG_INFO("Successful take off\r\n");
|
||||
DjiTest_WidgetLogAppend("Successful take off\r\n");
|
||||
|
||||
USER_LOG_INFO("--> Step 3: Move to north:0(m), earth:0(m), up:30(m) , yaw:0(degree) from current point");
|
||||
DjiTest_WidgetLogAppend("--> Step 3: Move to north:0(m), earth:0(m), up:30(m) , yaw:0(degree) from current point");
|
||||
USER_LOG_INFO("--> Step 3: Move to north:0(m), east:0(m), up:30(m) , yaw:0(degree) from current point");
|
||||
DjiTest_WidgetLogAppend("--> Step 3: Move to north:0(m), east:0(m), up:30(m) , yaw:0(degree) from current point");
|
||||
if (!DjiTest_FlightControlMoveByPositionOffset((T_DjiTestFlightControlVector3f) {0, 0, 30}, 0, 0.8, 1)) {
|
||||
USER_LOG_ERROR("Move to north:0(m), earth:0(m), up:30(m) , yaw:0(degree) from current point failed");
|
||||
USER_LOG_ERROR("Move to north:0(m), east:0(m), up:30(m) , yaw:0(degree) from current point failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("--> Step 4: Move to north:10(m), earth:0(m), up:0(m) , yaw:0(degree) from current point");
|
||||
DjiTest_WidgetLogAppend("--> Step 4: Move to north:10(m), earth:0(m), up:0(m) , yaw:0(degree) from current point");
|
||||
USER_LOG_INFO("--> Step 4: Move to north:10(m), east:0(m), up:0(m) , yaw:0(degree) from current point");
|
||||
DjiTest_WidgetLogAppend("--> Step 4: Move to north:10(m), east:0(m), up:0(m) , yaw:0(degree) from current point");
|
||||
if (!DjiTest_FlightControlMoveByPositionOffset((T_DjiTestFlightControlVector3f) {10, 0, 0}, 0, 0.8, 1)) {
|
||||
USER_LOG_ERROR("Move to north:10(m), earth:0(m), up:0(m) , yaw:0(degree) from current point failed");
|
||||
USER_LOG_ERROR("Move to north:10(m), east:0(m), up:0(m) , yaw:0(degree) from current point failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -434,10 +429,10 @@ void DjiTest_FlightControlGoHomeForceLandingSample()
|
||||
USER_LOG_INFO("Current go home altitude is %d m\r\n", goHomeAltitude);
|
||||
DjiTest_WidgetLogAppend("Current go home altitude is %d m\r\n", goHomeAltitude);
|
||||
|
||||
USER_LOG_INFO("--> Step 7: Move to north:20(m), earth:0(m), up:0(m) , yaw:0(degree) from current point");
|
||||
DjiTest_WidgetLogAppend("--> Step 7: Move to north:20(m), earth:0(m), up:0(m) , yaw:0(degree) from current point");
|
||||
USER_LOG_INFO("--> Step 7: Move to north:20(m), east:0(m), up:0(m) , yaw:0(degree) from current point");
|
||||
DjiTest_WidgetLogAppend("--> Step 7: Move to north:20(m), east:0(m), up:0(m) , yaw:0(degree) from current point");
|
||||
if (!DjiTest_FlightControlMoveByPositionOffset((T_DjiTestFlightControlVector3f) {20, 0, 0}, 0, 0.8, 1)) {
|
||||
USER_LOG_ERROR("Move to north:20(m), earth:0(m), up:0(m) , yaw:0(degree) from current point failed");
|
||||
USER_LOG_ERROR("Move to north:20(m), east:0(m), up:0(m) , yaw:0(degree) from current point failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -489,9 +484,9 @@ void DjiTest_FlightControlVelocityControlSample()
|
||||
DjiTest_WidgetLogAppend("Successful take off\r\n");
|
||||
|
||||
USER_LOG_INFO(
|
||||
"--> Step 3: Move with north:0(m/s), earth:0(m/s), up:5(m/s), yaw:0(deg/s) from current point for 2s!");
|
||||
"--> Step 3: Move with north:0(m/s), east:0(m/s), up:5(m/s), yaw:0(deg/s) from current point for 2s!");
|
||||
DjiTest_WidgetLogAppend(
|
||||
"--> Step 3: Move with north:0(m/s), earth:0(m/s), up:5(m/s), yaw:0(deg/s) from current point for 2s!");
|
||||
"--> Step 3: Move with north:0(m/s), east:0(m/s), up:5(m/s), yaw:0(deg/s) from current point for 2s!");
|
||||
DjiTest_FlightControlVelocityAndYawRateCtrl((T_DjiTestFlightControlVector3f) {0, 0, 5.0}, 0, 2000);
|
||||
|
||||
USER_LOG_INFO("--> Step 4: Emergency brake for 2s");
|
||||
@ -509,9 +504,9 @@ void DjiTest_FlightControlVelocityControlSample()
|
||||
}
|
||||
|
||||
USER_LOG_INFO(
|
||||
"--> Step 5: Move with north:-1.5(m/s), earth:2(m/s), up:0(m/s), yaw:20(deg/s) from current point for 2s!");
|
||||
"--> Step 5: Move with north:-1.5(m/s), east:2(m/s), up:0(m/s), yaw:20(deg/s) from current point for 2s!");
|
||||
DjiTest_WidgetLogAppend(
|
||||
"--> Step 5: Move with north:-1.5(m/s), earth:2(m/s), up:0(m/s), yaw:20(deg/s) from current point for 2s!");
|
||||
"--> Step 5: Move with north:-1.5(m/s), east:2(m/s), up:0(m/s), yaw:20(deg/s) from current point for 2s!");
|
||||
DjiTest_FlightControlVelocityAndYawRateCtrl((T_DjiTestFlightControlVector3f) {-1.5, 2, 0}, 20, 2000);
|
||||
|
||||
USER_LOG_INFO("--> Step 6: Emergency brake for 2s");
|
||||
@ -529,9 +524,9 @@ void DjiTest_FlightControlVelocityControlSample()
|
||||
}
|
||||
|
||||
USER_LOG_INFO(
|
||||
"--> Step 7: Move with north:3(m/s), earth:0(m/s), up:0(m/s), yaw:0(deg/s) from current point for 2.5s!");
|
||||
"--> Step 7: Move with north:3(m/s), east:0(m/s), up:0(m/s), yaw:0(deg/s) from current point for 2.5s!");
|
||||
DjiTest_WidgetLogAppend(
|
||||
"--> Step 7: Move with north:3(m/s), earth:0(m/s), up:0(m/s), yaw:0(deg/s) from current point for 2.5s!");
|
||||
"--> Step 7: Move with north:3(m/s), east:0(m/s), up:0(m/s), yaw:0(deg/s) from current point for 2.5s!");
|
||||
DjiTest_FlightControlVelocityAndYawRateCtrl((T_DjiTestFlightControlVector3f) {3, 0, 0}, 0, 2500);
|
||||
|
||||
USER_LOG_INFO("--> Step 8: Emergency brake for 2s");
|
||||
@ -549,9 +544,9 @@ void DjiTest_FlightControlVelocityControlSample()
|
||||
}
|
||||
|
||||
USER_LOG_INFO(
|
||||
"--> Step 9: Move with north:-1.6(m/s), earth:-2(m/s), up:0(m/s), yaw:0(deg/s) from current point for 2.2s!");
|
||||
"--> Step 9: Move with north:-1.6(m/s), east:-2(m/s), up:0(m/s), yaw:0(deg/s) from current point for 2.2s!");
|
||||
DjiTest_WidgetLogAppend(
|
||||
"--> Step 9: Move with north:-1.6(m/s), earth:-2(m/s), up:0(m/s), yaw:0(deg/s) from current point for 2.2s!");
|
||||
"--> Step 9: Move with north:-1.6(m/s), east:-2(m/s), up:0(m/s), yaw:0(deg/s) from current point for 2.2s!");
|
||||
DjiTest_FlightControlVelocityAndYawRateCtrl((T_DjiTestFlightControlVector3f) {-1.6, -2, 0}, 0, 2200);
|
||||
|
||||
USER_LOG_INFO("--> Step 10: Emergency brake for 2s");
|
||||
@ -1218,6 +1213,12 @@ bool DjiTest_FlightControlGoHomeAndConfirmLanding(void)
|
||||
{
|
||||
T_DjiReturnCode djiStat;
|
||||
T_DjiAircraftInfoBaseInfo aircraftInfoBaseInfo;
|
||||
E_DjiFlightControllerObstacleAvoidanceEnableStatus enableStatus;
|
||||
|
||||
djiStat = DjiFlightController_GetDownwardsVisualObstacleAvoidanceEnableStatus(&enableStatus);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("get downwards visual obstacle avoidance enable status error");
|
||||
}
|
||||
|
||||
djiStat = DjiAircraftInfo_GetBaseInfo(&aircraftInfoBaseInfo);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
@ -1272,11 +1273,20 @@ bool DjiTest_FlightControlGoHomeAndConfirmLanding(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!DjiTest_FlightControlCheckActionStarted(DJI_FC_SUBSCRIPTION_DISPLAY_MODE_FORCE_AUTO_LANDING)) {
|
||||
return false;
|
||||
if (enableStatus == DJI_FLIGHT_CONTROLLER_ENABLE_OBSTACLE_AVOIDANCE) {
|
||||
if (!DjiTest_FlightControlCheckActionStarted(DJI_FC_SUBSCRIPTION_DISPLAY_MODE_FORCE_AUTO_LANDING)) {
|
||||
return false;
|
||||
} else {
|
||||
while (DjiTest_FlightControlGetValueOfFlightStatus() == DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_IN_AIR &&
|
||||
DjiTest_FlightControlGetValueOfDisplayMode() ==
|
||||
DJI_FC_SUBSCRIPTION_DISPLAY_MODE_FORCE_AUTO_LANDING) {
|
||||
s_osalHandler->TaskSleepMs(1000);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (DjiTest_FlightControlGetValueOfFlightStatus() == DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_IN_AIR &&
|
||||
DjiTest_FlightControlGetValueOfDisplayMode() == DJI_FC_SUBSCRIPTION_DISPLAY_MODE_FORCE_AUTO_LANDING) {
|
||||
DjiTest_FlightControlGetValueOfDisplayMode() ==
|
||||
DJI_FC_SUBSCRIPTION_DISPLAY_MODE_FORCE_AUTO_LANDING) {
|
||||
s_osalHandler->TaskSleepMs(1000);
|
||||
}
|
||||
}
|
||||
@ -1454,11 +1464,12 @@ DjiTest_FlightControlMoveByPositionOffset(const T_DjiTestFlightControlVector3f o
|
||||
void DjiTest_FlightControlVelocityAndYawRateCtrl(const T_DjiTestFlightControlVector3f offsetDesired, float yawRate,
|
||||
uint32_t timeMs)
|
||||
{
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
uint32_t originTime = 0;
|
||||
uint32_t currentTime = 0;
|
||||
uint32_t elapsedTimeInMs = 0;
|
||||
s_osalHandler->GetTimeMs(&originTime);
|
||||
s_osalHandler->GetTimeMs(¤tTime);
|
||||
osalHandler->GetTimeMs(&originTime);
|
||||
osalHandler->GetTimeMs(¤tTime);
|
||||
elapsedTimeInMs = currentTime - originTime;
|
||||
T_DjiFlightControllerJoystickMode joystickMode = {
|
||||
DJI_FLIGHT_CONTROLLER_HORIZONTAL_VELOCITY_CONTROL_MODE,
|
||||
@ -1474,8 +1485,8 @@ void DjiTest_FlightControlVelocityAndYawRateCtrl(const T_DjiTestFlightControlVec
|
||||
|
||||
while (elapsedTimeInMs <= timeMs) {
|
||||
DjiFlightController_ExecuteJoystickAction(joystickCommand);
|
||||
s_osalHandler->TaskSleepMs(2);
|
||||
s_osalHandler->GetTimeMs(¤tTime);
|
||||
osalHandler->TaskSleepMs(2);
|
||||
osalHandler->GetTimeMs(¤tTime);
|
||||
elapsedTimeInMs = currentTime - originTime;
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,10 +44,20 @@ typedef enum {
|
||||
E_DJI_TEST_FLIGHT_CTRL_SAMPLE_SELECT_SET_GET_PARAM,
|
||||
} E_DjiTestFlightCtrlSampleSelect;
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
dji_f32_t x;
|
||||
dji_f32_t y;
|
||||
dji_f32_t z;
|
||||
} T_DjiTestFlightControlVector3f; // pack(1)
|
||||
#pragma pack()
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_FlightControlRunSample(E_DjiTestFlightCtrlSampleSelect flightCtrlSampleSelect);
|
||||
void DjiTest_FlightControlVelocityAndYawRateCtrl(const T_DjiTestFlightControlVector3f offsetDesired, float yawRate,
|
||||
uint32_t timeMs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -29,6 +29,8 @@
|
||||
#include "dji_platform.h"
|
||||
#include "dji_logger.h"
|
||||
#include "dji_gimbal_manager.h"
|
||||
#include "dji_fc_subscription.h"
|
||||
#include "dji_aircraft_info.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
@ -73,10 +75,26 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiGimbalManagerRotation rotation;
|
||||
T_DjiAircraftInfoBaseInfo baseInfo;
|
||||
E_DjiAircraftSeries aircraftSeries;
|
||||
|
||||
returnCode = DjiAircraftInfo_GetBaseInfo(&baseInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Failed to get aircraft base info, return code 0x%08X", returnCode);
|
||||
goto out;
|
||||
}
|
||||
|
||||
aircraftSeries = baseInfo.aircraftSeries;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("--> Step 1: Init gimbal manager module");
|
||||
DjiTest_WidgetLogAppend("--> Step 1: Init gimbal manager module");
|
||||
returnCode = DjiGimbalManager_Init();
|
||||
@ -99,7 +117,7 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
}
|
||||
|
||||
USER_LOG_INFO("--> Step 3: Reset gimbal angles.\r\n");
|
||||
returnCode = DjiGimbalManager_Reset(mountPosition);
|
||||
returnCode = DjiGimbalManager_Reset(mountPosition, DJI_GIMBAL_RESET_MODE_PITCH_AND_YAW);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Reset gimbal failed, error code: 0x%08X", returnCode);
|
||||
}
|
||||
@ -108,7 +126,7 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
for (int i = 0; i < sizeof(s_rotationActionList) / sizeof(T_DjiTestGimbalActionList); ++i) {
|
||||
if (s_rotationActionList[i].action == DJI_TEST_GIMBAL_RESET) {
|
||||
USER_LOG_INFO("Target gimbal reset.\r\n");
|
||||
returnCode = DjiGimbalManager_Reset(mountPosition);
|
||||
returnCode = DjiGimbalManager_Reset(mountPosition, DJI_GIMBAL_RESET_MODE_PITCH_AND_YAW);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Reset gimbal failed, error code: 0x%08X", returnCode);
|
||||
}
|
||||
@ -120,11 +138,22 @@ T_DjiReturnCode DjiTest_GimbalManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
continue;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Target gimbal pry = (%.1f, %.1f, %.1f)",
|
||||
s_rotationActionList[i].rotation.pitch, s_rotationActionList[i].rotation.roll,
|
||||
s_rotationActionList[i].rotation.yaw);
|
||||
|
||||
rotation = s_rotationActionList[i].rotation;
|
||||
|
||||
if (aircraftSeries == DJI_AIRCRAFT_SERIES_M3 || aircraftSeries == DJI_AIRCRAFT_SERIES_M30) {
|
||||
if (s_rotationActionList[i].rotation.rotationMode == DJI_GIMBAL_ROTATION_MODE_ABSOLUTE_ANGLE) {
|
||||
T_DjiFcSubscriptionGimbalAngles gimbalAngles = {0};
|
||||
T_DjiDataTimestamp timestamp = {0};
|
||||
returnCode = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_GIMBAL_ANGLES,
|
||||
(uint8_t *) &gimbalAngles,
|
||||
sizeof(T_DjiFcSubscriptionGimbalAngles),
|
||||
×tamp);
|
||||
rotation.yaw = gimbalAngles.z;
|
||||
}
|
||||
}
|
||||
|
||||
USER_LOG_INFO("Target gimbal pry = (%.1f, %.1f, %.1f)", rotation.pitch, rotation.roll, rotation.yaw);
|
||||
|
||||
returnCode = DjiGimbalManager_Rotate(mountPosition, rotation);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Target gimbal pry = (%.1f, %.1f, %.1f) failed, error code: 0x%08X",
|
||||
@ -136,6 +165,11 @@ 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);
|
||||
}
|
||||
|
||||
USER_LOG_INFO("--> Step 5: Deinit gimbal manager module");
|
||||
DjiTest_WidgetLogAppend("--> Step 5: Deinit gimbal manager module");
|
||||
returnCode = DjiGimbalManager_Deinit();
|
||||
|
||||
28290
samples/sample_c/module_sample/hms/data/hms_2023_05_18.json
Normal file
28290
samples/sample_c/module_sample/hms/data/hms_2023_05_18.json
Normal file
File diff suppressed because it is too large
Load Diff
30819
samples/sample_c/module_sample/hms/data/hms_2023_08_22.json
Normal file
30819
samples/sample_c/module_sample/hms/data/hms_2023_08_22.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -25,6 +25,8 @@
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <widget_interaction_test/test_widget_interaction.h>
|
||||
#include <utils/util_misc.h>
|
||||
#include <utils/cJSON.h>
|
||||
#include <utils/util_file.h>
|
||||
#include "test_hms.h"
|
||||
#include "dji_hms.h"
|
||||
#include "dji_hms_info_table.h"
|
||||
@ -52,28 +54,32 @@ static const char *oldReplaceComponentIndexStr = "%component_index";
|
||||
static T_DjiHmsFileBinaryArray s_EnHmsTextConfigFileBinaryArrayList[] = {
|
||||
{hms_text_config_json_fileName, hms_text_config_json_fileSize, hms_text_config_json_fileBinaryArray},
|
||||
};
|
||||
static bool s_hmsServiceRunFlag = false;
|
||||
static uint8_t *s_hmsJsonData = NULL;
|
||||
static E_DjiMobileAppLanguage s_hmsLanguage = DJI_MOBILE_APP_LANGUAGE_ENGLISH;
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_DjiReturnCode DjiTest_HmsInit(void);
|
||||
static T_DjiReturnCode DjiTest_HmsDeInit(void);
|
||||
static T_DjiReturnCode DjiTest_HmsManagerInit(void);
|
||||
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);
|
||||
static bool DjiTest_MarchErrCodeInfoTableByJson(T_DjiHmsInfoTable hmsInfoTable);
|
||||
static T_DjiReturnCode DjiTest_HmsInfoCallback(T_DjiHmsInfoTable hmsInfoTable);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_HmsRunSample(void)
|
||||
T_DjiReturnCode DjiTest_HmsManagerRunSample(E_DjiMobileAppLanguage language)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler;
|
||||
|
||||
s_hmsLanguage = language;
|
||||
|
||||
USER_LOG_INFO("Hms Sample Start");
|
||||
DjiTest_WidgetLogAppend("Hms Sample Start");
|
||||
|
||||
USER_LOG_INFO("--> Step 1: Init hms sample");
|
||||
DjiTest_WidgetLogAppend("--> Step 1: Init hms sample");
|
||||
returnCode = DjiTest_HmsInit();
|
||||
returnCode = DjiTest_HmsManagerInit();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Hms sample init error, error code:0x%08llX", returnCode);
|
||||
goto out;
|
||||
@ -82,7 +88,7 @@ T_DjiReturnCode DjiTest_HmsRunSample(void)
|
||||
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 = DjiHms_RegHmsInfoCallback(DjiTest_HmsInfoCallback);
|
||||
returnCode = DjiHmsManager_RegHmsInfoCallback(DjiTest_HmsInfoCallback);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Register callback function of push HMS information failed, error code:0x%08llX", returnCode);
|
||||
goto out;
|
||||
@ -93,7 +99,7 @@ T_DjiReturnCode DjiTest_HmsRunSample(void)
|
||||
out:
|
||||
USER_LOG_INFO("--> Step 3: Deinit hms sample");
|
||||
DjiTest_WidgetLogAppend("--> Step 3: Deinit hms sample");
|
||||
returnCode = DjiTest_HmsDeInit();
|
||||
returnCode = DjiTest_HmsManagerDeInit();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Hms sample deinit error, error code:0x%08llX", returnCode);
|
||||
}
|
||||
@ -104,7 +110,7 @@ out:
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
T_DjiReturnCode DjiTest_HmsStartService(void)
|
||||
T_DjiReturnCode DjiTest_HmsCustomizationStartService(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
@ -112,7 +118,7 @@ T_DjiReturnCode DjiTest_HmsStartService(void)
|
||||
char tempPath[HMS_DIR_PATH_LEN_MAX];
|
||||
#endif
|
||||
|
||||
returnCode = DjiHms_Init();
|
||||
returnCode = DjiHmsCustomization_Init();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Hms init error, error code:0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
@ -129,15 +135,15 @@ T_DjiReturnCode DjiTest_HmsStartService(void)
|
||||
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/en", curFileDirPath);
|
||||
|
||||
//set default hms text config path
|
||||
returnCode = DjiHms_RegDefaultHmsTextConfigByDirPath(tempPath);
|
||||
returnCode = DjiHmsCustomization_RegDefaultHmsTextConfigByDirPath(tempPath);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Add default hms text config error, stat = 0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
//set hms text config for English language
|
||||
returnCode = DjiHms_RegHmsTextConfigByDirPath(DJI_MOBILE_APP_LANGUAGE_ENGLISH,
|
||||
tempPath);
|
||||
returnCode = DjiHmsCustomization_RegHmsTextConfigByDirPath(DJI_MOBILE_APP_LANGUAGE_ENGLISH,
|
||||
tempPath);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Add hms text config error, stat = 0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
@ -145,8 +151,8 @@ T_DjiReturnCode DjiTest_HmsStartService(void)
|
||||
|
||||
//set hms text config for Chinese language
|
||||
snprintf(tempPath, HMS_DIR_PATH_LEN_MAX, "%shms_text/cn", curFileDirPath);
|
||||
returnCode = DjiHms_RegHmsTextConfigByDirPath(DJI_MOBILE_APP_LANGUAGE_CHINESE,
|
||||
tempPath);
|
||||
returnCode = DjiHmsCustomization_RegHmsTextConfigByDirPath(DJI_MOBILE_APP_LANGUAGE_CHINESE,
|
||||
tempPath);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Add hms text config error, stat = 0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
@ -159,7 +165,7 @@ T_DjiReturnCode DjiTest_HmsStartService(void)
|
||||
};
|
||||
|
||||
//set default hms text config
|
||||
returnCode = DjiHms_RegDefaultHmsTextConfigByBinaryArray(&enHmsTextBinaryArrayConfig);
|
||||
returnCode = DjiHmsCustomization_RegDefaultHmsTextConfigByBinaryArray(&enHmsTextBinaryArrayConfig);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Add default hms text config error, stat = 0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
@ -167,18 +173,21 @@ T_DjiReturnCode DjiTest_HmsStartService(void)
|
||||
#endif
|
||||
|
||||
#if DJI_CUSTOM_HMS_CODE_INJECT_ON
|
||||
DjiHms_InjectHmsErrorCode(0x1E020000, DJI_HMS_ERROR_LEVEL_FATAL);
|
||||
DjiHmsCustomization_InjectHmsErrorCode(0x1E020000, DJI_HMS_ERROR_LEVEL_FATAL);
|
||||
#endif
|
||||
|
||||
s_hmsServiceRunFlag = true;
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static T_DjiReturnCode DjiTest_HmsInit(void)
|
||||
static T_DjiReturnCode DjiTest_HmsManagerInit(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
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 = DjiFcSubscription_Init();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
@ -196,16 +205,38 @@ static T_DjiReturnCode DjiTest_HmsInit(void)
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
if (s_hmsServiceRunFlag == true) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
#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);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
return DjiHms_Init();
|
||||
snprintf(tempFileDirPath, HMS_DIR_PATH_LEN_MAX, "%s/data/hms_2023_08_22.json", curFileDirPath);
|
||||
|
||||
returnCode = UtilFile_GetFileSizeByPath(tempFileDirPath, &fileSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get file size by path failed, stat = 0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
USER_LOG_DEBUG("Hms json file size is %d", fileSize);
|
||||
|
||||
s_hmsJsonData = osalHandler->Malloc(fileSize);
|
||||
if (s_hmsJsonData == NULL) {
|
||||
USER_LOG_ERROR("Malloc failed.");
|
||||
}
|
||||
|
||||
UtilFile_GetFileDataByPath(tempFileDirPath, 0, fileSize, s_hmsJsonData, &readRealSize);
|
||||
#endif
|
||||
|
||||
return DjiHmsManager_Init();
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_HmsDeInit(void)
|
||||
static T_DjiReturnCode DjiTest_HmsManagerDeInit(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
returnCode = DjiFcSubscription_DeInit();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
@ -214,11 +245,11 @@ static T_DjiReturnCode DjiTest_HmsDeInit(void)
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
if (s_hmsServiceRunFlag == true) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
osalHandler->Free(s_hmsJsonData);
|
||||
#endif
|
||||
|
||||
return DjiHms_DeInit();
|
||||
return DjiHmsManager_DeInit();
|
||||
}
|
||||
|
||||
static T_DjiFcSubscriptionFlightStatus DjiTest_GetValueOfFlightStatus(void)
|
||||
@ -326,12 +357,67 @@ static bool DjiTest_MarchErrCodeInfoTable(T_DjiHmsInfoTable hmsInfoTable)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool DjiTest_MarchErrCodeInfoTableByJson(T_DjiHmsInfoTable hmsInfoTable)
|
||||
{
|
||||
cJSON *hmsJsonRoot = NULL;
|
||||
cJSON *hmsErrorCode = NULL;
|
||||
cJSON *hmsLanguage = NULL;
|
||||
char hmsErrorCodeString[HMS_DIR_PATH_LEN_MAX] = {0};
|
||||
|
||||
hmsJsonRoot = cJSON_Parse((char *) s_hmsJsonData);
|
||||
if (hmsJsonRoot == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < hmsInfoTable.hmsInfoNum; i++) {
|
||||
if (DjiTest_GetValueOfFlightStatus() == DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_IN_AIR) {
|
||||
sprintf(hmsErrorCodeString, "fpv_tip_0x%08X_in_the_sky", hmsInfoTable.hmsInfo[i].errorCode);
|
||||
} else {
|
||||
sprintf(hmsErrorCodeString, "fpv_tip_0x%08X", hmsInfoTable.hmsInfo[i].errorCode);
|
||||
}
|
||||
|
||||
hmsErrorCode = cJSON_GetObjectItem(hmsJsonRoot, hmsErrorCodeString);
|
||||
if (hmsErrorCode != NULL) {
|
||||
if (s_hmsLanguage == DJI_MOBILE_APP_LANGUAGE_CHINESE) {
|
||||
hmsLanguage = cJSON_GetObjectItem(hmsErrorCode, "zh");
|
||||
} else if (s_hmsLanguage == DJI_MOBILE_APP_LANGUAGE_ENGLISH) {
|
||||
hmsLanguage = cJSON_GetObjectItem(hmsErrorCode, "en");
|
||||
} else if (s_hmsLanguage == DJI_MOBILE_APP_LANGUAGE_JAPANESE) {
|
||||
hmsLanguage = cJSON_GetObjectItem(hmsErrorCode, "ja");
|
||||
} else if (s_hmsLanguage == DJI_MOBILE_APP_LANGUAGE_FRENCH) {
|
||||
hmsLanguage = cJSON_GetObjectItem(hmsErrorCode, "fr");
|
||||
}
|
||||
if (hmsLanguage != NULL) {
|
||||
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);
|
||||
} 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);
|
||||
}
|
||||
} else {
|
||||
USER_LOG_WARN("[ErrorCode: 0x%2x] There are no matching documents for this language for now.",
|
||||
hmsInfoTable.hmsInfo[i].errorCode);
|
||||
}
|
||||
} else {
|
||||
USER_LOG_WARN("[ErrorCode: 0x%2x] There are no matching documents in the current json for now.",
|
||||
hmsInfoTable.hmsInfo[i].errorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_HmsInfoCallback(T_DjiHmsInfoTable hmsInfoTable)
|
||||
{
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
DjiTest_MarchErrCodeInfoTableByJson(hmsInfoTable);
|
||||
#else
|
||||
if (!DjiTest_MarchErrCodeInfoTable(hmsInfoTable)) {
|
||||
USER_LOG_ERROR("March HMS Information failed.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (hmsInfoTable.hmsInfoNum == 0) {
|
||||
USER_LOG_INFO("All systems of drone are running well now.");
|
||||
|
||||
@ -39,8 +39,8 @@ extern "C" {
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_HmsRunSample(void);
|
||||
T_DjiReturnCode DjiTest_HmsStartService(void);
|
||||
T_DjiReturnCode DjiTest_HmsManagerRunSample(E_DjiMobileAppLanguage language);
|
||||
T_DjiReturnCode DjiTest_HmsCustomizationStartService(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -0,0 +1,131 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_interest_point.c
|
||||
* @brief
|
||||
*
|
||||
* @copyright (c) 2018 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "test_interest_point.h"
|
||||
#include "dji_interest_point.h"
|
||||
#include "dji_logger.h"
|
||||
#include "dji_flight_controller.h"
|
||||
#include "flight_control/test_flight_control.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
static T_DjiReturnCode DjiUser_InterestPointMissionStateCallback(T_DjiInterestPointMissionState missionState);
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_InterestPointRunSample(void)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiInterestPointSettings interestPointSettings = {0};
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
T_DjiFlightControllerRidInfo ridInfo = {0};
|
||||
|
||||
ridInfo.latitude = 22.542812;
|
||||
ridInfo.longitude = 113.958902;
|
||||
ridInfo.altitude = 10;
|
||||
|
||||
returnCode = DjiFlightController_Init(ridInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_INFO("Flight control init failed, errno=%lld", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
returnCode = DjiInterestPoint_Init();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_INFO("Point interest init failed, errno=%lld", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
DjiFlightController_ObtainJoystickCtrlAuthority();
|
||||
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
DjiFlightController_StartTakeoff();
|
||||
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
DjiTest_FlightControlVelocityAndYawRateCtrl((T_DjiTestFlightControlVector3f) {0, 0, 5}, 0, 10000);
|
||||
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
DjiTest_FlightControlVelocityAndYawRateCtrl((T_DjiTestFlightControlVector3f) {3, 0, 0}, 0, 5000);
|
||||
|
||||
interestPointSettings.latitude = 22.542812;
|
||||
interestPointSettings.longitude = 113.958902;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
returnCode = DjiInterestPoint_Start(interestPointSettings);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Point interest start failed, errno=%lld", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
DjiInterestPoint_SetSpeed(5.0f);
|
||||
|
||||
for (int i = 0; i < 60; ++i) {
|
||||
USER_LOG_ERROR("Interest point mission running %d.", i);
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
}
|
||||
|
||||
returnCode = DjiInterestPoint_Stop();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Point interest stop failed, errno=%lld", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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,
|
||||
missionState.curSpeed);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
@ -0,0 +1,49 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_interest_point.h
|
||||
* @brief This is the header file for "test_interest_point.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2018 DJI. All rights reserved.
|
||||
*
|
||||
* All information contained herein is, and remains, the property of DJI.
|
||||
* The intellectual and technical concepts contained herein are proprietary
|
||||
* to DJI and may be covered by U.S. and foreign patents, patents in process,
|
||||
* and protected by trade secret or copyright law. Dissemination of this
|
||||
* information, including but not limited to data and other proprietary
|
||||
* material(s) incorporated within the information, in any form, is strictly
|
||||
* prohibited without the express written consent of DJI.
|
||||
*
|
||||
* If you receive this source code without DJI’s authorization, you may not
|
||||
* further disseminate the information, and you must immediately remove the
|
||||
* source code and notify DJI of its removal. DJI reserves the right to pursue
|
||||
* legal actions against you for any loss(es) or damage(s) caused by your
|
||||
* failure to do so.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef TEST_INTEREST_POINT_H
|
||||
#define TEST_INTEREST_POINT_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_InterestPointRunSample(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_INTEREST_POINT_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
@ -32,22 +32,34 @@
|
||||
#include "dji_platform.h"
|
||||
#include "time_sync/test_time_sync.h"
|
||||
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
|
||||
#include "time.h"
|
||||
|
||||
#endif
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define POSITIONING_TASK_FREQ (1)
|
||||
#define POSITIONING_TASK_STACK_SIZE (1024)
|
||||
#define POSITIONING_TASK_STACK_SIZE (2048)
|
||||
#define TEST_RTCM_FILE_PATH_STR_MAX_SIZE (64)
|
||||
|
||||
#define DJI_TEST_POSITIONING_EVENT_COUNT (2)
|
||||
#define DJI_TEST_TIME_INTERVAL_AMONG_EVENTS_US (200000)
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static void *DjiTest_PositioningTask(void *arg);
|
||||
static T_DjiReturnCode DjiTest_ReceiveRtkOnAircraftRtcmDataCallback(uint8_t index, const uint8_t *data,
|
||||
uint16_t dataLen);
|
||||
static T_DjiReturnCode DjiTest_ReceiveRtkBaseStationRtcmDataCallback(uint8_t index, const uint8_t *data,
|
||||
uint16_t dataLen);
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
static T_DjiTaskHandle s_userPositioningThread;
|
||||
static int32_t s_eventIndex = 0;
|
||||
static char s_rtkOnAircraftRtcmFilePath[TEST_RTCM_FILE_PATH_STR_MAX_SIZE];
|
||||
static char s_rtkBaseStationRtcmFilePath[TEST_RTCM_FILE_PATH_STR_MAX_SIZE];
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_PositioningStartService(void)
|
||||
@ -63,12 +75,40 @@ T_DjiReturnCode DjiTest_PositioningStartService(void)
|
||||
|
||||
DjiPositioning_SetTaskIndex(0);
|
||||
|
||||
#ifndef SYSTEM_ARCH_LINUX
|
||||
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.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
#else
|
||||
time_t currentTime = time(NULL);
|
||||
struct tm *localTime = NULL;
|
||||
|
||||
localTime = localtime(¤tTime);
|
||||
sprintf(s_rtkOnAircraftRtcmFilePath, "rtk_on_aircraft_%04d%02d%02d_%02d-%02d-%02d.rtcm",
|
||||
localTime->tm_year + 1900, localTime->tm_mon + 1, localTime->tm_mday,
|
||||
localTime->tm_hour, localTime->tm_min, localTime->tm_sec);
|
||||
|
||||
localTime = localtime(¤tTime);
|
||||
sprintf(s_rtkBaseStationRtcmFilePath, "rtk_base_station_%04d%02d%02d_%02d-%02d-%02d.rtcm",
|
||||
localTime->tm_year + 1900, localTime->tm_mon + 1, localTime->tm_mday,
|
||||
localTime->tm_hour, localTime->tm_min, localTime->tm_sec);
|
||||
#endif
|
||||
djiStat = DjiPositioning_RegReceiveRtcmDataCallback(DJI_POSITIONING_RTCM_DATA_TYPE_RTK_BASE_STATION,
|
||||
DjiTest_ReceiveRtkBaseStationRtcmDataCallback);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Register receive rtk base station callback error.");
|
||||
return djiStat;
|
||||
}
|
||||
|
||||
djiStat = DjiPositioning_RegReceiveRtcmDataCallback(DJI_POSITIONING_RTCM_DATA_TYPE_RTK_ON_AIRCRAFT,
|
||||
DjiTest_ReceiveRtkOnAircraftRtcmDataCallback);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Register receive rtk on aircraft callback error.");
|
||||
return djiStat;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
@ -158,4 +198,51 @@ static void *DjiTest_PositioningTask(void *arg)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
static int32_t DjiTest_SaveRtcmData(char *filePath, const uint8_t *data, uint32_t len)
|
||||
{
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
FILE *fp = NULL;
|
||||
size_t size;
|
||||
|
||||
fp = fopen(filePath, "ab+");
|
||||
if (fp == NULL) {
|
||||
printf("fopen failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
size = fwrite(data, 1, len, fp);
|
||||
if (size != len) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fflush(fp);
|
||||
fclose(fp);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_ReceiveRtkOnAircraftRtcmDataCallback(uint8_t index, const uint8_t *data,
|
||||
uint16_t dataLen)
|
||||
{
|
||||
USER_LOG_INFO("Receive rtcm data from rtk on aircraft, index: %d, len: %d", index, dataLen);
|
||||
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
DjiTest_SaveRtcmData(s_rtkOnAircraftRtcmFilePath, data, dataLen);
|
||||
#endif
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_ReceiveRtkBaseStationRtcmDataCallback(uint8_t index, const uint8_t *data,
|
||||
uint16_t dataLen)
|
||||
{
|
||||
USER_LOG_INFO("Receive rtcm data from rtk base station, index: %d, len: %d", index, dataLen);
|
||||
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
DjiTest_SaveRtcmData(s_rtkBaseStationRtcmFilePath, data, dataLen);
|
||||
#endif
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
|
||||
2688
samples/sample_c/module_sample/utils/cJSON.c
Normal file
2688
samples/sample_c/module_sample/utils/cJSON.c
Normal file
File diff suppressed because it is too large
Load Diff
290
samples/sample_c/module_sample/utils/cJSON.h
Normal file
290
samples/sample_c/module_sample/utils/cJSON.h
Normal file
@ -0,0 +1,290 @@
|
||||
/*
|
||||
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef cJSON__h
|
||||
#define cJSON__h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
|
||||
|
||||
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
|
||||
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
|
||||
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
|
||||
|
||||
For *nix builds that support visibility attribute, you can define similar behavior by
|
||||
|
||||
setting default visibility to hidden by adding
|
||||
-fvisibility=hidden (for gcc)
|
||||
or
|
||||
-xldscope=hidden (for sun cc)
|
||||
to CFLAGS
|
||||
|
||||
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
|
||||
|
||||
*/
|
||||
|
||||
#define CJSON_CDECL __cdecl
|
||||
#define CJSON_STDCALL __stdcall
|
||||
|
||||
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
||||
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_EXPORT_SYMBOLS
|
||||
#endif
|
||||
|
||||
#if defined(CJSON_HIDE_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
||||
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
||||
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
||||
#endif
|
||||
#else /* !__WINDOWS__ */
|
||||
#define CJSON_CDECL
|
||||
#define CJSON_STDCALL
|
||||
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||
#else
|
||||
#define CJSON_PUBLIC(type) type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* project version */
|
||||
#define CJSON_VERSION_MAJOR 1
|
||||
#define CJSON_VERSION_MINOR 7
|
||||
#define CJSON_VERSION_PATCH 12
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_Invalid (0)
|
||||
#define cJSON_False (1 << 0)
|
||||
#define cJSON_True (1 << 1)
|
||||
#define cJSON_NULL (1 << 2)
|
||||
#define cJSON_Number (1 << 3)
|
||||
#define cJSON_String (1 << 4)
|
||||
#define cJSON_Array (1 << 5)
|
||||
#define cJSON_Object (1 << 6)
|
||||
#define cJSON_Raw (1 << 7) /* raw json */
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_StringIsConst 512
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON {
|
||||
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *next;
|
||||
struct cJSON *prev;
|
||||
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
struct cJSON *child;
|
||||
|
||||
/* The type of the item, as above. */
|
||||
int type;
|
||||
|
||||
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
|
||||
char *valuestring;
|
||||
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
|
||||
int valueint;
|
||||
/* The item's number, if type==cJSON_Number */
|
||||
double valuedouble;
|
||||
|
||||
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
char *string;
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks {
|
||||
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
|
||||
void *(CJSON_CDECL *malloc_fn)(size_t sz);
|
||||
void (CJSON_CDECL *free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
typedef int cJSON_bool;
|
||||
|
||||
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
|
||||
* This is to prevent stack overflows. */
|
||||
#ifndef CJSON_NESTING_LIMIT
|
||||
#define CJSON_NESTING_LIMIT 1000
|
||||
#endif
|
||||
|
||||
/* returns the version of cJSON as a string */
|
||||
CJSON_PUBLIC(const char*)cJSON_Version(void);
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks *hooks);
|
||||
|
||||
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
||||
CJSON_PUBLIC(cJSON *)cJSON_Parse(const char *value);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_ParseByJsonData(const uint8_t *json_data, uint16_t data_len);
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
||||
CJSON_PUBLIC(cJSON *)cJSON_ParseWithOpts(const char *value, const char **return_parse_end,
|
||||
cJSON_bool require_null_terminated);
|
||||
|
||||
/* Render a cJSON entity to text for transfer/storage. */
|
||||
CJSON_PUBLIC(char *)cJSON_Print(const cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. */
|
||||
CJSON_PUBLIC(char *)cJSON_PrintUnformatted(const cJSON *item);
|
||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||
CJSON_PUBLIC(char *)cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
||||
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
||||
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
|
||||
|
||||
/* Returns the number of items in an array (or object). */
|
||||
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
||||
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
|
||||
CJSON_PUBLIC(cJSON *)cJSON_GetArrayItem(const cJSON *array, int index);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
CJSON_PUBLIC(cJSON *)cJSON_GetObjectItem(const cJSON *const object, const char *const string);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_GetObjectItemCaseSensitive(const cJSON *const object, const char *const string);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
CJSON_PUBLIC(const char *)cJSON_GetErrorPtr(void);
|
||||
|
||||
/* Check if the item is a string and return its valuestring */
|
||||
CJSON_PUBLIC(char *)cJSON_GetStringValue(cJSON *item);
|
||||
|
||||
/* These functions check the type of an item */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON *const item);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateNull(void);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateTrue(void);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateFalse(void);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateBool(cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateNumber(double num);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateString(const char *string);
|
||||
/* raw json */
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateRaw(const char *raw);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateArray(void);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateObject(void);
|
||||
|
||||
/* Create a string where valuestring references a string so
|
||||
* it will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateStringReference(const char *string);
|
||||
/* Create an object/array that only references it's elements so
|
||||
* they will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateObjectReference(const cJSON *child);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateArrayReference(const cJSON *child);
|
||||
|
||||
/* These utilities create an Array of count items.
|
||||
* The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateIntArray(const int *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateFloatArray(const float *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_CreateStringArray(const char **strings, int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
|
||||
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
|
||||
* writing to `item->string` */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
|
||||
/* Remove/Detach items from Arrays/Objects. */
|
||||
CJSON_PUBLIC(cJSON *)cJSON_DetachItemViaPointer(cJSON *parent, cJSON *const item);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(cJSON *)cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
CJSON_PUBLIC(void)
|
||||
cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON *const parent, cJSON *const item, cJSON *replacement);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem);
|
||||
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
CJSON_PUBLIC(cJSON *)cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
* need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
* The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
||||
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON *const a, const cJSON *const b, const cJSON_bool case_sensitive);
|
||||
|
||||
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
|
||||
* The input pointer json cannot point to a read-only address area, such as a string constant,
|
||||
* but should point to a readable and writable adress area. */
|
||||
CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
||||
|
||||
/* Helper functions for creating and adding items to an object at the same time.
|
||||
* They return the added item or NULL on failure. */
|
||||
CJSON_PUBLIC(cJSON*)cJSON_AddNullToObject(cJSON *const object, const char *const name);
|
||||
CJSON_PUBLIC(cJSON*)cJSON_AddTrueToObject(cJSON *const object, const char *const name);
|
||||
CJSON_PUBLIC(cJSON*)cJSON_AddFalseToObject(cJSON *const object, const char *const name);
|
||||
CJSON_PUBLIC(cJSON*)cJSON_AddBoolToObject(cJSON *const object, const char *const name, const cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON*)cJSON_AddNumberToObject(cJSON *const object, const char *const name, const double number);
|
||||
CJSON_PUBLIC(cJSON*)cJSON_AddStringToObject(cJSON *const object, const char *const name, const char *const string);
|
||||
CJSON_PUBLIC(cJSON*)cJSON_AddRawToObject(cJSON *const object, const char *const name, const char *const raw);
|
||||
CJSON_PUBLIC(cJSON*)cJSON_AddObjectToObject(cJSON *const object, const char *const name);
|
||||
CJSON_PUBLIC(cJSON*)cJSON_AddArrayToObject(cJSON *const object, const char *const name);
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||
/* helper for the cJSON_SetNumberValue macro */
|
||||
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||
|
||||
/* Macro for iterating over an array or object */
|
||||
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||
|
||||
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
||||
CJSON_PUBLIC(void *)cJSON_malloc(size_t size);
|
||||
CJSON_PUBLIC(void) cJSON_free(void *object);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -89,8 +89,8 @@ T_DjiReturnCode UtilFile_GetFileSizeByPath(const char *filePath, uint32_t *fileS
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
T_DjiReturnCode UtilFile_GetFileDataByPath(const char *filePath, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen)
|
||||
T_DjiReturnCode UtilFile_GetFileDataByPath(const char *filePath, uint32_t offset, uint32_t len,
|
||||
uint8_t *data, uint32_t *realLen)
|
||||
{
|
||||
FILE *pF;
|
||||
T_DjiReturnCode psdkStat;
|
||||
|
||||
@ -52,8 +52,8 @@ typedef struct {
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode UtilFile_GetCreateTime(const char *filePath, T_UtilFileCreateTime *createTime);
|
||||
T_DjiReturnCode UtilFile_GetFileSizeByPath(const char *filePath, uint32_t *fileSize);
|
||||
T_DjiReturnCode UtilFile_GetFileDataByPath(const char *filePath, uint32_t offset, uint16_t len,
|
||||
uint8_t *data, uint16_t *realLen);
|
||||
T_DjiReturnCode UtilFile_GetFileDataByPath(const char *filePath, uint32_t offset, uint32_t len,
|
||||
uint8_t *data, uint32_t *realLen);
|
||||
T_DjiReturnCode DjiFile_Delete(const char *filePath);
|
||||
|
||||
T_DjiReturnCode UtilFile_GetFileSize(FILE *file, uint32_t *fileSize);
|
||||
|
||||
@ -384,6 +384,7 @@ static T_DjiReturnCode DjiTest_CheckFileMd5Sum(const char *path, uint8_t *buf, u
|
||||
file = fopen(path, "rb");
|
||||
if (file == NULL) {
|
||||
USER_LOG_ERROR("Open tts file error.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
@ -585,7 +586,7 @@ static T_DjiReturnCode SetVolume(uint8_t volume)
|
||||
(int32_t) realVolume);
|
||||
|
||||
returnCode = DjiUserUtil_RunSystemCmd(cmdStr);
|
||||
if (returnCode < 0) {
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Set widget speaker volume error: %d", ret);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -73,7 +73,7 @@ typedef enum {
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_TAKE_OFF_VELOCITY_CTRL_LANDING = 6,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_ARREST_FLYING = 7,
|
||||
E_DJI_SAMPLE_INDEX_FLIGHT_CONTROL_SET_GET_PARAM = 8,
|
||||
E_DJI_SAMPLE_INDEX_HMS = 9,
|
||||
E_DJI_SAMPLE_INDEX_HMS_MANAGER = 9,
|
||||
E_DJI_SAMPLE_INDEX_GIMBAL_MANAGER_FREE_MODE = 10,
|
||||
E_DJI_SAMPLE_INDEX_GIMBAL_MANAGER_YAW_FOLLOW_MODE = 11,
|
||||
E_DJI_SAMPLE_INDEX_LIVEVIEW = 12,
|
||||
@ -102,7 +102,7 @@ typedef enum {
|
||||
E_DJI_HMS_ERROR_CODE_INDEX3,
|
||||
E_DJI_HMS_ERROR_CODE_INDEX4,
|
||||
E_DJI_HMS_ERROR_CODE_INDEX5,
|
||||
}E_DjiExtensionPortHmsErrorCodeIndex;
|
||||
} E_DjiExtensionPortHmsErrorCodeIndex;
|
||||
|
||||
typedef enum {
|
||||
E_DJI_HMS_ERROR_LEVEL_INDEX1 = 0,
|
||||
@ -110,7 +110,7 @@ typedef enum {
|
||||
E_DJI_HMS_ERROR_LEVEL_INDEX3,
|
||||
E_DJI_HMS_ERROR_LEVEL_INDEX4,
|
||||
E_DJI_HMS_ERROR_LEVEL_INDEX5,
|
||||
}E_DjiExtensionPortHmsErrorLevelIndex;
|
||||
} E_DjiExtensionPortHmsErrorLevelIndex;
|
||||
|
||||
typedef struct {
|
||||
bool valid;
|
||||
@ -418,7 +418,7 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
DjiHms_InjectHmsErrorCode(errorCode, errorLevel);
|
||||
DjiHmsCustomization_InjectHmsErrorCode(errorCode, errorLevel);
|
||||
osalHandler->TaskSleepMs(500);
|
||||
s_isInjectErrcode = false;
|
||||
s_isEliminateErrcode = false;
|
||||
@ -444,7 +444,7 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
DjiHms_EliminateHmsErrorCode(errorCode);
|
||||
DjiHmsCustomization_EliminateHmsErrorCode(errorCode);
|
||||
osalHandler->TaskSleepMs(500);
|
||||
s_isInjectErrcode = false;
|
||||
s_isEliminateErrcode = false;
|
||||
@ -530,8 +530,8 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
|
||||
case E_DJI_SAMPLE_INDEX_GIMBAL_MANAGER_YAW_FOLLOW_MODE:
|
||||
DjiTest_GimbalManagerRunSample(s_mountPosition, DJI_GIMBAL_MODE_YAW_FOLLOW);
|
||||
break;
|
||||
case E_DJI_SAMPLE_INDEX_HMS:
|
||||
DjiTest_HmsRunSample();
|
||||
case E_DJI_SAMPLE_INDEX_HMS_MANAGER:
|
||||
DjiTest_HmsManagerRunSample(DJI_MOBILE_APP_LANGUAGE_ENGLISH);
|
||||
break;
|
||||
case E_DJI_SAMPLE_INDEX_LIVEVIEW:
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
|
||||
Reference in New Issue
Block a user