NEW: release DJI Payload-SDK version 3.7

Signed-off-by: Martin <Martin@dji.com>
This commit is contained in:
Martin
2023-10-31 22:16:41 +08:00
parent 5c4ba38136
commit be3a925185
44 changed files with 1949 additions and 1738 deletions

View File

@ -82,7 +82,7 @@ T_DjiReturnCode DjiMediaFile_GetAttrFunc_JPG(struct _DjiMediaFile *mediaFileHand
}
T_DjiReturnCode DjiMediaFile_GetDataOrigin_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
uint8_t *data, uint16_t *realLen)
uint8_t *data, uint32_t *realLen)
{
return UtilFile_GetFileDataByPath(mediaFileHandle->filePath, offset, len, data, realLen);
}

View File

@ -49,7 +49,7 @@ T_DjiReturnCode DjiMediaFile_GetAttrFunc_JPG(struct _DjiMediaFile *mediaFileHand
T_DjiCameraMediaFileAttr *mediaFileAttr);
T_DjiReturnCode DjiMediaFile_GetDataOrigin_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
uint8_t *data, uint16_t *realLen);
uint8_t *data, uint32_t *realLen);
T_DjiReturnCode DjiMediaFile_GetFileSizeOrigin_JPG(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
T_DjiReturnCode DjiMediaFile_CreateThumbNail_JPG(struct _DjiMediaFile *mediaFileHandle);

View File

@ -115,7 +115,7 @@ out:
}
T_DjiReturnCode DjiMediaFile_GetDataOrigin_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
uint8_t *data, uint16_t *realLen)
uint8_t *data, uint32_t *realLen)
{
return UtilFile_GetFileDataByPath(mediaFileHandle->filePath, offset, len, data, realLen);
}

View File

@ -49,7 +49,7 @@ T_DjiReturnCode DjiMediaFile_GetAttrFunc_MP4(struct _DjiMediaFile *mediaFileHand
T_DjiCameraMediaFileAttr *mediaFileAttr);
T_DjiReturnCode DjiMediaFile_GetDataOrigin_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t offset, uint16_t len,
uint8_t *data, uint16_t *realLen);
uint8_t *data, uint32_t *realLen);
T_DjiReturnCode DjiMediaFile_GetFileSizeOrigin_MP4(struct _DjiMediaFile *mediaFileHandle, uint32_t *fileSize);
T_DjiReturnCode DjiMediaFile_CreateThumbNail_MP4(struct _DjiMediaFile *mediaFileHandle);

View File

