关键词:PSDK1.x
适用机型:M200系列、M210系列、M200 V2系列、M210 V2系列
SDK版本:PSDK 1.4.0&PSDK1.4.1
Skyport固件:01.02.00及以上
step1:找到SD卡剩余内存所在结构体T_PsdkCameraGetSDCardStateAck
typedef struct {
uint8_t ackCode; /*!< Specifies PSDK command ack code.
This parameter can be any value of ::E_PsdkCmdAckCode */
uint8_t isInserted : 1; /*!< Specifies if the SD card is inserted in the camera.
This parameter is boolean type. */
uint8_t isVerified : 1; /*!< Specifies if the SD card is verified as genuine.
This parameter is boolean type. */
uint8_t isInitializing : 1; /*!< This parameter is boolean type. */
uint8_t isReadOnly : 1; /*!< This parameter is boolean type. */
uint8_t isFormatting : 1; /*!< This parameter is boolean type. */
uint8_t isFull : 1; /*!< This parameter is boolean type. */
uint8_t isInvalidFormat : 1;/*!< This parameter is boolean type. */
uint8_t hasError : 1; /*!< This parameter is boolean type. */
uint8_t reserved;
uint32_t totalSpaceInMB; /*!< SD card total capacity, unit: MB. */
uint32_t remainSpaceInMB; /*!< SD card remaining capacity, unit: MB. */
uint32_t availableCaptureCount; /*!< Available shots, unit: s. */
uint32_t availableRecordingTimeInSeconds; /*!< Available video recording time, unit: s. */
} T_PsdkCameraGetSDCardStateAck;
step2:找到全局赋值变量 remainCapacity(初始值2048Mb)
//SD card parameters
static uint8_t insertState = 1;
static uint32_t capacity = 4096; //uint: MB
static uint32_t remainCapacity = 2048; //unit: MB
static uint32_t remainShots = 100;
static uint32_t remainRecordTime = 6000; //unit: s
step3:在SD卡状态获取函数中尝试动态改变剩余内存的值(每次减少10Mb)
void CamEmu_GetSdcardParam(const T_PsdkCameraGetSDCardStateReq *req, T_PsdkCameraGetSDCardStateAck *ack)
{
PSDK_LOG_DEBUG("Get Sd card Param");
ack->isInserted = insertState;
ack->isVerified = 1;
ack->isInitializing = 0;
ack->isReadOnly = 0;
ack->isFormatting = 0;
ack->isFull = 0;
ack->isInvalidFormat = 0;
ack->hasError = 0;
ack->totalSpaceInMB = capacity;
ack->remainSpaceInMB = remainCapacity;
remainCapacity=remainCapacity-10;
ack->availableRecordingTimeInSeconds = remainRecordTime;
ack->availableCaptureCount = remainShots;
ack->ackCode = PSDK_CMD_ACK_CODE_OK;
}
step4:定义相机命令回调函数列表
const T_PsdkCameraHandler g_testCameraHandler = {
.SetMode = CamEmu_SetCameraMode,
.GetMode = CamEmu_GetCameraMode,
.ShootPhoto = CamEmu_Photography,
.GetShootPhotoState = CamEmu_GetPhotographyState,
.SetShootPhotoMode = CamEmu_SetPhotographyMode,
.GetShootPhotoMode = CamEmu_GetPhotographyMode,
.RecordVideo = CamEmu_SetRecording,
.GetRecordVideoState = CamEmu_GetRecordingState,
.GetSDCardState = CamEmu_GetSdcardParam,
.FormatSDCard = CamEmu_FormatSdcard,
};
step5:在初始化函数中将数据更新提供给回调函数
E_PsdkStat PsdkCamera_Init(T_PsdkUpper *psdkUpper, const T_PsdkCameraHandler *cameraHandler)
{
T_PsdkProtCmdSetHandle cmdSetHandle;
s_cameraHandler = *cameraHandler;
cmdSetHandle.cmdSet = PSDK_CMDSET_CAMERA;
cmdSetHandle.cmdList = s_PayloadCameraCmdList;
cmdSetHandle.cmdCount = sizeof(s_PayloadCameraCmdList) / sizeof(T_PsdkProtCmdItem);
//support camera
s_isSupportCamera = 1;
return PsdkProto_RegCmdSetHandler(&(psdkUpper->protHandle), &cmdSetHandle);
}
step6:在主函数中调用初始化函数,飞控会以一定的频率回调SD卡数据
评论
0 条评论
请登录写评论。