1、操作遥控器按钮,psdk进程通过socket发送命令给相机进程 来控制高光谱采集系统;
2、通过FFmpeg采集摄像头视频流并编码为h264,利用psdk推流到遥控器;
This commit is contained in:
145
sample/api_sample/power_management/test_power_management.c
Normal file
145
sample/api_sample/power_management/test_power_management.c
Normal file
@ -0,0 +1,145 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_power_management.c
|
||||
* @version V2.0.0
|
||||
* @date 2019/8/29
|
||||
* @brief
|
||||
*
|
||||
* @copyright (c) 2017-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_power_management.h"
|
||||
#include "psdk_logger.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
|
||||
/* Private functions declaration ---------------------------------------------*/
|
||||
//需要自己写的函数:功能是负载设备关机前需要执行的命令
|
||||
//详细说明见网页:https://developer.dji.com/cn/payload-sdk/documentation/basicfunction/power-manage.html
|
||||
static T_PsdkReturnCode PsdkTest_PowerOffNotificationCallback(bool *powerOffPreparationFlag);
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
//此变量是函数PsdkTest_RegApplyHighPowerHandler先判断然后内存拷贝过来的
|
||||
static T_PsdkTestApplyHighPowerHandler s_applyHighPowerHandler;
|
||||
|
||||
/* Exported functions definition ---------------------------------------------*/
|
||||
/**
|
||||
* @brief Register handler function for applying high power. This function have to be called before calling
|
||||
* PsdkTest_PowerManagementInit(), except for in Linux, because PsdkTest_PowerManagementInit() do not apply high power
|
||||
* in Linux OS.
|
||||
* @param applyHighPowerHandler: pointer to handler function for applying high power.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_PsdkReturnCode PsdkTest_RegApplyHighPowerHandler(T_PsdkTestApplyHighPowerHandler *applyHighPowerHandler)
|
||||
{
|
||||
//此函数的功能:验证这两个函数指针指向的函数是否可用 → 结构体T_PsdkTestApplyHighPowerHandler中有两个函数指针,分别为pinInit和pinWrite
|
||||
|
||||
//1、先判断两个函数指针是否为空,如果为空就报错
|
||||
if (applyHighPowerHandler->pinInit == NULL) {
|
||||
PsdkLogger_UserLogError("reg apply high power handler pinInit error");
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (applyHighPowerHandler->pinWrite == NULL) {
|
||||
PsdkLogger_UserLogError("reg apply high power handler pinWrite error");
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//2、如果不为空就内存拷贝到本文件的静态变量中
|
||||
memcpy(&s_applyHighPowerHandler, applyHighPowerHandler, sizeof(T_PsdkTestApplyHighPowerHandler));
|
||||
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialise power management module, including apply high power (only RTOS) and register power off notification
|
||||
* callback function.
|
||||
* @note PSDK development board 1.0 can not accept high power, so do not call this function in PSDK development board
|
||||
* 1.0 project.
|
||||
* @return Execution result.
|
||||
*/
|
||||
T_PsdkReturnCode PsdkTest_PowerManagementInit(void)
|
||||
{
|
||||
//此函数的功能:
|
||||
//1、申请高功率。如果要申请高功率,需要在执行本函数前,先执行PsdkTest_RegApplyHighPowerHandler函数
|
||||
//2、负载设备关机前需要执行的操作
|
||||
|
||||
|
||||
T_PsdkReturnCode psdkStat;
|
||||
|
||||
// apply high power
|
||||
#if !PSDK_ARCH_SYS_LINUX
|
||||
//如果函数指针pinInit为空(没有指向函数),就返回错误代码:PSDK_RETURN_CODE_ERR_UNKNOWN
|
||||
if (s_applyHighPowerHandler.pinInit == NULL) {
|
||||
PsdkLogger_UserLogError("apply high power pin init interface is NULL error");
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (s_applyHighPowerHandler.pinWrite == NULL) {
|
||||
PsdkLogger_UserLogError("apply high power pin write interface is NULL error");
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||
}
|
||||
|
||||
//如果函数指针pinInit不为空(指向了一个函数),就执行函数,并根据返回值判断是否成功
|
||||
psdkStat = s_applyHighPowerHandler.pinInit();
|
||||
if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("apply high power pin init error");
|
||||
return psdkStat;
|
||||
}
|
||||
//注册高电压返回函数
|
||||
psdkStat = PsdkPowerManagement_RegWriteHighPowerApplyPinCallback(s_applyHighPowerHandler.pinWrite);
|
||||
if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("register WriteHighPowerApplyPinCallback error.");
|
||||
return psdkStat;
|
||||
}
|
||||
//执行高电压请求
|
||||
psdkStat = PsdkPowerManagement_ApplyHighPowerSync();
|
||||
if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("apply high power error");
|
||||
return psdkStat;
|
||||
}
|
||||
#endif
|
||||
|
||||
// register power off notification callback function
|
||||
//负载设备关机前需要执行的操作
|
||||
psdkStat = PsdkPowerManagement_RegPowerOffNotificationCallback(PsdkTest_PowerOffNotificationCallback);
|
||||
if (psdkStat != PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
PsdkLogger_UserLogError("register power off notification callback function error");
|
||||
return psdkStat;
|
||||
}
|
||||
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/* Private functions definition-----------------------------------------------*/
|
||||
//详细说明见函数申明处
|
||||
static T_PsdkReturnCode PsdkTest_PowerOffNotificationCallback(bool *powerOffPreparationFlag)
|
||||
{
|
||||
PsdkLogger_UserLogDebug("aircraft will power off soon.");
|
||||
|
||||
*powerOffPreparationFlag = true;
|
||||
|
||||
return PSDK_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
63
sample/api_sample/power_management/test_power_management.h
Normal file
63
sample/api_sample/power_management/test_power_management.h
Normal file
@ -0,0 +1,63 @@
|
||||
/**
|
||||
********************************************************************
|
||||
* @file test_power_management.h
|
||||
* @version V2.0.0
|
||||
* @date 2019/8/29
|
||||
* @brief This is the header file for "test_power_management.c", defining the structure and
|
||||
* (exported) function prototypes.
|
||||
*
|
||||
* @copyright (c) 2017-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_POWER_MANAGEMENT_H
|
||||
#define TEST_POWER_MANAGEMENT_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "psdk_typedef.h"
|
||||
#include "psdk_power_management.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
//E_PsdkPowerManagementPinState定义在中psdk_power_management.h
|
||||
//里面的两个函数指针例子见下行网页中:PsdkTest_HighPowerApplyPinInit + PsdkTest_WriteHighPowerApplyPin
|
||||
//https://developer.dji.com/cn/payload-sdk/documentation/basicfunction/power-manage.html
|
||||
typedef struct {
|
||||
T_PsdkReturnCode (*pinInit)(void);
|
||||
T_PsdkReturnCode (*pinWrite)(E_PsdkPowerManagementPinState pinState);
|
||||
} T_PsdkTestApplyHighPowerHandler;
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
//如果要申请高功率,需要在执行PsdkTest_PowerManagementInit函数前,先执行PsdkTest_RegApplyHighPowerHandler函数
|
||||
T_PsdkReturnCode PsdkTest_PowerManagementInit(void);
|
||||
T_PsdkReturnCode PsdkTest_RegApplyHighPowerHandler(T_PsdkTestApplyHighPowerHandler *applyHighPowerHandler);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // TEST_POWER_MANAGEMENT_H
|
||||
|
||||
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
|
Reference in New Issue
Block a user