@ -127,6 +127,7 @@ static T_DjiPlaybackInfo s_playbackInfo = {0};
static T_DjiTaskHandle s_userSendVideoThread;
static T_UtilBuffer s_mediaPlayCommandBufferHandler = {0};
static T_DjiMutexHandle s_mediaPlayCommandBufferMutex = {0};
static T_DjiSemaHandle s_mediaPlayWorkSem = NULL;
static uint8_t s_mediaPlayCommandBuffer[sizeof(T_TestPayloadCameraPlaybackCommand) * 32] = {0};
static const char *s_frameKeyChar = "[PACKET]";
static const char *s_frameDurationTimeKeyChar = "duration_time";
@ -179,6 +180,11 @@ T_DjiReturnCode DjiTest_CameraEmuMediaStartService(void)
s_psdkCameraMedia.StartDownloadNotification = StartDownloadNotification;
s_psdkCameraMedia.StopDownloadNotification = StopDownloadNotification;
if (DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS != osalHandler->SemaphoreCreate(0, &s_mediaPlayWorkSem)) {
USER_LOG_ERROR("SemaphoreCreate(\"%s\") error.", "s_mediaPlayWorkSem");
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
if (osalHandler->MutexCreate(&s_mediaPlayCommandBufferMutex) != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("mutex create error");
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
@ -303,6 +309,7 @@ static T_DjiReturnCode DjiPlayback_PausePlay(T_DjiPlaybackInfo *playbackInfo)
USER_LOG_ERROR("mutex unlock error");
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
osalHandler->SemaphorePost(s_mediaPlayWorkSem);
}
playbackInfo->isInPlayProcess = 0;
@ -485,7 +492,7 @@ static T_DjiReturnCode DjiPlayback_StartPlayProcess(const char *filePath, uint32
USER_LOG_ERROR("mutex unlock error");
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
osalHandler->SemaphorePost(s_mediaPlayWorkSem);
return returnCode;
}
@ -514,7 +521,7 @@ static T_DjiReturnCode DjiPlayback_StopPlayProcess(void)
USER_LOG_ERROR("mutex unlock error");
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
osalHandler->SemaphorePost(s_mediaPlayWorkSem);
return returnCode;
}
@ -1160,10 +1167,13 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
int lengthOfDataHaveBeenSent = 0;
char *dataBuffer = NULL;
T_TestPayloadCameraPlaybackCommand playbackCommand = {0};
uint16_t bufferReadSize = 0;
uint16_t bufferReadSize = 0;
char *videoFilePath = NULL;
char *transcodedFilePath = NULL;
float frameRate = 1.0f;
uint32_t waitDuration = 1000 / SEND_VIDEO_TASK_FREQ;
uint32_t rightNow = 0;
uint32_t sendExpect = 0;
T_TestPayloadCameraVideoFrameInfo *frameInfo = NULL;
uint32_t frameNumber = 0;
uint32_t frameCount = 0;
@ -1216,8 +1226,16 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
exit(1);
}
(void)osalHandler->GetTimeMs(&rightNow);
sendExpect = rightNow + waitDuration;
while (1) {
osalHandler->TaskSleepMs(1000 / SEND_VIDEO_TASK_FREQ);
(void)osalHandler->GetTimeMs(&rightNow);
if (sendExpect > rightNow) {
waitDuration = sendExpect - rightNow;
} else {
waitDuration = 1000 / SEND_VIDEO_TASK_FREQ;
}
(void)osalHandler->SemaphoreTimedWait(s_mediaPlayWorkSem, waitDuration);
// response playback command
if (osalHandler->MutexLock(s_mediaPlayCommandBufferMutex) != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -1295,94 +1313,94 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
continue;
}
send:
if (fpFile == NULL) {
USER_LOG_ERROR("open video file fail.");
continue;
}
if (sendVideoFlag != true)
continue;
returnCode = DjiTest_CameraGetMode(&mode);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
continue;
}
returnCode = DjiTest_CameraGetVideoStreamType(&videoStreamType);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
continue;
}
if (mode == DJI_CAMERA_MODE_PLAYBACK && s_playbackInfo.isInPlayProcess == false) {
continue;
}
if (!USER_UTIL_IS_WORK_TURN(sendVideoStep++, frameRate, SEND_VIDEO_TASK_FREQ))
continue;
frameBufSize = frameInfo[frameNumber].size;
if (videoStreamType == DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) {
frameBufSize = frameBufSize + VIDEO_FRAME_AUD_LEN;
}
dataBuffer = calloc(frameBufSize, 1);
if (dataBuffer == NULL) {
USER_LOG_ERROR("malloc fail.");
goto free;
}
ret = fseek(fpFile, frameInfo[frameNumber].positionInFile, SEEK_SET);
if (ret != 0) {
USER_LOG_ERROR("fseek fail.");
goto free;
}
dataLength = fread(dataBuffer, 1, frameInfo[frameNumber].size, fpFile);
if (dataLength != frameInfo[frameNumber].size) {
USER_LOG_ERROR("read data from video file error.");
} else {
USER_LOG_DEBUG("read data from video file success, len = %d B\r\n", dataLength);
}
if (videoStreamType == DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) {
memcpy(&dataBuffer[frameInfo[frameNumber].size], s_frameAudInfo, VIDEO_FRAME_AUD_LEN);
dataLength = dataLength + VIDEO_FRAME_AUD_LEN;
}
lengthOfDataHaveBeenSent = 0;
while (dataLength - lengthOfDataHaveBeenSent) {
lengthOfDataToBeSent = USER_UTIL_MIN(DATA_SEND_FROM_VIDEO_STREAM_MAX_LEN,
dataLength - lengthOfDataHaveBeenSent);
returnCode = DjiPayloadCamera_SendVideoStream((const uint8_t *) dataBuffer + lengthOfDataHaveBeenSent,
lengthOfDataToBeSent);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("send video stream error: 0x%08llX.", returnCode);
send:
if (fpFile == NULL) {
USER_LOG_ERROR("open video file fail.");
continue;
}
lengthOfDataHaveBeenSent += lengthOfDataToBeSent;
}
if ((frameNumber++) >= frameCount) {
USER_LOG_DEBUG("reach file tail.");
frameNumber = 0;
if (sendVideoFlag != true)
continue;
if (sendOneTimeFlag == true)
sendVideoFlag = false;
}
returnCode = DjiTest_CameraGetMode(&mode);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
continue;
}
returnCode = DjiPayloadCamera_GetVideoStreamState(&videoStreamState);
if (returnCode == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_DEBUG(
"video stream state: realtimeBandwidthLimit: %d, realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController:%d busyState: %d.",
videoStreamState.realtimeBandwidthLimit, videoStreamState.realtimeBandwidthBeforeFlowController,
videoStreamState.realtimeBandwidthAfterFlowController,
videoStreamState.busyState);
} else {
USER_LOG_ERROR("get video stream state error.");
}
returnCode = DjiTest_CameraGetVideoStreamType(&videoStreamType);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
continue;
}
free:
free(dataBuffer);
if (mode == DJI_CAMERA_MODE_PLAYBACK && s_playbackInfo.isInPlayProcess == false) {
continue;
}
frameBufSize = frameInfo[frameNumber].size;
if (videoStreamType == DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) {
frameBufSize = frameBufSize + VIDEO_FRAME_AUD_LEN;
}
dataBuffer = calloc(frameBufSize, 1);
if (dataBuffer == NULL) {
USER_LOG_ERROR("malloc fail.");
goto free;
}
ret = fseek(fpFile, frameInfo[frameNumber].positionInFile, SEEK_SET);
if (ret != 0) {
USER_LOG_ERROR("fseek fail.");
goto free;
}
dataLength = fread(dataBuffer, 1, frameInfo[frameNumber].size, fpFile);
if (dataLength != frameInfo[frameNumber].size) {
USER_LOG_ERROR("read data from video file error.");
} else {
USER_LOG_DEBUG("read data from video file success, len = %d B\r\n", dataLength);
}
if (videoStreamType == DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) {
memcpy(&dataBuffer[frameInfo[frameNumber].size], s_frameAudInfo, VIDEO_FRAME_AUD_LEN);
dataLength = dataLength + VIDEO_FRAME_AUD_LEN;
}
lengthOfDataHaveBeenSent = 0;
while (dataLength - lengthOfDataHaveBeenSent) {
lengthOfDataToBeSent = USER_UTIL_MIN(DATA_SEND_FROM_VIDEO_STREAM_MAX_LEN,
dataLength - lengthOfDataHaveBeenSent);
returnCode = DjiPayloadCamera_SendVideoStream((const uint8_t *) dataBuffer + lengthOfDataHaveBeenSent,
lengthOfDataToBeSent);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("send video stream error: 0x%08llX.", returnCode);
}
lengthOfDataHaveBeenSent += lengthOfDataToBeSent;
}
(void)osalHandler->GetTimeMs(&sendExpect);
sendExpect += (1000 / frameRate);
if ((frameNumber++) >= frameCount) {
USER_LOG_DEBUG("reach file tail.");
frameNumber = 0;
if (sendOneTimeFlag == true)
sendVideoFlag = false;
}
returnCode = DjiPayloadCamera_GetVideoStreamState(&videoStreamState);
if (returnCode == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_DEBUG(
"video stream state: realtimeBandwidthLimit: %d, realtimeBandwidthBeforeFlowController: %d, realtimeBandwidthAfterFlowController:%d busyState: %d.",
videoStreamState.realtimeBandwidthLimit, videoStreamState.realtimeBandwidthBeforeFlowController,
videoStreamState.realtimeBandwidthAfterFlowController,
videoStreamState.busyState);
} else {
USER_LOG_ERROR("get video stream state error.");
}
free:
free(dataBuffer);
}
}

