NEW: release DJI Payload-SDK version 3.8.1
This commit is contained in:
@ -45,6 +45,7 @@
|
||||
#define TEST_CAMERA_MOP_CHANNEL_WAIT_TIME_MS (3 * 1000)
|
||||
#define TEST_CAMERA_MOP_CHANNEL_MAX_RECV_COUNT 30
|
||||
#define TEST_CAMEAR_POINT_CLOUD_FILE_PATH_STR_MAX_SIZE 256
|
||||
#define TEST_CAMEAR_MEDIA_SUB_FILE_NOT_FOUND -1
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
@ -625,80 +626,6 @@ T_DjiReturnCode DjiTest_CameraManagerStartShootBurstPhoto(E_DjiMountPosition pos
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
/*! @brief Sample to shoot AEB photo, using async api
|
||||
*
|
||||
* @note In this interface, camera will be set to be the SHOOT_PHOTO mode
|
||||
* then start to shoot a AEB photo.
|
||||
* @param index payload node index, input limit see enum
|
||||
* DJI::OSDK::PayloadIndexType
|
||||
* @param photoNum The number of pictures in each AEB shooting
|
||||
* @return T_DjiReturnCode error code
|
||||
*/
|
||||
T_DjiReturnCode DjiTest_CameraManagerStartShootAEBPhoto(E_DjiMountPosition position,
|
||||
E_DjiCameraManagerPhotoAEBCount aebCount)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
E_DjiCameraManagerWorkMode workMode;
|
||||
|
||||
/*!< set camera work mode as shoot photo */
|
||||
USER_LOG_INFO("set mounted position %d camera's work mode as shoot photo mode.", position);
|
||||
returnCode = DjiCameraManager_SetMode(position, 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.", position, returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
|
||||
returnCode = DjiCameraManager_GetMode(position, &workMode);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS &&
|
||||
returnCode != DJI_ERROR_CAMERA_MANAGER_MODULE_CODE_UNSUPPORTED_COMMAND) {
|
||||
USER_LOG_ERROR("get mounted position %d camera's work mode failed,"
|
||||
" error code :0x%08X", position, returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
USER_LOG_INFO("Camera current workmode is %d", workMode);
|
||||
|
||||
/*!< set shoot-photo mode */
|
||||
USER_LOG_INFO("Set mounted position %d camera's shoot photo mode as AEB-photo mode", position);
|
||||
returnCode = DjiCameraManager_SetShootPhotoMode(position, DJI_CAMERA_MANAGER_SHOOT_PHOTO_MODE_AEB);
|
||||
if (returnCode == DJI_ERROR_CAMERA_MANAGER_MODULE_CODE_UNSUPPORTED_COMMAND) {
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("set mounted position %d camera's shoot photo mode as AEB-photo mode failed,"
|
||||
" error code :0x%08X.", position, returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
/*! wait the APP change the shoot-photo mode display */
|
||||
USER_LOG_INFO("Sleep 0.5s...");
|
||||
osalHandler->TaskSleepMs(500);
|
||||
|
||||
/*!< set shoot-photo mode parameter */
|
||||
USER_LOG_INFO("Set mounted position %d camera's AEB count to %d", position, aebCount);
|
||||
returnCode = DjiCameraManager_SetPhotoAEBCount(position, aebCount);
|
||||
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 AEB count(%d) failed,"
|
||||
" error code :0x%08X.", position, aebCount, returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
/*!< start to shoot single photo */
|
||||
USER_LOG_INFO("Mounted position %d camera start to shoot photo.", position);
|
||||
returnCode = DjiCameraManager_StartShootPhoto(position, DJI_CAMERA_MANAGER_SHOOT_PHOTO_MODE_AEB);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Mounted position %d camera shoot photo failed, "
|
||||
"error code :0x%08X.", position, returnCode);
|
||||
}
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
/*! @brief Sample to start shooting interval photo, using async api
|
||||
*
|
||||
* @note In this interface, camera will be set to be the SHOOT_PHOTO mode
|
||||
@ -1135,17 +1062,6 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
}
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_AEB_PHOTO: {
|
||||
USER_LOG_INFO("--> Function i: Shoot AEB photo with 3 pictures in one time");
|
||||
DjiTest_WidgetLogAppend("--> Function i: Shoot AEB photo with 3 pictures in one time");
|
||||
returnCode = DjiTest_CameraManagerStartShootAEBPhoto(mountPosition, DJI_CAMERA_MANAGER_PHOTO_AEB_COUNT_3);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Mounted position %d camera shoot AEB photo failed,"
|
||||
"error code: 0x%08X\r\n", mountPosition, returnCode);
|
||||
goto exitCameraModule;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_BURST_PHOTO: {
|
||||
USER_LOG_INFO("--> Function j: Shoot Burst photo with 5 pictures in one time");
|
||||
DjiTest_WidgetLogAppend("--> Function j: Shoot Burst photo with 5pictures in one time");
|
||||
@ -1487,12 +1403,6 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOW_STORAGE_INFO: {
|
||||
T_DjiCameraManagerStorageInfo storageInfo;
|
||||
|
||||
if (cameraType == DJI_CAMERA_TYPE_L1 || cameraType == DJI_CAMERA_TYPE_P1 ||
|
||||
cameraType == DJI_CAMERA_TYPE_M3D || cameraType == DJI_CAMERA_TYPE_M3TD) {
|
||||
USER_LOG_INFO("Position %d, camera type %d, doesn't support get storage info. Sample exits.");
|
||||
goto exitCameraModule;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 30; i++) {
|
||||
returnCode = DjiCameraManager_GetStorageInfo(mountPosition, &storageInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
@ -1775,7 +1685,7 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
returnCode = DjiCameraManager_GetPhotoFormatStorageRange(mountPosition, &photoFormatRange);
|
||||
returnCode = DjiCameraManager_GetPhotoStorageFormatRange(mountPosition, &photoFormatRange);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get range failed!");
|
||||
goto exitCameraModule;
|
||||
@ -2102,8 +2012,7 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
|
||||
uint16_t recordingTime;
|
||||
uint8_t remainingTime;
|
||||
|
||||
if (cameraType == DJI_CAMERA_TYPE_L1 || cameraType == DJI_CAMERA_TYPE_P1 ||
|
||||
cameraType == DJI_CAMERA_TYPE_M3D || cameraType == DJI_CAMERA_TYPE_M3TD) {
|
||||
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;
|
||||
@ -2192,6 +2101,8 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
uint16_t downloadCount = 0;
|
||||
uint16_t subFileDownloadCount = 0;
|
||||
int i = 0, j= 0;
|
||||
|
||||
s_nextDownloadFileIndex = 0;
|
||||
returnCode = DjiCameraManager_RegDownloadFileDataCallback(position, DjiTest_CameraManagerDownloadFileDataCallback);
|
||||
@ -2213,11 +2124,13 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
|
||||
|
||||
if (s_meidaFileList.totalCount > 0) {
|
||||
downloadCount = s_meidaFileList.totalCount;
|
||||
subFileDownloadCount = s_meidaFileList.fileListInfo->subFileListTotalNum;
|
||||
printf(
|
||||
"\033[1;33;40m -> Download file list finished, total file count is %d, the following %d is list details: \033[0m\r\n",
|
||||
"\033[1;33;40m -> Download file list finished, total media file count is %d "
|
||||
"the following %d is list details: \033[0m\r\n",
|
||||
s_meidaFileList.totalCount, downloadCount);
|
||||
for (int i = 0; i < downloadCount; ++i) {
|
||||
if (s_meidaFileList.fileListInfo[i].fileSize < 1 * 1024 * 1024) {
|
||||
|
||||
for (i = 0; i < downloadCount; ++i) {
|
||||
printf(
|
||||
"\033[1;32;40m ### Media file_%03d name: %s, index: %d, time:%04d-%02d-%02d_%02d:%02d:%02d, size: %.2f KB, type: %d \033[0m\r\n",
|
||||
i, s_meidaFileList.fileListInfo[i].fileName,
|
||||
@ -2228,21 +2141,23 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
|
||||
s_meidaFileList.fileListInfo[i].createTime.hour,
|
||||
s_meidaFileList.fileListInfo[i].createTime.minute,
|
||||
s_meidaFileList.fileListInfo[i].createTime.second,
|
||||
(dji_f32_t) s_meidaFileList.fileListInfo[i].fileSize / 1024,
|
||||
s_meidaFileList.fileListInfo[i].type);
|
||||
} else {
|
||||
printf(
|
||||
"\033[1;32;40m ### Media file_%03d name: %s, index: %d, time:%04d-%02d-%02d_%02d:%02d:%02d, size: %.2f MB, type: %d \033[0m\r\n",
|
||||
i, s_meidaFileList.fileListInfo[i].fileName,
|
||||
s_meidaFileList.fileListInfo[i].fileIndex,
|
||||
s_meidaFileList.fileListInfo[i].createTime.year,
|
||||
s_meidaFileList.fileListInfo[i].createTime.month,
|
||||
s_meidaFileList.fileListInfo[i].createTime.day,
|
||||
s_meidaFileList.fileListInfo[i].createTime.hour,
|
||||
s_meidaFileList.fileListInfo[i].createTime.minute,
|
||||
s_meidaFileList.fileListInfo[i].createTime.second,
|
||||
(dji_f32_t) s_meidaFileList.fileListInfo[i].fileSize / (1024 * 1024),
|
||||
(dji_f32_t) s_meidaFileList.fileListInfo[i].fileSize / (1024),
|
||||
s_meidaFileList.fileListInfo[i].type);
|
||||
if (s_meidaFileList.fileListInfo[i].type == DJI_CAMERA_FILE_TYPE_LDRT) {
|
||||
for (j = 0; j < s_meidaFileList.fileListInfo[i].subFileListTotalNum; j++) {
|
||||
printf(
|
||||
"\033[1;32;40m ### Media file_%03d, sub_file_%03d, name: %s, index: %d, time:%04d-%02d-%02d_%02d:%02d:%02d, size: %.2f KB, sub type: %d\033[0m\r\n",
|
||||
i, j, s_meidaFileList.fileListInfo[i].subFileListInfo[j].fileName,
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].fileIndex,
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].createTime.year,
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].createTime.month,
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].createTime.day,
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].createTime.hour,
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].createTime.minute,
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].createTime.second,
|
||||
(dji_f32_t) s_meidaFileList.fileListInfo[i].subFileListInfo[j].fileSize / (1024),
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].type);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("\r\n");
|
||||
@ -2251,24 +2166,38 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
|
||||
|
||||
downloadCount = s_meidaFileList.totalCount;
|
||||
|
||||
for (int i = 0; i < downloadCount; ++i) {
|
||||
redownload:
|
||||
for (i = 0; i < downloadCount; ++i) {
|
||||
redownload:
|
||||
if (i != s_nextDownloadFileIndex) {
|
||||
i = s_nextDownloadFileIndex;
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_DownloadFileByIndex(position, s_meidaFileList.fileListInfo[i].fileIndex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Download media file by index failed, error code: 0x%08X.", returnCode);
|
||||
s_nextDownloadFileIndex--;
|
||||
goto redownload;
|
||||
}
|
||||
if (s_meidaFileList.fileListInfo[i].type == DJI_CAMERA_FILE_TYPE_LDRT) {
|
||||
for (j = 0; j < s_meidaFileList.fileListInfo[i].subFileListTotalNum; j++) {
|
||||
subFileRedownload:
|
||||
returnCode = DjiCameraManager_DownloadSubFileByIndexAndSubType(position,
|
||||
s_meidaFileList.fileListInfo[i].fileIndex,
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].type);
|
||||
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Download sub media file by index and type failed, error code: 0x%08X.", returnCode);
|
||||
goto subFileRedownload;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
returnCode = DjiCameraManager_DeleteFileByIndex(position, s_meidaFileList.fileListInfo[0].fileIndex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Delete media file by index failed, error code: 0x%08X.", returnCode);
|
||||
return returnCode;
|
||||
if (s_meidaFileList.fileListInfo[0].type == DJI_CAMERA_FILE_TYPE_JPEG) {
|
||||
returnCode = DjiCameraManager_DeleteFileByIndex(position, s_meidaFileList.fileListInfo[0].fileIndex);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Delete media file by index failed, error code: 0x%08X.", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(1000);
|
||||
@ -2368,23 +2297,45 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadFileListBySlices(E_DjiM
|
||||
static T_DjiReturnCode DjiTest_CameraManagerDownloadFileDataCallback(T_DjiDownloadFilePacketInfo packetInfo,
|
||||
const uint8_t *data, uint16_t len)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t i =0, j = 0;
|
||||
float downloadSpeed = 0.0f;
|
||||
uint32_t mediaFileIndex = 0, mediaSubFileIndex = -1;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
if (packetInfo.downloadFileEvent == DJI_DOWNLOAD_FILE_EVENT_START) {
|
||||
for (i = 0; i < s_meidaFileList.totalCount; ++i) {
|
||||
if (s_meidaFileList.fileListInfo[i].fileIndex == packetInfo.fileIndex) {
|
||||
s_nextDownloadFileIndex = i + 1;
|
||||
break;
|
||||
memset(downloadFileName, 0, sizeof(downloadFileName));
|
||||
if (packetInfo.fileType == DJI_DOWNLOAD_FILE_ORG) {
|
||||
for (i = 0; i < s_meidaFileList.totalCount; ++i) {
|
||||
if (s_meidaFileList.fileListInfo[i].fileIndex == packetInfo.fileIndex) {
|
||||
snprintf(downloadFileName, sizeof(downloadFileName), "%s", s_meidaFileList.fileListInfo[i].fileName);
|
||||
mediaFileIndex = i;
|
||||
s_nextDownloadFileIndex = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < s_meidaFileList.totalCount; ++i) {
|
||||
for (j = 0; j < s_meidaFileList.fileListInfo[i].subFileListTotalNum; ++j) {
|
||||
if (s_meidaFileList.fileListInfo[i].subFileListInfo[j].fileIndex == packetInfo.fileIndex &&
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].type == packetInfo.fileType) {
|
||||
snprintf(downloadFileName, sizeof(downloadFileName), "%s",
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].fileName);
|
||||
mediaFileIndex = i;
|
||||
mediaSubFileIndex = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
osalHandler->GetTimeMs(&downloadStartMs);
|
||||
|
||||
memset(downloadFileName, 0, sizeof(downloadFileName));
|
||||
snprintf(downloadFileName, sizeof(downloadFileName), "%s", s_meidaFileList.fileListInfo[i].fileName);
|
||||
USER_LOG_INFO("Start download media file, index : %d, next download media file, index: %d", i,
|
||||
s_nextDownloadFileIndex);
|
||||
if (mediaSubFileIndex != TEST_CAMEAR_MEDIA_SUB_FILE_NOT_FOUND) {
|
||||
USER_LOG_INFO("Start download media sub file, index : %d, media file, index: %d", mediaSubFileIndex, mediaFileIndex);
|
||||
} else {
|
||||
USER_LOG_INFO("Start download media file, index : %d", mediaFileIndex);
|
||||
}
|
||||
|
||||
s_downloadMediaFile = fopen(downloadFileName, "wb+");
|
||||
if (s_downloadMediaFile == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
@ -2415,6 +2366,57 @@ static T_DjiReturnCode DjiTest_CameraManagerDownloadFileDataCallback(T_DjiDownlo
|
||||
USER_LOG_INFO("End download media file, Download Speed %.2f KB/S\r\n\r\n", downloadSpeed);
|
||||
fclose(s_downloadMediaFile);
|
||||
s_downloadMediaFile = NULL;
|
||||
} else if (packetInfo.downloadFileEvent == DJI_DOWNLOAD_FILE_EVENT_START_TRANSFER_END) {
|
||||
|
||||
memset(downloadFileName, 0, sizeof(downloadFileName));
|
||||
if (packetInfo.fileType == DJI_DOWNLOAD_FILE_ORG) {
|
||||
for (i = 0; i < s_meidaFileList.totalCount; ++i) {
|
||||
if (s_meidaFileList.fileListInfo[i].fileIndex == packetInfo.fileIndex) {
|
||||
snprintf(downloadFileName, sizeof(downloadFileName), "%s", s_meidaFileList.fileListInfo[i].fileName);
|
||||
mediaFileIndex = i;
|
||||
s_nextDownloadFileIndex = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < s_meidaFileList.totalCount; ++i) {
|
||||
for (j = 0; j < s_meidaFileList.fileListInfo[i].subFileListTotalNum; ++j) {
|
||||
if (s_meidaFileList.fileListInfo[i].subFileListInfo[j].fileIndex == packetInfo.fileIndex &&
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].type == packetInfo.fileType) {
|
||||
snprintf(downloadFileName, sizeof(downloadFileName), "%s",
|
||||
s_meidaFileList.fileListInfo[i].subFileListInfo[j].fileName);
|
||||
mediaFileIndex = i;
|
||||
mediaSubFileIndex = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mediaSubFileIndex != TEST_CAMEAR_MEDIA_SUB_FILE_NOT_FOUND) {
|
||||
USER_LOG_INFO("Start download media sub file, index : %d, media file, index: %d", mediaSubFileIndex, mediaFileIndex);
|
||||
} else {
|
||||
USER_LOG_INFO("Start download media file, index : %d", mediaFileIndex);
|
||||
}
|
||||
|
||||
s_downloadMediaFile = fopen(downloadFileName, "wb+");
|
||||
if (s_downloadMediaFile == NULL) {
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
fwrite(data, 1, len, s_downloadMediaFile);
|
||||
|
||||
printf("\033[1;32;40m ### [Complete rate : %0.1f%%] (%s), size: %u, mediaFileIndex: %d\033[0m\r\n",
|
||||
packetInfo.progressInPercent, downloadFileName, packetInfo.fileSize, packetInfo.fileIndex);
|
||||
printf("\033[1A");
|
||||
|
||||
downloadSpeed = (float) packetInfo.fileSize / 1.0;
|
||||
printf("\033[1;32;40m ### [Complete rate : %0.1f%%] (%s), size: %u, mediaFileIndex: %d\033[0m\r\n",
|
||||
packetInfo.progressInPercent, downloadFileName, packetInfo.fileSize, packetInfo.fileIndex);
|
||||
printf("\033[1A");
|
||||
printf("\r\n");
|
||||
USER_LOG_INFO("End download media file, Download Speed %.2f KB/S\r\n\r\n", downloadSpeed);
|
||||
fclose(s_downloadMediaFile);
|
||||
s_downloadMediaFile = NULL;
|
||||
}
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
@ -2550,6 +2552,7 @@ T_DjiReturnCode DjiTest_CameraManagerSubscribePointCloud(E_DjiMountPosition posi
|
||||
T_DjiCameraManagerColorPointCloud *colorPointCloud;
|
||||
uint32_t colorPointCloudDataByte = 0;
|
||||
uint32_t colorPointsNum = 0;
|
||||
static bool isMopInit = false;
|
||||
|
||||
returnCode = DjiCameraManager_StartRecordPointCloud(position);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
@ -2568,11 +2571,15 @@ T_DjiReturnCode DjiTest_CameraManagerSubscribePointCloud(E_DjiMountPosition posi
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
returnCode = DjiMopChannel_Init();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
fclose(fp);
|
||||
USER_LOG_ERROR("Mop channel init error, stat:0x%08llX.", returnCode);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
if (isMopInit == false) {
|
||||
returnCode = DjiMopChannel_Init();
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
fclose(fp);
|
||||
USER_LOG_ERROR("Mop channel init error, stat:0x%08llX.", returnCode);
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
} else {
|
||||
isMopInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
returnCode = DjiMopChannel_Create(&s_mopChannelHandle, DJI_MOP_CHANNEL_TRANS_UNRELIABLE);
|
||||
|
||||
@ -47,7 +47,6 @@ typedef enum {
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_CAMERA_TAP_ZOOM_POINT,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_CAMERA_ZOOM_PARAM,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_SINGLE_PHOTO,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_AEB_PHOTO,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_BURST_PHOTO,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_INTERVAL_PHOTO,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_RECORD_VIDEO,
|
||||
@ -223,18 +222,6 @@ T_DjiReturnCode DjiTest_CameraManagerStartShootSinglePhoto(E_DjiMountPosition po
|
||||
T_DjiReturnCode DjiTest_CameraManagerStartShootBurstPhoto(E_DjiMountPosition position,
|
||||
E_DjiCameraBurstCount burstCount);
|
||||
|
||||
/*! @brief Sample to shoot AEB photo, using async api
|
||||
*
|
||||
* @note In this interface, camera will be set to be the SHOOT_PHOTO mode
|
||||
* then start to shoot a AEB photo.
|
||||
* @param index payload node index, input limit see enum
|
||||
* DJI::OSDK::PayloadIndexType
|
||||
* @param photoNum The number of pictures in each AEB shooting
|
||||
* @return T_DjiReturnCode error code
|
||||
*/
|
||||
T_DjiReturnCode DjiTest_CameraManagerStartShootAEBPhoto(E_DjiMountPosition position,
|
||||
E_DjiCameraManagerPhotoAEBCount aebCount);
|
||||
|
||||
/*! @brief Sample to start shooting interval photo, using async api
|
||||
*
|
||||
* @note In this interface, camera will be set to be the SHOOT_PHOTO mode
|
||||
|
||||
@ -664,6 +664,7 @@ void DjiTest_FlightControlSetGetParamSample()
|
||||
E_DjiFlightControllerRtkPositionEnableStatus rtkEnableStatus;
|
||||
E_DjiFlightControllerRCLostAction rcLostAction;
|
||||
T_DjiAircraftInfoBaseInfo aircraftInfoBaseInfo;
|
||||
uint16_t countryCode;
|
||||
|
||||
returnCode = DjiAircraftInfo_GetBaseInfo(&aircraftInfoBaseInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
@ -673,6 +674,12 @@ void DjiTest_FlightControlSetGetParamSample()
|
||||
USER_LOG_INFO("Flight control set-get-param sample start");
|
||||
DjiTest_WidgetLogAppend("Flight control set-get-param sample start");
|
||||
|
||||
returnCode = DjiFlightController_GetCountryCode(&countryCode);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get aircraft country code error.");
|
||||
}
|
||||
USER_LOG_INFO("country code: %hd", countryCode);
|
||||
|
||||
/*! Turn on horizontal vision avoid enable */
|
||||
USER_LOG_INFO("--> Step 1: Turn on horizontal visual obstacle avoidance");
|
||||
DjiTest_WidgetLogAppend("--> Step 1: Turn on horizontal visual obstacle avoidance");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -212,7 +212,7 @@ static T_DjiReturnCode DjiTest_HmsManagerInit(void)
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
snprintf(tempFileDirPath, HMS_DIR_PATH_LEN_MAX, "%s/data/hms_2023_08_22.json", curFileDirPath);
|
||||
snprintf(tempFileDirPath, HMS_DIR_PATH_LEN_MAX, "%s/data/hms.json", curFileDirPath);
|
||||
|
||||
returnCode = UtilFile_GetFileSizeByPath(tempFileDirPath, &fileSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
|
||||
339
samples/sample_c/module_sample/utils/dji_config_manager.c
Normal file
339
samples/sample_c/module_sample/utils/dji_config_manager.c
Normal file
@ -0,0 +1,339 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_config_manager.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 <utils/util_misc.h>
|
||||
#include <dji_logger.h>
|
||||
#include <utils/util_file.h>
|
||||
#include <dji_aircraft_info.h>
|
||||
#include "dji_config_manager.h"
|
||||
#include "utils/cJSON.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
/* Private values -------------------------------------------------------------*/
|
||||
static T_DjiUserInfo s_configManagerUserInfo = {0};
|
||||
static T_DjiUserLinkConfig s_configManagerLinkInfo = {0};
|
||||
static bool s_configManagerIsEnable = false;
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_DjiReturnCode DjiUserConfigManager_GetAppInfoInner(const char *path, T_DjiUserInfo *userInfo);
|
||||
static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path, T_DjiUserLinkConfig *linkConfig);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
T_DjiReturnCode DjiUserConfigManager_LoadConfiguration(const char *path)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
|
||||
if (path == NULL) {
|
||||
perror("Config file path is null.\n");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
printf("Load configuration start, config file path is: %s\r\n", path);
|
||||
|
||||
returnCode = DjiUserConfigManager_GetAppInfoInner(path, &s_configManagerUserInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
perror("Get app info failed.\n");
|
||||
}
|
||||
|
||||
returnCode = DjiUserConfigManager_GetLinkConfigInner(path, &s_configManagerLinkInfo);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
perror("Get link info failed.\n");
|
||||
}
|
||||
|
||||
printf("\r\nLoad configuration successfully.\r\n");
|
||||
|
||||
s_configManagerIsEnable = true;
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void DjiUserConfigManager_GetAppInfo(T_DjiUserInfo *userInfo)
|
||||
{
|
||||
memcpy(userInfo, &s_configManagerUserInfo, sizeof(T_DjiUserInfo));
|
||||
}
|
||||
|
||||
void DjiUserConfigManager_GetLinkConfig(T_DjiUserLinkConfig *linkConfig)
|
||||
{
|
||||
memcpy(linkConfig, &s_configManagerLinkInfo, sizeof(T_DjiUserLinkConfig));
|
||||
}
|
||||
|
||||
bool DjiUserConfigManager_IsEnable(void)
|
||||
{
|
||||
return s_configManagerIsEnable;
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
static T_DjiReturnCode DjiUserConfigManager_GetAppInfoInner(const char *path, T_DjiUserInfo *userInfo)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
uint32_t fileSize = 0;
|
||||
uint32_t readRealSize = 0;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
uint8_t *jsonData = NULL;
|
||||
cJSON *jsonRoot = NULL;
|
||||
cJSON *jsonItem = NULL;
|
||||
cJSON *jsonValue = NULL;
|
||||
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
returnCode = UtilFile_GetFileSizeByPath(path, &fileSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get file size by path failed, stat = 0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
USER_LOG_DEBUG("Get config json file size is %d", fileSize);
|
||||
|
||||
jsonData = osalHandler->Malloc(fileSize + 1);
|
||||
if (jsonData == NULL) {
|
||||
USER_LOG_ERROR("Malloc failed.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
memset(jsonData, 0, fileSize);
|
||||
|
||||
UtilFile_GetFileDataByPath(path, 0, fileSize, jsonData, &readRealSize);
|
||||
|
||||
jsonData[readRealSize] = '\0';
|
||||
|
||||
jsonRoot = cJSON_Parse((char *) jsonData);
|
||||
if (jsonRoot == NULL) {
|
||||
returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
goto jsonDataFree;
|
||||
}
|
||||
|
||||
jsonItem = cJSON_GetObjectItem(jsonRoot, "dji_sdk_app_info");
|
||||
if (jsonItem != NULL) {
|
||||
jsonValue = cJSON_GetObjectItem(jsonItem, "user_app_name");
|
||||
if (jsonValue != NULL) {
|
||||
strcpy(userInfo->appName, jsonValue->valuestring);
|
||||
}
|
||||
|
||||
jsonValue = cJSON_GetObjectItem(jsonItem, "user_app_id");
|
||||
if (jsonValue != NULL) {
|
||||
strcpy(userInfo->appId, jsonValue->valuestring);
|
||||
}
|
||||
|
||||
jsonValue = cJSON_GetObjectItem(jsonItem, "user_app_key");
|
||||
if (jsonValue != NULL) {
|
||||
strcpy(userInfo->appKey, jsonValue->valuestring);
|
||||
}
|
||||
|
||||
jsonValue = cJSON_GetObjectItem(jsonItem, "user_app_license");
|
||||
if (jsonValue != NULL) {
|
||||
strcpy(userInfo->appLicense, jsonValue->valuestring);
|
||||
}
|
||||
|
||||
jsonValue = cJSON_GetObjectItem(jsonItem, "user_develop_account");
|
||||
if (jsonValue != NULL) {
|
||||
strcpy(userInfo->developerAccount, jsonValue->valuestring);
|
||||
}
|
||||
|
||||
jsonValue = cJSON_GetObjectItem(jsonItem, "user_baud_rate");
|
||||
if (jsonValue != NULL) {
|
||||
strcpy(userInfo->baudRate, jsonValue->valuestring);
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(userInfo->appName) >= sizeof(userInfo->appName) ||
|
||||
strlen(userInfo->appId) > sizeof(userInfo->appId) ||
|
||||
strlen(userInfo->appKey) > sizeof(userInfo->appKey) ||
|
||||
strlen(userInfo->appLicense) > sizeof(userInfo->appLicense) ||
|
||||
strlen(userInfo->developerAccount) >= sizeof(userInfo->developerAccount) ||
|
||||
strlen(userInfo->baudRate) > sizeof(userInfo->baudRate)) {
|
||||
USER_LOG_ERROR("Length of user information string is beyond limit. Please check.");
|
||||
returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
goto jsonDataFree;
|
||||
}
|
||||
|
||||
if (!strcmp(userInfo->appName, "your_app_name") ||
|
||||
!strcmp(userInfo->appId, "your_app_id") ||
|
||||
!strcmp(userInfo->appKey, "your_app_key") ||
|
||||
!strcmp(userInfo->appLicense, "your_app_license") ||
|
||||
!strcmp(userInfo->developerAccount, "your_developer_account") ||
|
||||
!strcmp(userInfo->baudRate, "your_baud_rate")) {
|
||||
USER_LOG_ERROR(
|
||||
"Please fill in correct user information to 'samples/sample_c++/platform/linux/manifold2/application/dji_sdk_config.json' file.");
|
||||
returnCode = DJI_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
goto jsonDataFree;
|
||||
}
|
||||
|
||||
jsonDataFree:
|
||||
osalHandler->Free(jsonData);
|
||||
#endif
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiUserConfigManager_GetLinkConfigInner(const char *path, T_DjiUserLinkConfig *linkConfig)
|
||||
{
|
||||
T_DjiReturnCode returnCode;
|
||||
uint32_t fileSize = 0;
|
||||
uint32_t readRealSize = 0;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
uint8_t *jsonData = NULL;
|
||||
cJSON *jsonRoot = NULL;
|
||||
cJSON *jsonItem = NULL;
|
||||
cJSON *jsonValue = NULL;
|
||||
cJSON *jsonConfig = NULL;
|
||||
int32_t configValue;
|
||||
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
|
||||
returnCode = UtilFile_GetFileSizeByPath(path, &fileSize);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get file size by path failed, stat = 0x%08llX", returnCode);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
USER_LOG_DEBUG("Get config json file size is %d", fileSize);
|
||||
|
||||
jsonData = osalHandler->Malloc(fileSize + 1);
|
||||
if (jsonData == NULL) {
|
||||
USER_LOG_ERROR("Malloc failed.");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
memset(jsonData, 0, fileSize);
|
||||
|
||||
UtilFile_GetFileDataByPath(path, 0, fileSize, jsonData, &readRealSize);
|
||||
|
||||
jsonData[readRealSize] = '\0';
|
||||
|
||||
jsonRoot = cJSON_Parse((char *) jsonData);
|
||||
if (jsonRoot == NULL) {
|
||||
goto jsonDataFree;
|
||||
}
|
||||
|
||||
jsonItem = cJSON_GetObjectItem(jsonRoot, "dji_sdk_link_config");
|
||||
if (jsonItem != NULL) {
|
||||
jsonValue = cJSON_GetObjectItem(jsonItem, "link_select");
|
||||
if (jsonValue != NULL) {
|
||||
printf("\r\nSelect link type: %s\r\n", jsonValue->valuestring);
|
||||
if (strcmp(jsonValue->valuestring, "use_only_uart") == 0) {
|
||||
linkConfig->type = DJI_USER_LINK_CONFIG_USE_ONLY_UART;
|
||||
} else if (strcmp(jsonValue->valuestring, "use_uart_and_network_device") == 0) {
|
||||
linkConfig->type = DJI_USER_LINK_CONFIG_USE_UART_AND_NETWORK_DEVICE;
|
||||
} else if (strcmp(jsonValue->valuestring, "use_uart_and_usb_bulk_device") == 0) {
|
||||
linkConfig->type = DJI_USER_LINK_CONFIG_USE_UART_AND_USB_BULK_DEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
jsonValue = cJSON_GetObjectItem(jsonItem, "uart_config");
|
||||
if (jsonValue != NULL) {
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "uart1_device_name");
|
||||
printf("\r\nConfig uart1 device name: %s\r\n", jsonConfig->valuestring);
|
||||
strcpy(linkConfig->uartConfig.uart1DeviceName, jsonConfig->valuestring);
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "uart2_device_name");
|
||||
printf("Config uart2 device name: %s\r\n", jsonConfig->valuestring);
|
||||
strcpy(linkConfig->uartConfig.uart2DeviceName, jsonConfig->valuestring);
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "uart2_device_enable");
|
||||
printf("Config uart2 device enable: %s\r\n", jsonConfig->valuestring);
|
||||
if (strcmp(jsonConfig->valuestring, "true") == 0) {
|
||||
linkConfig->uartConfig.uart2DeviceEnable = true;
|
||||
} else {
|
||||
linkConfig->uartConfig.uart2DeviceEnable = false;
|
||||
}
|
||||
}
|
||||
|
||||
jsonValue = cJSON_GetObjectItem(jsonItem, "network_config");
|
||||
if (jsonValue != NULL) {
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "network_device_name");
|
||||
printf("\r\nConfig network device name: %s\r\n", jsonConfig->valuestring);
|
||||
strcpy(linkConfig->networkConfig.networkDeviceName, jsonConfig->valuestring);
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "network_usb_adapter_vid");
|
||||
printf("Config network usb adapter vid: %s\r\n", jsonConfig->valuestring);
|
||||
sscanf(jsonConfig->valuestring, "%X", &configValue);
|
||||
linkConfig->networkConfig.networkUsbAdapterVid = configValue;
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "network_usb_adapter_pid");
|
||||
printf("Config network usb adapter vid: %s\r\n", jsonConfig->valuestring);
|
||||
sscanf(jsonConfig->valuestring, "%X", &configValue);
|
||||
linkConfig->networkConfig.networkUsbAdapterPid = configValue;
|
||||
}
|
||||
|
||||
jsonValue = cJSON_GetObjectItem(jsonItem, "usb_bulk_config");
|
||||
if (jsonValue != NULL) {
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_device_vid");
|
||||
printf("\r\nConfig usb device vid: %s\r\n", jsonConfig->valuestring);
|
||||
sscanf(jsonConfig->valuestring, "%X", &configValue);
|
||||
linkConfig->usbBulkConfig.usbDeviceVid = configValue;
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_device_pid");
|
||||
printf("Config usb device pid: %s\r\n", jsonConfig->valuestring);
|
||||
sscanf(jsonConfig->valuestring, "%X", &configValue);
|
||||
linkConfig->usbBulkConfig.usbDevicePid = configValue;
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk1_device_name");
|
||||
printf("Config usb bulk1 device name: %s\r\n", jsonConfig->valuestring);
|
||||
strcpy(linkConfig->usbBulkConfig.usbBulk1DeviceName, jsonConfig->valuestring);
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk1_interface_num");
|
||||
printf("Config usb bulk1 interface num: %s\r\n", jsonConfig->valuestring);
|
||||
sscanf(jsonConfig->valuestring, "%X", &configValue);
|
||||
linkConfig->usbBulkConfig.usbBulk1InterfaceNum = configValue;
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk1_endpoint_in");
|
||||
printf("Config usb bulk1 endpoint in: %s\r\n", jsonConfig->valuestring);
|
||||
sscanf(jsonConfig->valuestring, "%X", &configValue);
|
||||
linkConfig->usbBulkConfig.usbBulk1EndpointIn = configValue;
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk1_endpoint_out");
|
||||
printf("Config usb bulk1 endpoint out: %s\r\n", jsonConfig->valuestring);
|
||||
sscanf(jsonConfig->valuestring, "%X", &configValue);
|
||||
linkConfig->usbBulkConfig.usbBulk1EndpointOut = configValue;
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk2_device_name");
|
||||
printf("Config usb bulk2 device name: %s\r\n", jsonConfig->valuestring);
|
||||
strcpy(linkConfig->usbBulkConfig.usbBulk2DeviceName, jsonConfig->valuestring);
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk2_interface_num");
|
||||
printf("Config usb bulk2 interface num: %s\r\n", jsonConfig->valuestring);
|
||||
sscanf(jsonConfig->valuestring, "%X", &configValue);
|
||||
linkConfig->usbBulkConfig.usbBulk2InterfaceNum = configValue;
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk2_endpoint_in");
|
||||
printf("Config usb bulk2 endpoint in: %s\r\n", jsonConfig->valuestring);
|
||||
linkConfig->usbBulkConfig.usbBulk2EndpointIn = configValue;
|
||||
|
||||
jsonConfig = cJSON_GetObjectItem(jsonValue, "usb_bulk2_endpoint_out");
|
||||
printf("Config usb bulk2 endpoint out: %s\r\n", jsonConfig->valuestring);
|
||||
linkConfig->usbBulkConfig.usbBulk2EndpointOut = configValue;
|
||||
}
|
||||
}
|
||||
|
||||
jsonDataFree:
|
||||
osalHandler->Free(jsonData);
|
||||
#endif
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
88
samples/sample_c/module_sample/utils/dji_config_manager.h
Normal file
88
samples/sample_c/module_sample/utils/dji_config_manager.h
Normal file
@ -0,0 +1,88 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file dji_config_manager.h
|
||||
* @brief This is the header file for "dji_config_manager.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 DJI_CONFIG_MANAGER_H
|
||||
#define DJI_CONFIG_MANAGER_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_platform.h"
|
||||
#include "dji_core.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define USER_DEVICE_NAME_STR_MAX_SIZE (64)
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum {
|
||||
DJI_USER_LINK_CONFIG_USE_ONLY_UART,
|
||||
DJI_USER_LINK_CONFIG_USE_UART_AND_NETWORK_DEVICE,
|
||||
DJI_USER_LINK_CONFIG_USE_UART_AND_USB_BULK_DEVICE,
|
||||
} E_DjiUserLinkConfigType;
|
||||
|
||||
typedef struct {
|
||||
E_DjiUserLinkConfigType type;
|
||||
struct {
|
||||
char uart1DeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
|
||||
bool uart2DeviceEnable;
|
||||
char uart2DeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
|
||||
} uartConfig;
|
||||
struct {
|
||||
char networkDeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
|
||||
// M300/M350 RTK payload port no need
|
||||
uint16_t networkUsbAdapterVid;
|
||||
uint16_t networkUsbAdapterPid;
|
||||
} networkConfig;
|
||||
struct {
|
||||
uint16_t usbDeviceVid;
|
||||
uint16_t usbDevicePid;
|
||||
|
||||
char usbBulk1DeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
|
||||
uint8_t usbBulk1InterfaceNum;
|
||||
uint8_t usbBulk1EndpointIn;
|
||||
uint8_t usbBulk1EndpointOut;
|
||||
|
||||
char usbBulk2DeviceName[USER_DEVICE_NAME_STR_MAX_SIZE];
|
||||
uint8_t usbBulk2InterfaceNum;
|
||||
uint8_t usbBulk2EndpointIn;
|
||||
uint8_t usbBulk2EndpointOut;
|
||||
} usbBulkConfig;
|
||||
} T_DjiUserLinkConfig;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
T_DjiReturnCode DjiUserConfigManager_LoadConfiguration(const char *path);
|
||||
void DjiUserConfigManager_GetAppInfo(T_DjiUserInfo *userInfo);
|
||||
void DjiUserConfigManager_GetLinkConfig(T_DjiUserLinkConfig *linkConfig);
|
||||
bool DjiUserConfigManager_IsEnable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // DJI_CONFIG_MANAGER_H
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
||||
@ -42,6 +42,7 @@ static T_DjiWaypointV3MissionState s_lastWaypointV3MissionState = {0};
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
static T_DjiReturnCode DjiTest_WaypointV3MissionStateCallback(T_DjiWaypointV3MissionState missionState);
|
||||
static T_DjiReturnCode DjiTest_WaypointV3ActionStateCallback(T_DjiWaypointV3ActionState actionState);
|
||||
static T_DjiReturnCode DjiTest_WaypointV3WaitEndFlightStatus(T_DjiFcSubscriptionFlightStatus status);
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
T_DjiReturnCode DjiTest_WaypointV3RunSample(void)
|
||||
@ -136,8 +137,6 @@ T_DjiReturnCode DjiTest_WaypointV3RunSample(void)
|
||||
goto close_file;
|
||||
}
|
||||
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
|
||||
close_file:
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
returnCode = fclose(kmzFile);
|
||||
@ -155,21 +154,49 @@ close_file:
|
||||
goto out;
|
||||
}
|
||||
|
||||
do {
|
||||
osalHandler->TaskSleepMs(2000);
|
||||
USER_LOG_INFO("The aircraft is on the ground and motors are stoped...");
|
||||
returnCode = DjiTest_WaypointV3WaitEndFlightStatus(DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_STOPED);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Wait end flight status error.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
returnCode = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_STATUS_FLIGHT,
|
||||
(uint8_t *) &flightStatus,
|
||||
sizeof(T_DjiFcSubscriptionFlightStatus),
|
||||
&flightStatusTimestamp);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get value of topic flight status failed, error code:0x%08llX", returnCode);
|
||||
}
|
||||
USER_LOG_INFO("The aircraft is on the ground and motors are rotating...");
|
||||
returnCode = DjiTest_WaypointV3WaitEndFlightStatus(DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_ON_GROUND);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Wait end flight status error.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("flight status: %d", flightStatus);
|
||||
} while(flightStatus == DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_IN_AIR);
|
||||
USER_LOG_INFO("The aircraft is in the air...");
|
||||
returnCode = DjiTest_WaypointV3WaitEndFlightStatus(DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_IN_AIR);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Wait end flight status error.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("The aircraft is on the ground now.");
|
||||
USER_LOG_INFO("The aircraft is on the ground and motors are rotating...");
|
||||
returnCode = DjiTest_WaypointV3WaitEndFlightStatus(DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_ON_GROUND);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Wait end flight status error.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
returnCode = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_STATUS_FLIGHT,
|
||||
(uint8_t *) &flightStatus,
|
||||
sizeof(T_DjiFcSubscriptionFlightStatus),
|
||||
&flightStatusTimestamp);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get value of topic flight status failed, error code:0x%08llX", returnCode);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (flightStatus != DJI_FC_SUBSCRIPTION_FLIGHT_STATUS_STOPED) {
|
||||
USER_LOG_ERROR("Aircraft's flight status error, motors are not stoped.");
|
||||
goto out;
|
||||
}
|
||||
|
||||
USER_LOG_INFO("The aircraft is on the ground now, and motor are stoped.");
|
||||
|
||||
out:
|
||||
#ifdef SYSTEM_ARCH_LINUX
|
||||
@ -209,4 +236,25 @@ static T_DjiReturnCode DjiTest_WaypointV3ActionStateCallback(T_DjiWaypointV3Acti
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_WaypointV3WaitEndFlightStatus(T_DjiFcSubscriptionFlightStatus status) {
|
||||
T_DjiReturnCode returnCode;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
T_DjiDataTimestamp flightStatusTimestamp = {0};
|
||||
T_DjiFcSubscriptionFlightStatus flightStatus = 0;
|
||||
|
||||
do {
|
||||
osalHandler->TaskSleepMs(20);
|
||||
|
||||
returnCode = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_STATUS_FLIGHT,
|
||||
(uint8_t *)&flightStatus,
|
||||
sizeof(T_DjiFcSubscriptionFlightStatus),
|
||||
&flightStatusTimestamp);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get value of topic flight status failed, error code:0x%08llX", returnCode);
|
||||
}
|
||||
} while(flightStatus == status);
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||
|
||||
@ -87,12 +87,11 @@ typedef enum {
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_TAP_ZOOM = 20,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_OPTICAL_ZOOM = 21,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_SINGLE_PHOTO = 22,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_AEB_PHOTO = 23,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_BURST_PHOTO = 24,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_INTERVAL_PHOTO = 25,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_RECORDER_VIDEO = 26,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_MEDIA_DOWNLOAD = 27,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_THERMOMETRY = 28,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_BURST_PHOTO = 23,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_INTERVAL_PHOTO = 24,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_RECORDER_VIDEO = 25,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_MEDIA_DOWNLOAD = 26,
|
||||
E_DJI_SAMPLE_INDEX_CAMMGR_THERMOMETRY = 27,
|
||||
E_DJI_SAMPLE_INDEX_UNKNOWN = 0xFF,
|
||||
} E_DjiExtensionPortSampleIndex;
|
||||
|
||||
@ -583,10 +582,6 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
|
||||
DjiTest_CameraManagerRunSample(s_mountPosition,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_SINGLE_PHOTO);
|
||||
break;
|
||||
case E_DJI_SAMPLE_INDEX_CAMMGR_AEB_PHOTO:
|
||||
DjiTest_CameraManagerRunSample(s_mountPosition,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_AEB_PHOTO);
|
||||
break;
|
||||
case E_DJI_SAMPLE_INDEX_CAMMGR_BURST_PHOTO:
|
||||
DjiTest_CameraManagerRunSample(s_mountPosition,
|
||||
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SHOOT_BURST_PHOTO);
|
||||
|
||||
@ -205,22 +205,19 @@
|
||||
"item_name": "23_test_cammgr-single_photo"
|
||||
},
|
||||
{
|
||||
"item_name": "24_test_cammgr-AEB_photo"
|
||||
"item_name": "24_test_cammgr-burst_photo"
|
||||
},
|
||||
{
|
||||
"item_name": "25_test_cammgr-burst_photo"
|
||||
"item_name": "25_test_cammgr-interval_photo"
|
||||
},
|
||||
{
|
||||
"item_name": "26_test_cammgr-interval_photo"
|
||||
"item_name": "26_test_cammgr-recorder_video"
|
||||
},
|
||||
{
|
||||
"item_name": "27_test_cammgr-recorder_video"
|
||||
"item_name": "27_test_cammgr-media_download"
|
||||
},
|
||||
{
|
||||
"item_name": "28_test_cammgr-media_download"
|
||||
},
|
||||
{
|
||||
"item_name": "29_test_cammgr-thermometry"
|
||||
"item_name": "28_test_cammgr-thermometry"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@ -205,22 +205,19 @@
|
||||
"item_name": "23_test_cammgr-single_photo"
|
||||
},
|
||||
{
|
||||
"item_name": "24_test_cammgr-AEB_photo"
|
||||
"item_name": "24_test_cammgr-burst_photo"
|
||||
},
|
||||
{
|
||||
"item_name": "25_test_cammgr-burst_photo"
|
||||
"item_name": "25_test_cammgr-interval_photo"
|
||||
},
|
||||
{
|
||||
"item_name": "26_test_cammgr-interval_photo"
|
||||
"item_name": "26_test_cammgr-recorder_video"
|
||||
},
|
||||
{
|
||||
"item_name": "27_test_cammgr-recorder_video"
|
||||
"item_name": "27_test_cammgr-media_download"
|
||||
},
|
||||
{
|
||||
"item_name": "28_test_cammgr-media_download"
|
||||
},
|
||||
{
|
||||
"item_name": "29_test_cammgr-thermometry"
|
||||
"item_name": "28_test_cammgr-thermometry"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user