View File

@ -25,10 +25,12 @@
/* Includes ------------------------------------------------------------------*/
#include <widget_interaction_test/test_widget_interaction.h>
#include <utils/util_misc.h>
#include <time.h>
#include "test_camera_manager.h"
#include "dji_camera_manager.h"
#include "dji_platform.h"
#include "dji_logger.h"
#include "dji_mop_channel.h"
/* Private constants ---------------------------------------------------------*/
#define TEST_CAMERA_MANAGER_MEDIA_FILE_NAME_MAX_SIZE 256
@ -37,6 +39,12 @@
#define TEST_CAMERA_MAX_INFRARED_ZOOM_FACTOR 8
#define TEST_CAMERA_MIN_INFRARED_ZOOM_FACTOR 2
#define TEST_CAMERA_MOP_CHANNEL_SUBSCRIBE_POINT_CLOUD_CHANNEL_ID 49152
#define TEST_CAMERA_MOP_CHANNEL_SUBSCRIBE_POINT_CLOUD_RECV_BUFFER (512 * 1024)
#define TEST_CAMERA_MOP_CHANNEL_COLOR_POINTS_BUFFER (512 * 1024)
#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
/* Private types -------------------------------------------------------------*/
typedef struct {
@ -55,6 +63,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"},
@ -68,6 +77,8 @@ static uint32_t downloadStartMs = 0;
static uint32_t downloadEndMs = 0;
static char downloadFileName[TEST_CAMERA_MANAGER_MEDIA_FILE_NAME_MAX_SIZE] = {0};
static uint32_t s_nextDownloadFileIndex = 0;
static T_DjiMopChannelHandle s_mopChannelHandle;
static char s_pointCloudFilePath[TEST_CAMEAR_POINT_CLOUD_FILE_PATH_STR_MAX_SIZE];
/* Private functions declaration ---------------------------------------------*/
static uint8_t DjiTest_CameraManagerGetCameraTypeIndex(E_DjiCameraType cameraType);
@ -79,6 +90,7 @@ static T_DjiReturnCode DjiTest_CameraManagerGetAreaThermometryData(E_DjiMountPos
static T_DjiReturnCode DjiTest_CameraManagerGetPointThermometryData(E_DjiMountPosition position);
static T_DjiReturnCode DjiTest_CameraManagerGetLidarRangingInfo(E_DjiMountPosition position);
T_DjiReturnCode DjiTest_CameraManagerSubscribePointCloud(E_DjiMountPosition position);
/* Exported functions definition ---------------------------------------------*/
/*! @brief Sample to set EV for camera, using async api
@ -906,7 +918,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_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 +958,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,
@ -1251,9 +1264,10 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
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_M3E ||
cameraType == DJI_CAMERA_TYPE_M3T) {
USER_LOG_INFO("Camera type %d does not support night scene mode!", cameraType);
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 %s does not support night scene mode!",
s_cameraTypeStrList[DjiTest_CameraManagerGetCameraTypeIndex(cameraType)].cameraTypeStr);
goto exitCameraModule;
}
@ -1355,8 +1369,8 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
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);
USER_LOG_INFO("Camera type %s does not support set capture or recording stream(s) to storage.",
s_cameraTypeStrList[DjiTest_CameraManagerGetCameraTypeIndex(cameraType)].cameraTypeStr);
goto exitCameraModule;
}
@ -1684,9 +1698,9 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
osalHandler->TaskSleepMs(10);
printf("Input focus ring value to set: ");
scanf("%d", &focusRingValue);
scanf("%hd", &focusRingValue);
USER_LOG_INFO("Try to set focus ring value as %d", focusRingValue);
USER_LOG_INFO("Try to set focus ring value as %hd", 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);
@ -1936,6 +1950,7 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
}
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_METERING_POINT: {
int32_t x, y;
uint8_t getX, getY;
uint8_t horizonRegionNum;
uint8_t viticalRegionNum;
@ -1965,24 +1980,26 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
osalHandler->TaskSleepMs(500);
returnCode = DjiCameraManager_GetMeteringPoint(mountPosition, &x, &y);
returnCode = DjiCameraManager_GetMeteringPoint(mountPosition, &getX, &getY);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get metering point failed");
goto exitCameraModule;
}
USER_LOG_INFO("Current metering point: (%d, %d)", x, y);
USER_LOG_INFO("Current metering point: (%d, %d)", getX, getY);
break;
}
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_FFC_MODE_AND_TRRIGER: {
E_DjiCameraManagerFfcMode ffcMode;
uint32_t 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);
cameraType == DJI_CAMERA_TYPE_M3E ||
cameraType == DJI_CAMERA_TYPE_L2) {
USER_LOG_WARN("Camera type %s don't support FFC function.",
s_cameraTypeStrList[DjiTest_CameraManagerGetCameraTypeIndex(cameraType)].cameraTypeStr);
goto exitCameraModule;
}
@ -2000,7 +2017,7 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
}
}
returnCode = DjiCameraManager_SetFfcMode(mountPosition, ffcMode);
returnCode = DjiCameraManager_SetFfcMode(mountPosition, (E_DjiCameraManagerFfcMode)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);
@ -2019,14 +2036,16 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
break;
}
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_GAIN_MODE: {
E_DjiCameraManagerIrGainMode gainMode;
uint32_t 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);
cameraType == DJI_CAMERA_TYPE_M3E ||
cameraType == DJI_CAMERA_TYPE_L2) {
USER_LOG_WARN("Camera type %s don't support infrared function.",
s_cameraTypeStrList[DjiTest_CameraManagerGetCameraTypeIndex(cameraType)].cameraTypeStr);
goto exitCameraModule;
}
@ -2056,14 +2075,14 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
tempRange.lowGainTempMin, tempRange.lowGainTempMax,
tempRange.highGainTempMin, tempRange.highGainTempMax);
returnCode = DjiCameraManager_SetInfraredCameraGainMode(mountPosition, gainMode);
returnCode = DjiCameraManager_SetInfraredCameraGainMode(mountPosition, (E_DjiCameraManagerIrGainMode)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);
USER_LOG_INFO("Set gain mode to %d successfully!", (E_DjiCameraManagerIrGainMode)gainMode);
break;
}
@ -2115,6 +2134,17 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
break;
}
#ifndef SYSTEM_ARCH_RTOS
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SUBSCRIBE_POINT_CLOUD: {
returnCode = DjiTest_CameraManagerSubscribePointCloud(mountPosition);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Fail to subscribe point cloud. position %d, error code 0x%08llX",
mountPosition, returnCode);
goto exitCameraModule;
}
break;
}
#endif
default: {
USER_LOG_ERROR("There is no valid command input!");
break;
@ -2493,4 +2523,120 @@ static T_DjiReturnCode DjiTest_CameraManagerGetLidarRangingInfo(E_DjiMountPositi
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
#ifndef SYSTEM_ARCH_RTOS
T_DjiReturnCode DjiTest_CameraManagerSubscribePointCloud(E_DjiMountPosition position)
{
T_DjiReturnCode returnCode;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
uint8_t recvBuf[TEST_CAMERA_MOP_CHANNEL_SUBSCRIBE_POINT_CLOUD_RECV_BUFFER] = {0};
uint8_t colorPointsBuf[TEST_CAMERA_MOP_CHANNEL_COLOR_POINTS_BUFFER] = {0};
uint32_t realLen;
uint32_t recvDataCount = 0;
struct tm *localTime = NULL;
time_t currentTime = time(NULL);
FILE *fp = NULL;
size_t size;
T_DjiCameraManagerColorPointCloud *colorPointCloud;
uint32_t colorPointCloudDataByte = 0;
uint32_t colorPointsNum = 0;
returnCode = DjiCameraManager_StartRecordPointCloud(position);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Start record point cloud failed, stat:0x%08llX.", returnCode);
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
localTime = localtime(&currentTime);
sprintf(s_pointCloudFilePath, "payload%d_point_cloud_%04d%02d%02d_%02d-%02d-%02d.ldrt",
position, localTime->tm_year + 1900, localTime->tm_mon + 1, localTime->tm_mday,
localTime->tm_hour, localTime->tm_min, localTime->tm_sec);
fp = fopen(s_pointCloudFilePath, "ab+");
if (fp == NULL) {
USER_LOG_ERROR("fopen point cloud file failed!\n");
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;
}
returnCode = DjiMopChannel_Create(&s_mopChannelHandle, DJI_MOP_CHANNEL_TRANS_UNRELIABLE);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
fclose(fp);
USER_LOG_ERROR("Mop channel create send handle error, stat:0x%08llX.", returnCode);
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
RECONNECT:
osalHandler->TaskSleepMs(TEST_CAMERA_MOP_CHANNEL_WAIT_TIME_MS);
returnCode = DjiMopChannel_Connect(s_mopChannelHandle, DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO1,
TEST_CAMERA_MOP_CHANNEL_SUBSCRIBE_POINT_CLOUD_CHANNEL_ID);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Connect point cloud mop channel error, stat:0x%08llX.", returnCode);
goto RECONNECT;
}
while (1) {
if (recvDataCount == TEST_CAMERA_MOP_CHANNEL_MAX_RECV_COUNT) {
USER_LOG_INFO("Subscribe point cloud success, the point cloud data is stored in %s", s_pointCloudFilePath);
break;
}
memset(recvBuf, 0, TEST_CAMERA_MOP_CHANNEL_SUBSCRIBE_POINT_CLOUD_RECV_BUFFER);
returnCode = DjiMopChannel_RecvData(s_mopChannelHandle, recvBuf,
TEST_CAMERA_MOP_CHANNEL_SUBSCRIBE_POINT_CLOUD_RECV_BUFFER, &realLen);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
if (returnCode == DJI_ERROR_MOP_CHANNEL_MODULE_CODE_CONNECTION_CLOSE) {
USER_LOG_INFO("mop channel is disconnected");
osalHandler->TaskSleepMs(TEST_CAMERA_MOP_CHANNEL_WAIT_TIME_MS);
goto RECONNECT;
}
}
colorPointCloud = (T_DjiCameraManagerColorPointCloud *) recvBuf;
colorPointCloudDataByte = (colorPointCloud->pointCloudHeader).dataByte;
colorPointsNum = colorPointCloudDataByte / sizeof(T_DjiCameraManagerPointXYZRGBInfo);
memcpy(colorPointsBuf, (uint8_t *)(colorPointCloud->points), colorPointCloudDataByte);
USER_LOG_INFO("Mop channel recv data from channel length:%d, count:%d, points num = %d, points byte = %d",
realLen, recvDataCount++, colorPointsNum, colorPointCloudDataByte);
size = fwrite(colorPointsBuf, 1, colorPointCloudDataByte, fp);
if (size != colorPointCloudDataByte) {
USER_LOG_ERROR("fwrite point cloud file failed!\n");
fclose(fp);
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
fflush(fp);
}
fclose(fp);
returnCode = DjiMopChannel_Close(s_mopChannelHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Close mop channel error, stat:0x%08llX.", returnCode);
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
returnCode = DjiMopChannel_Destroy(s_mopChannelHandle);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Destroy mop channel error, stat:0x%08llX.", returnCode);
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
returnCode = DjiCameraManager_StopRecordPointCloud(position);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Stop record point cloud failed, stat:0x%08llX.", returnCode);
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
#endif
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/

View File

@ -72,6 +72,7 @@ typedef enum {
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_SUBSCRIBE_POINT_CLOUD,
E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_INDEX_MAX
} E_DjiTestCameraManagerSampleSelect;
/* Exported functions --------------------------------------------------------*/

View File

@ -113,7 +113,8 @@ T_DjiReturnCode DjiTest_DataTransmissionStartService(void)
USER_LOG_ERROR("get data stream remote address error.");
}
} else if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT) {
} else if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT
|| DJI_MOUNT_POSITION_EXTENSION_LITE_PORT == s_aircraftInfoBaseInfo.mountPosition) {
channelAddress = DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO1;
djiStat = DjiLowSpeedDataChannel_RegRecvDataCallback(channelAddress, ReceiveDataFromPayload);
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -240,7 +241,8 @@ static void *UserDataTransmission_Task(void *arg)
}
#endif
}
} else if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT) {
} else if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT
|| DJI_MOUNT_POSITION_EXTENSION_LITE_PORT == s_aircraftInfoBaseInfo.mountPosition) {
channelAddress = DJI_CHANNEL_ADDRESS_PAYLOAD_PORT_NO1;
djiStat = DjiLowSpeedDataChannel_SendData(channelAddress, dataToBeSent, sizeof(dataToBeSent));
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS)

View File

@ -52,13 +52,13 @@ T_DjiReturnCode DjiTest_InterestPointRunSample(void)
returnCode = DjiFlightController_Init(ridInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_INFO("Flight control init failed, errno=%lld", returnCode);
USER_LOG_ERROR("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);
USER_LOG_ERROR("Point interest init failed, errno=%lld", returnCode);
return returnCode;
}
@ -92,7 +92,7 @@ T_DjiReturnCode DjiTest_InterestPointRunSample(void)
DjiInterestPoint_SetSpeed(5.0f);
for (int i = 0; i < 60; ++i) {
USER_LOG_ERROR("Interest point mission running %d.", i);
USER_LOG_INFO("Interest point mission running %d.", i);
osalHandler->TaskSleepMs(1000);
}

View File

@ -81,9 +81,9 @@ T_DjiReturnCode DjiTest_LiveviewRunSample(E_DjiMountPosition mountPosition)
DjiTest_WidgetLogAppend("--> Step 2: Start h264 stream of the fpv and selected payload\r\n");
if (aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3E) {
//TODO: how to use on M3E
} else if (aircraftInfoBaseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M3T) {
//TODO: how to use on M3T
} else {
localTime = localtime(&currentTime);
sprintf(s_fpvCameraStreamFilePath, "fpv_stream_%04d%02d%02d_%02d-%02d-%02d.h264",

View File

@ -87,10 +87,9 @@ T_DjiReturnCode DjiTest_PowerManagementStartService(void)
return returnCode;
}
if ((baseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M300_RTK ||
baseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M350_RTK) &&
(baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 ||
baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_XPORT)) {
if (((baseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M300_RTK || baseInfo.aircraftType == DJI_AIRCRAFT_TYPE_M350_RTK) &&
(baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_SKYPORT_V2 || baseInfo.djiAdapterType == DJI_SDK_ADAPTER_TYPE_XPORT)) ||
baseInfo.aircraftType == DJI_AIRCRAFT_TYPE_FC30) {
// apply high power
if (s_applyHighPowerHandler.pinInit == NULL) {
USER_LOG_ERROR("apply high power pin init interface is NULL error");

View File

@ -62,7 +62,7 @@
#define WIDGET_SPEAKER_AUDIO_OPUS_DECODE_BITRATE_8KBPS (8000)
/* The speaker initialization parameters */
#define WIDGET_SPEAKER_DEFAULT_VOLUME (30)
#define WIDGET_SPEAKER_DEFAULT_VOLUME (60)
#define EKHO_INSTALLED (1)
/* Private types -------------------------------------------------------------*/

View File

@ -462,7 +462,8 @@ static void *DjiTest_WidgetInteractionTask(void *arg)
USER_LOG_INFO("--------------------------------------------------------------------------------------------->");
DjiTest_WidgetLogAppend("-> Sample Start");
if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT) {
if (s_aircraftInfoBaseInfo.mountPosition == DJI_MOUNT_POSITION_EXTENSION_PORT
|| DJI_MOUNT_POSITION_EXTENSION_LITE_PORT == s_aircraftInfoBaseInfo.mountPosition) {
switch (s_extensionPortSampleIndex) {
case E_DJI_SAMPLE_INDEX_WAYPOINT_V2:
if (s_isallowRunFlightControlSample == true) {