Compare commits
13 Commits
3.32.37.21
...
3.38.43.21
Author | SHA1 | Date | |
---|---|---|---|
a3ea1b8b67 | |||
9bb6969cd7 | |||
1494807973 | |||
9e63686a52 | |||
2f467085f8 | |||
4d872189be | |||
4df18d88dd | |||
80159490e1 | |||
884cd90ac4 | |||
1b12e68f84 | |||
db81ffe5cc | |||
9f76699bc2 | |||
23153193a6 |
@ -119,6 +119,13 @@ static uint32_t s_tapZoomNewestTargetHybridFocalLength = 0; // unit: 0.1mm
|
|||||||
static T_DjiMutexHandle s_tapZoomMutex = NULL;
|
static T_DjiMutexHandle s_tapZoomMutex = NULL;
|
||||||
static E_DjiCameraVideoStreamType s_cameraVideoStreamType;
|
static E_DjiCameraVideoStreamType s_cameraVideoStreamType;
|
||||||
|
|
||||||
|
static int sockfd;
|
||||||
|
static struct sockaddr_in server;
|
||||||
|
static struct sockaddr_in client;
|
||||||
|
static socklen_t addrlen;
|
||||||
|
|
||||||
|
char s_positionMessage[100]=" ";
|
||||||
|
|
||||||
/* Private functions declaration ---------------------------------------------*/
|
/* Private functions declaration ---------------------------------------------*/
|
||||||
//用于s_commonHandler中的回调函数:相机类基础功能
|
//用于s_commonHandler中的回调函数:相机类基础功能
|
||||||
static T_DjiReturnCode GetSystemState(T_DjiCameraSystemState *systemState);
|
static T_DjiReturnCode GetSystemState(T_DjiCameraSystemState *systemState);
|
||||||
@ -587,6 +594,9 @@ static T_DjiReturnCode SetFocusTarget(T_DjiCameraPointInScreen target)
|
|||||||
USER_LOG_INFO("set focus target x:%.2f y:%.2f", target.focusX, target.focusY);
|
USER_LOG_INFO("set focus target x:%.2f y:%.2f", target.focusX, target.focusY);
|
||||||
memcpy(&s_cameraFocusTarget, &target, sizeof(T_DjiCameraPointInScreen));
|
memcpy(&s_cameraFocusTarget, &target, sizeof(T_DjiCameraPointInScreen));
|
||||||
|
|
||||||
|
sprintf(s_positionMessage, "%.2f,%.2f", target.focusX, target.focusY);
|
||||||
|
sendto(sockfd, s_positionMessage, strlen(s_positionMessage), 0, (struct sockaddr *)&server, sizeof(server));
|
||||||
|
|
||||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1399,6 +1409,15 @@ T_DjiReturnCode DjiTest_CameraEmuBaseStartService(void)
|
|||||||
|
|
||||||
s_isCamInited = true;
|
s_isCamInited = true;
|
||||||
|
|
||||||
|
// 创建UDP套接字
|
||||||
|
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
||||||
|
perror("Creatingsocket failed.");
|
||||||
|
}
|
||||||
|
bzero(&server, sizeof(server));
|
||||||
|
server.sin_family = AF_INET;
|
||||||
|
server.sin_port = htons(POSITION_PORT_RLX);
|
||||||
|
server.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
|
|
||||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,13 @@
|
|||||||
#include "dji_typedef.h"
|
#include "dji_typedef.h"
|
||||||
#include "dji_payload_camera.h"
|
#include "dji_payload_camera.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
|
#define POSITION_PORT_RLX 20005
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#define VIDEO_FRAME_MAX_COUNT 18000 // max video duration 10 minutes
|
#define VIDEO_FRAME_MAX_COUNT 18000 // max video duration 10 minutes
|
||||||
#define VIDEO_FRAME_AUD_LEN 6
|
#define VIDEO_FRAME_AUD_LEN 6
|
||||||
#define DATA_SEND_FROM_VIDEO_STREAM_MAX_LEN 60000
|
#define DATA_SEND_FROM_VIDEO_STREAM_MAX_LEN 60000
|
||||||
|
#define MAXDATASIZE 100000
|
||||||
|
|
||||||
/* Private types -------------------------------------------------------------*/
|
/* Private types -------------------------------------------------------------*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -123,6 +124,7 @@ static T_DjiReturnCode StopDownloadNotification(void);
|
|||||||
|
|
||||||
_Noreturn static void *UserCameraMedia_SendVideoTask(void *arg);
|
_Noreturn static void *UserCameraMedia_SendVideoTask(void *arg);
|
||||||
static void *UserCameraMedia_SendVideoTask_tc(void *arg);
|
static void *UserCameraMedia_SendVideoTask_tc(void *arg);
|
||||||
|
static void *UserCameraMedia_SendVideoTask_ximea(void *arg);
|
||||||
|
|
||||||
/* Private variables -------------------------------------------------------------*/
|
/* Private variables -------------------------------------------------------------*/
|
||||||
static T_DjiCameraMediaDownloadPlaybackHandler s_psdkCameraMedia = {0};//控制相机类负载设备执行媒体文件下载回放功能
|
static T_DjiCameraMediaDownloadPlaybackHandler s_psdkCameraMedia = {0};//控制相机类负载设备执行媒体文件下载回放功能
|
||||||
@ -212,14 +214,24 @@ T_DjiReturnCode DjiTest_CameraEmuMediaStartService(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建线程执行用户自定义函数
|
// 创建线程执行用户自定义函数
|
||||||
// if (DjiPlatform_GetHalNetworkHandler() != NULL || DjiPlatform_GetHalUsbBulkHandler() != NULL) {
|
if (DjiPlatform_GetHalNetworkHandler() != NULL || DjiPlatform_GetHalUsbBulkHandler() != NULL) {
|
||||||
// returnCode = osalHandler->TaskCreate("user_camera_media_task", UserCameraMedia_SendVideoTask_tc, 2048,
|
returnCode = osalHandler->TaskCreate("user_camera_media_task", UserCameraMedia_SendVideoTask_ximea, 2048,
|
||||||
// NULL, &s_userSendVideoThread);
|
NULL, &s_userSendVideoThread);
|
||||||
// if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||||
// USER_LOG_ERROR("user send video task create error.");
|
USER_LOG_ERROR("user send video task create error.");
|
||||||
// return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
char ipAddr[100];
|
||||||
|
uint16_t port;
|
||||||
|
returnCode = DjiPayloadCamera_GetVideoStreamRemoteAddress(ipAddr, &port);
|
||||||
|
if (returnCode == DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||||
|
USER_LOG_INFO("Get video stream remote address-------------------------------------: %s, port: %d", ipAddr, port);
|
||||||
|
} else {
|
||||||
|
USER_LOG_INFO("get video stream remote address error------------------------------------.");
|
||||||
|
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -559,7 +571,10 @@ static T_DjiReturnCode DjiPlayback_VideoFileTranscode(const char *inPath, const
|
|||||||
snprintf(ffmpegCmdStr, FFMPEG_CMD_BUF_SIZE,
|
snprintf(ffmpegCmdStr, FFMPEG_CMD_BUF_SIZE,
|
||||||
"echo \"y\" | ffmpeg -i \"%s\" -codec copy -f \"%s\" \"%s\" 1>/dev/null 2>&1", inPath,
|
"echo \"y\" | ffmpeg -i \"%s\" -codec copy -f \"%s\" \"%s\" 1>/dev/null 2>&1", inPath,
|
||||||
outFormat, outPath);
|
outFormat, outPath);
|
||||||
|
|
||||||
|
// echo "y" | ffmpeg -i "/home/300tc/projects_source/Payload-SDK/samples/sample_c/module_sample/camera_emu/media_file/PSDK_0005.h264" -codec copy -f "h264" "/home/300tc/projects_source/Payload-SDK/samples/sample_c/module_sample/camera_emu/media_file/out.h264" 1>/dev/null 2>&1
|
||||||
// printf(ffmpegCmdStr);
|
// printf(ffmpegCmdStr);
|
||||||
|
|
||||||
fpCommand = popen(ffmpegCmdStr, "r");
|
fpCommand = popen(ffmpegCmdStr, "r");
|
||||||
if (fpCommand == NULL) {
|
if (fpCommand == NULL) {
|
||||||
USER_LOG_ERROR("execute transcode command fail.");
|
USER_LOG_ERROR("execute transcode command fail.");
|
||||||
@ -1178,7 +1193,7 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
|
|||||||
uint16_t lengthOfDataToBeSent = 0;
|
uint16_t lengthOfDataToBeSent = 0;
|
||||||
int lengthOfDataHaveBeenSent = 0;
|
int lengthOfDataHaveBeenSent = 0;
|
||||||
char *dataBuffer = NULL;
|
char *dataBuffer = NULL;
|
||||||
T_TestPayloadCameraPlaybackCommand playbackCommand = {0};//??????????????????????
|
T_TestPayloadCameraPlaybackCommand playbackCommand = {0};//取出将要执行的命令,放入此变量
|
||||||
uint16_t bufferReadSize = 0;
|
uint16_t bufferReadSize = 0;
|
||||||
char *videoFilePath = NULL;
|
char *videoFilePath = NULL;
|
||||||
char *transcodedFilePath = NULL;//转换视频编码后的文件路径
|
char *transcodedFilePath = NULL;//转换视频编码后的文件路径
|
||||||
@ -1238,6 +1253,8 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int frameNumberSendCounter=0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
osalHandler->TaskSleepMs(1000 / SEND_VIDEO_TASK_FREQ);
|
osalHandler->TaskSleepMs(1000 / SEND_VIDEO_TASK_FREQ);
|
||||||
|
|
||||||
@ -1354,6 +1371,8 @@ send:
|
|||||||
//3. 解析视频流文件
|
//3. 解析视频流文件
|
||||||
//基于PSDK 开发的相机类负载设备获取视频流文件的信息后,将解析视频流文件的内容,识别视频流文件的帧头。
|
//基于PSDK 开发的相机类负载设备获取视频流文件的信息后,将解析视频流文件的内容,识别视频流文件的帧头。
|
||||||
frameBufSize = frameInfo[frameNumber].size;//这行几行代码的意思:每一帧的大小不一样
|
frameBufSize = frameInfo[frameNumber].size;//这行几行代码的意思:每一帧的大小不一样
|
||||||
|
printf("第 %d 帧大小:%d\n", frameNumberSendCounter, frameBufSize);
|
||||||
|
frameNumberSendCounter++;
|
||||||
if (videoStreamType == DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) {
|
if (videoStreamType == DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) {
|
||||||
frameBufSize = frameBufSize + VIDEO_FRAME_AUD_LEN;
|
frameBufSize = frameBufSize + VIDEO_FRAME_AUD_LEN;
|
||||||
}
|
}
|
||||||
@ -1554,7 +1573,7 @@ static void *UserCameraMedia_SendVideoTask_tc(void *arg)
|
|||||||
int aa = v_ifmtCtx->streams[videoindex]->r_frame_rate.num;
|
int aa = v_ifmtCtx->streams[videoindex]->r_frame_rate.num;
|
||||||
int bb = v_ifmtCtx->streams[videoindex]->r_frame_rate.den;
|
int bb = v_ifmtCtx->streams[videoindex]->r_frame_rate.den;
|
||||||
double dInputFps = v_ifmtCtx->streams[videoindex]->r_frame_rate.num*1.0 / v_ifmtCtx->streams[videoindex]->r_frame_rate.den;
|
double dInputFps = v_ifmtCtx->streams[videoindex]->r_frame_rate.num*1.0 / v_ifmtCtx->streams[videoindex]->r_frame_rate.den;
|
||||||
printf("摄像头的帧率%d\n",(int)dInputFps);
|
printf("摄像头的帧率: %d\n",(int)dInputFps);
|
||||||
|
|
||||||
|
|
||||||
//视频流的编解码器
|
//视频流的编解码器
|
||||||
@ -1562,7 +1581,7 @@ static void *UserCameraMedia_SendVideoTask_tc(void *arg)
|
|||||||
AVCodec *pCodec;
|
AVCodec *pCodec;
|
||||||
|
|
||||||
pCodec=avcodec_find_decoder(v_ifmtCtx->streams[videoindex]->codecpar->codec_id);
|
pCodec=avcodec_find_decoder(v_ifmtCtx->streams[videoindex]->codecpar->codec_id);
|
||||||
printf("编码器名字:%%s\n",pCodec->name);
|
printf("编码器名字:%s\n",pCodec->name);
|
||||||
|
|
||||||
if(pCodec==NULL)
|
if(pCodec==NULL)
|
||||||
{
|
{
|
||||||
@ -1808,6 +1827,7 @@ static void *UserCameraMedia_SendVideoTask_tc(void *arg)
|
|||||||
//3. 解析视频流文件
|
//3. 解析视频流文件
|
||||||
//基于PSDK 开发的相机类负载设备获取视频流文件的信息后,将解析视频流文件的内容,识别视频流文件的帧头。
|
//基于PSDK 开发的相机类负载设备获取视频流文件的信息后,将解析视频流文件的内容,识别视频流文件的帧头。
|
||||||
frameBufSize = datasize;
|
frameBufSize = datasize;
|
||||||
|
videoStreamType = DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT;
|
||||||
if (videoStreamType == DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) {
|
if (videoStreamType == DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) {
|
||||||
frameBufSize = frameBufSize + VIDEO_FRAME_AUD_LEN;
|
frameBufSize = frameBufSize + VIDEO_FRAME_AUD_LEN;
|
||||||
}
|
}
|
||||||
@ -1852,6 +1872,7 @@ static void *UserCameraMedia_SendVideoTask_tc(void *arg)
|
|||||||
dataLength - lengthOfDataHaveBeenSent);
|
dataLength - lengthOfDataHaveBeenSent);
|
||||||
returnCode = DjiPayloadCamera_SendVideoStream((const uint8_t *) dataBuffer + lengthOfDataHaveBeenSent,
|
returnCode = DjiPayloadCamera_SendVideoStream((const uint8_t *) dataBuffer + lengthOfDataHaveBeenSent,
|
||||||
lengthOfDataToBeSent);
|
lengthOfDataToBeSent);
|
||||||
|
printf("fasong: %d!!!!\n", lengthOfDataToBeSent);
|
||||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||||
USER_LOG_ERROR("send video stream error: 0x%08llX.", returnCode);
|
USER_LOG_ERROR("send video stream error: 0x%08llX.", returnCode);
|
||||||
}
|
}
|
||||||
@ -1881,6 +1902,186 @@ static void *UserCameraMedia_SendVideoTask_tc(void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *UserCameraMedia_SendVideoTask_ximea(void *arg)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
T_DjiReturnCode returnCode;
|
||||||
|
static uint32_t sendVideoStep = 0;
|
||||||
|
FILE *fpFile = NULL;
|
||||||
|
unsigned long dataLength = 0;
|
||||||
|
uint16_t lengthOfDataToBeSent = 0;
|
||||||
|
int lengthOfDataHaveBeenSent = 0;
|
||||||
|
char *dataBuffer = NULL;
|
||||||
|
T_TestPayloadCameraPlaybackCommand playbackCommand = {0};//取出将要执行的命令,放入此变量
|
||||||
|
uint16_t bufferReadSize = 0;
|
||||||
|
char *videoFilePath = NULL;
|
||||||
|
char *transcodedFilePath = NULL;//转换视频编码后的文件路径
|
||||||
|
float frameRate = 1.0f;
|
||||||
|
T_TestPayloadCameraVideoFrameInfo *frameInfo = NULL;//时长,大小,此帧在文件中的位置
|
||||||
|
uint32_t frameNumber = 0;
|
||||||
|
uint32_t frameCount = 0;
|
||||||
|
uint32_t startTimeMs = 0;
|
||||||
|
bool sendVideoFlag = true;
|
||||||
|
bool sendOneTimeFlag = false;
|
||||||
|
T_DjiDataChannelState videoStreamState = {0};
|
||||||
|
E_DjiCameraMode mode = DJI_CAMERA_MODE_SHOOT_PHOTO;
|
||||||
|
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||||
|
uint32_t frameBufSize = 0;
|
||||||
|
E_DjiCameraVideoStreamType videoStreamType;
|
||||||
|
char curFileDirPath[DJI_FILE_PATH_SIZE_MAX];
|
||||||
|
char tempPath[DJI_FILE_PATH_SIZE_MAX];
|
||||||
|
|
||||||
|
USER_UTIL_UNUSED(arg);
|
||||||
|
|
||||||
|
//获取视频流文件信息(1)
|
||||||
|
returnCode = DjiUserUtil_GetCurrentFileDirPath(__FILE__, DJI_FILE_PATH_SIZE_MAX, curFileDirPath);
|
||||||
|
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||||
|
USER_LOG_ERROR("Get file current path error, stat = 0x%08llX", returnCode);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (s_isMediaFileDirPathConfigured == true) {
|
||||||
|
snprintf(tempPath, DJI_FILE_PATH_SIZE_MAX, "%sPSDK_0005.h264", s_mediaFileDirPath);
|
||||||
|
} else {
|
||||||
|
snprintf(tempPath, DJI_FILE_PATH_SIZE_MAX, "%smedia_file/PSDK_0005.h264", curFileDirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
//使用PSDK 开发的相机类负载设备在创建视频流处理线程后,需要先初始化线程状态并向相机类负载设备申请用于缓存视频流文件的内存空间。
|
||||||
|
videoFilePath = osalHandler->Malloc(DJI_FILE_PATH_SIZE_MAX);
|
||||||
|
if (videoFilePath == NULL) {
|
||||||
|
USER_LOG_ERROR("malloc memory for video file path fail.");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
transcodedFilePath = osalHandler->Malloc(DJI_FILE_PATH_SIZE_MAX);
|
||||||
|
if (transcodedFilePath == NULL) {
|
||||||
|
USER_LOG_ERROR("malloc memory for transcoded file path fail.");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
frameInfo = osalHandler->Malloc(VIDEO_FRAME_MAX_COUNT * sizeof(T_TestPayloadCameraVideoFrameInfo));
|
||||||
|
if (frameInfo == NULL) {
|
||||||
|
USER_LOG_ERROR("malloc memory for frame info fail.");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
memset(frameInfo, 0, VIDEO_FRAME_MAX_COUNT * sizeof(T_TestPayloadCameraVideoFrameInfo));
|
||||||
|
|
||||||
|
//???????????????????????????????????????????????????????????????
|
||||||
|
returnCode = DjiPlayback_StopPlayProcess();
|
||||||
|
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||||
|
USER_LOG_ERROR("stop playback and start liveview error: 0x%08llX.", returnCode);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//tc+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
int sockfd;
|
||||||
|
struct sockaddr_in server;
|
||||||
|
struct sockaddr_in client;
|
||||||
|
socklen_t addrlen;
|
||||||
|
int num;
|
||||||
|
char buf[MAXDATASIZE];
|
||||||
|
|
||||||
|
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
||||||
|
perror("Creatingsocket failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
bzero(&server, sizeof(server));
|
||||||
|
server.sin_family = AF_INET;
|
||||||
|
server.sin_port = htons(PORT);
|
||||||
|
server.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
|
if (bind(sockfd, (struct sockaddr *) &server, sizeof(server)) == -1)
|
||||||
|
{
|
||||||
|
perror("Bind() error.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int udpReceivedCounter=0;
|
||||||
|
//tc-------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
send:
|
||||||
|
num = recvfrom(sockfd, buf, MAXDATASIZE, 0, (struct sockaddr *) &client, &addrlen);
|
||||||
|
if (num < 0) {
|
||||||
|
perror("recvfrom() error\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// printf("You got a message (%d bytes) from client. \nId is %d\n", num, udpReceivedCounter);
|
||||||
|
udpReceivedCounter++;
|
||||||
|
|
||||||
|
//3. 解析视频流文件
|
||||||
|
//基于PSDK 开发的相机类负载设备获取视频流文件的信息后,将解析视频流文件的内容,识别视频流文件的帧头。
|
||||||
|
videoStreamType = DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT;
|
||||||
|
frameBufSize = num;//这行几行代码的意思:每一帧的大小不一样
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(dataBuffer,buf,num);
|
||||||
|
dataLength = num;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//4. 发送视频流数据
|
||||||
|
//基于PSDK 开发的相机类负载设备在解析视频流文件并识别视频流文件的帧头后,调用视频流发送接口PsdkPayloadCamera_SendVideoStream,
|
||||||
|
//以逐帧的方式发送视频流数据。若视频流格式为DJI H264格式,需要在每一帧的最后增加AUD信息,用于标识一帧的结束。
|
||||||
|
if (videoStreamType == DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) {
|
||||||
|
memcpy(&dataBuffer[num], s_frameAudInfo, VIDEO_FRAME_AUD_LEN);
|
||||||
|
dataLength = dataLength + VIDEO_FRAME_AUD_LEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for(int i=0;i<dataLength - VIDEO_FRAME_AUD_LEN;i++)
|
||||||
|
// {
|
||||||
|
//// printf("%c",data[i]);
|
||||||
|
// printf("%02X ",dataBuffer[i]);
|
||||||
|
// }
|
||||||
|
// printf("\n");
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((frameNumber++) >= frameCount) {
|
||||||
|
USER_LOG_DEBUG("reach file tail.");
|
||||||
|
frameNumber = 0;
|
||||||
|
|
||||||
|
if (sendOneTimeFlag == true)
|
||||||
|
sendVideoFlag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//5. 获取视频流状态
|
||||||
|
//使用PSDK 开发的相机类负载设备能够获取视频流发送的实时状态,方便用户调整视频流的码率,确保图传画面的稳定显示。
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef __CC_ARM
|
#ifndef __CC_ARM
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,6 +33,17 @@
|
|||||||
|
|
||||||
#include "ffmpeg_tc.h"
|
#include "ffmpeg_tc.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
|
#define PORT 666
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "dji_typedef.h"
|
#include "dji_typedef.h"
|
||||||
#include "dji_power_management.h"
|
#include "dji_power_management.h"
|
||||||
|
#include <wiringPi.h>
|
||||||
|
|
||||||
|
#define HIGH_POWER_APPLY_PIN 11
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -54,6 +54,8 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
|||||||
|
|
||||||
static void *PsdkTest_IrisRecordSystemChanged(void *arg);
|
static void *PsdkTest_IrisRecordSystemChanged(void *arg);
|
||||||
static void extractSpectralBinAndBandnumber(bool isModifyBin);
|
static void extractSpectralBinAndBandnumber(bool isModifyBin);
|
||||||
|
static void extractSpatialBinAndWidth(bool isModifyBin);
|
||||||
|
static void closeXimeaRecordSystem();
|
||||||
|
|
||||||
/* Private values ------------------------------------------------------------*/
|
/* Private values ------------------------------------------------------------*/
|
||||||
static T_DjiTaskHandle s_widgetTestThread;
|
static T_DjiTaskHandle s_widgetTestThread;
|
||||||
@ -79,14 +81,17 @@ int systemON_Control = 0;
|
|||||||
|
|
||||||
char s_strUIMessage[100]=" ";
|
char s_strUIMessage[100]=" ";
|
||||||
static char * s_strStateOfSbg=" ";
|
static char * s_strStateOfSbg=" ";
|
||||||
static char * s_strSbgSatelliteCounter=" ";
|
char s_strSbgSatelliteCounter[100]=" ";
|
||||||
static char * s_strSbgAccuracy=" ";
|
char s_strSbgAccuracy[100]=" ";
|
||||||
char XimeaFramerate[100]=" ";
|
char XimeaFramerate[100]=" ";
|
||||||
int framerate = 0;
|
int framerate = 0;
|
||||||
char XimeaExposeTime[100]=" ";
|
char XimeaExposeTime[100]=" ";
|
||||||
|
int exposeTimeInt = 0;
|
||||||
char XimeaExposeMaxValue[100]=" ";
|
char XimeaExposeMaxValue[100]=" ";
|
||||||
char s_spectralBin[100]=" ";
|
char s_spectralBin[100]=" ";
|
||||||
|
char s_spatialBin[100]=" ";
|
||||||
int spectralBinInt = 0;
|
int spectralBinInt = 0;
|
||||||
|
int spatialBinInt = 0;
|
||||||
static char * s_strSbgSolutionMode=" ";
|
static char * s_strSbgSolutionMode=" ";
|
||||||
static char * s_strStateOfXimea=" ";
|
static char * s_strStateOfXimea=" ";
|
||||||
|
|
||||||
@ -111,14 +116,13 @@ static const T_DjiWidgetHandlerListItem s_widgetHandlerList[] = {
|
|||||||
{1, DJI_WIDGET_TYPE_LIST, DjiTestWidget_SetWidgetValue, DjiTestWidget_GetWidgetValue, NULL},
|
{1, DJI_WIDGET_TYPE_LIST, DjiTestWidget_SetWidgetValue, DjiTestWidget_GetWidgetValue, NULL},
|
||||||
{2, DJI_WIDGET_TYPE_SWITCH, DjiTestWidget_SetWidgetValue, DjiTestWidget_GetWidgetValue, NULL},
|
{2, DJI_WIDGET_TYPE_SWITCH, DjiTestWidget_SetWidgetValue, DjiTestWidget_GetWidgetValue, NULL},
|
||||||
{3, DJI_WIDGET_TYPE_SCALE, DjiTestWidget_SetWidgetValue, DjiTestWidget_GetWidgetValue, NULL},
|
{3, DJI_WIDGET_TYPE_SCALE, DjiTestWidget_SetWidgetValue, DjiTestWidget_GetWidgetValue, NULL},
|
||||||
{4, DJI_WIDGET_TYPE_BUTTON, DjiTestWidget_SetWidgetValue, DjiTestWidget_GetWidgetValue, NULL},
|
{4, DJI_WIDGET_TYPE_LIST, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
||||||
{5, DJI_WIDGET_TYPE_SWITCH, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
{5, DJI_WIDGET_TYPE_SWITCH, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
||||||
{6, DJI_WIDGET_TYPE_INT_INPUT_BOX, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
{6, DJI_WIDGET_TYPE_INT_INPUT_BOX, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
||||||
{7, DJI_WIDGET_TYPE_BUTTON, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
{7, DJI_WIDGET_TYPE_BUTTON, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
||||||
{8, DJI_WIDGET_TYPE_INT_INPUT_BOX, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
{8, DJI_WIDGET_TYPE_INT_INPUT_BOX, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
||||||
{9, DJI_WIDGET_TYPE_SWITCH, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
{9, DJI_WIDGET_TYPE_SWITCH, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
||||||
{10, DJI_WIDGET_TYPE_LIST, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},//PsdkTestWidget_SetWidgetValue
|
{10, DJI_WIDGET_TYPE_LIST, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},//PsdkTestWidget_SetWidgetValue
|
||||||
{11, DJI_WIDGET_TYPE_LIST, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *s_widgetTypeNameArray[] = {
|
static const char *s_widgetTypeNameArray[] = {
|
||||||
@ -244,6 +248,8 @@ T_DjiReturnCode DjiTest_WidgetStartService(void)
|
|||||||
s_server.sin_family = AF_INET;
|
s_server.sin_family = AF_INET;
|
||||||
s_server.sin_port = htons(PORT);
|
s_server.sin_port = htons(PORT);
|
||||||
s_server.sin_addr= *((struct in_addr *)he->h_addr);
|
s_server.sin_addr= *((struct in_addr *)he->h_addr);
|
||||||
|
|
||||||
|
system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 10");
|
||||||
/* tc-----------------------------------------------*/
|
/* tc-----------------------------------------------*/
|
||||||
|
|
||||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||||
@ -285,19 +291,25 @@ static void *DjiTest_WidgetTask(void *arg)
|
|||||||
T_DjiReturnCode djiStat;
|
T_DjiReturnCode djiStat;
|
||||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||||
|
|
||||||
extractSpectralBinAndBandnumber(false);
|
|
||||||
|
|
||||||
USER_UTIL_UNUSED(arg);
|
USER_UTIL_UNUSED(arg);
|
||||||
|
|
||||||
while (1) {
|
while (1)
|
||||||
|
{
|
||||||
|
s_widgetValueList[6] = framerate;
|
||||||
|
s_widgetValueList[8] = exposeTimeInt;
|
||||||
|
if (systemON_Control == 4)
|
||||||
|
{
|
||||||
|
s_widgetValueList[5] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
djiStat = osalHandler->GetTimeMs(&sysTimeMs);
|
djiStat = osalHandler->GetTimeMs(&sysTimeMs);
|
||||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||||
USER_LOG_ERROR("Get system time ms error, stat = 0x%08llX", djiStat);
|
USER_LOG_ERROR("Get system time ms error, stat = 0x%08llX", djiStat);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USER_FIRMWARE_MAJOR_VERSION
|
#ifndef USER_FIRMWARE_MAJOR_VERSION
|
||||||
snprintf(message, DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN, "%s\n高光谱: %s; 惯导: %s;\n卫星: %s; 惯导状态: %s;\n帧率: %s;曝光: %s;max: %s;\nP: %s; R: %s; Y: %s;\n光谱bin: %s;\n时间: %s min; 空间: %s G;\n",
|
snprintf(message, DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN, "%s\n高光谱: %s 惯导: %s\n卫星: %s 惯导状态: %s\n帧率: %s 曝光: %s μs %s \nP: %s R: %s Y: %s \n时间: %s min 空间: %s G\n光谱bin: %s 空间bin: %s\n",
|
||||||
s_strUIMessage, s_strStateOfXimea, s_strStateOfSbg, s_strSbgSatelliteCounter, s_strSbgSolutionMode, XimeaFramerate, XimeaExposeTime, XimeaExposeMaxValue, s_strPitch, s_strRoll, s_strYaw, s_spectralBin, s_remainingTime, s_remainingSpace);
|
s_strUIMessage, s_strStateOfXimea, s_strStateOfSbg, s_strSbgSatelliteCounter, s_strSbgSolutionMode, XimeaFramerate, XimeaExposeTime, XimeaExposeMaxValue, s_strPitch, s_strRoll, s_strYaw, s_remainingTime, s_remainingSpace, s_spectralBin, s_spatialBin);
|
||||||
#else
|
#else
|
||||||
snprintf(message, DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN,
|
snprintf(message, DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN,
|
||||||
"System time : %u ms\r\nVersion: v%02d.%02d.%02d.%02d\r\nBuild time: %s %s", sysTimeMs,
|
"System time : %u ms\r\nVersion: v%02d.%02d.%02d.%02d\r\nBuild time: %s %s", sysTimeMs,
|
||||||
@ -320,6 +332,9 @@ static void *DjiTest_WidgetTask(void *arg)
|
|||||||
strcpy(s_strUIMessage," ");
|
strcpy(s_strUIMessage," ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extractSpectralBinAndBandnumber(false);
|
||||||
|
extractSpatialBinAndWidth(false);
|
||||||
|
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
@ -338,24 +353,28 @@ static void *DjiTest_WidgetTask(void *arg)
|
|||||||
|
|
||||||
// 转换为MB
|
// 转换为MB
|
||||||
double availableMB = availableBytes / (1024.0 * 1024.0);
|
double availableMB = availableBytes / (1024.0 * 1024.0);
|
||||||
sprintf(remainingSpaceTmp, "%.0f", availableMB/1024);
|
sprintf(remainingSpaceTmp, "%.2f", availableMB/1024);
|
||||||
s_remainingSpace = remainingSpaceTmp;
|
s_remainingSpace = remainingSpaceTmp;
|
||||||
|
|
||||||
if (spectralBinInt!=0 && framerate!=0)
|
if (spectralBinInt!=0 && framerate!=0)
|
||||||
{
|
{
|
||||||
double frameSize;
|
double frameSize;
|
||||||
if (spectralBinInt==1)
|
if (spectralBinInt + spatialBinInt==2)
|
||||||
{
|
{
|
||||||
frameSize = 0.783;
|
frameSize = 0.783;
|
||||||
}
|
}
|
||||||
else
|
else if(spectralBinInt + spatialBinInt==3)
|
||||||
{
|
{
|
||||||
frameSize = 0.783/2;
|
frameSize = 0.783/2;
|
||||||
}
|
}
|
||||||
|
else if(spectralBinInt + spatialBinInt==4)
|
||||||
|
{
|
||||||
|
frameSize = 0.783/4;
|
||||||
|
}
|
||||||
|
|
||||||
double minTemp = availableMB / (frameSize * framerate * 60);
|
double minTemp = availableMB / (frameSize * framerate * 60);
|
||||||
|
|
||||||
sprintf(remainingTimeTmp, "%.0f", minTemp);
|
sprintf(remainingTimeTmp, "%.2f", minTemp);
|
||||||
s_remainingTime = remainingTimeTmp;
|
s_remainingTime = remainingTimeTmp;
|
||||||
|
|
||||||
// 打印结果
|
// 打印结果
|
||||||
@ -467,21 +486,11 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
|||||||
case 0:
|
case 0:
|
||||||
s_strStateOfSbg="未打开";
|
s_strStateOfSbg="未打开";
|
||||||
|
|
||||||
if (systemON_Control == 0 || systemON_Control == 4)
|
|
||||||
{
|
|
||||||
strcpy(s_strUIMessage,"系统已就绪!");
|
strcpy(s_strUIMessage,"系统已就绪!");
|
||||||
messageTimeCounter = 0;
|
messageTimeCounter = 0;
|
||||||
messageTimespan = 1000;
|
messageTimespan = 1000;
|
||||||
|
|
||||||
systemON_Control = 1;//ximeaAirborneSystem系统一启动就会发送此信息 → 代表采集系统就绪;
|
systemON_Control = 1;//ximeaAirborneSystem系统一启动就会发送此信息 → 代表采集系统就绪;
|
||||||
}
|
|
||||||
|
|
||||||
if (systemON_Control == 3)
|
|
||||||
{
|
|
||||||
strcpy(s_strUIMessage,"数据量过大,采集系统已经停止,请重新上电!");
|
|
||||||
messageTimeCounter = 0;
|
|
||||||
messageTimespan = 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@ -492,7 +501,7 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
s_strStateOfSbg="采集中";
|
s_strStateOfSbg="采集中";
|
||||||
systemON_Control = 3;
|
s_widgetValueList[5] = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -502,9 +511,10 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
|||||||
else if (strcmp(result[0],"Accuracy") == 0)
|
else if (strcmp(result[0],"Accuracy") == 0)
|
||||||
{
|
{
|
||||||
// printf("惯导定位精度为: %s\n\n", result[1]);
|
// printf("惯导定位精度为: %s\n\n", result[1]);
|
||||||
|
// printf("卫星数为: %s\n\n", result[2]);
|
||||||
|
|
||||||
s_strSbgAccuracy=result[1];
|
strcpy(s_strSbgAccuracy,result[1]);
|
||||||
s_strSbgSatelliteCounter=result[2];
|
strcpy(s_strSbgSatelliteCounter,result[2]);
|
||||||
|
|
||||||
ximeaAirborneSystemSurvivalTime++;
|
ximeaAirborneSystemSurvivalTime++;
|
||||||
|
|
||||||
@ -531,19 +541,19 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
|||||||
switch (s_sbgMagState)
|
switch (s_sbgMagState)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
s_strSbgSolutionMode="UNINITI";//UNINITIALIZED
|
s_strSbgSolutionMode="dis_UNINIT";//UNINITIALIZED
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
s_strSbgSolutionMode="GYRO";//VERTICAL_GYRO
|
s_strSbgSolutionMode="dis_GYRO";//VERTICAL_GYRO
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
s_strSbgSolutionMode="AHRS";
|
s_strSbgSolutionMode="dis_AHRS";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
s_strSbgSolutionMode="VELOCITY";//NAV_VELOCITY
|
s_strSbgSolutionMode="dis_VELOCITY";//NAV_VELOCITY
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
s_strSbgSolutionMode="FULL";//NAV_POSITION
|
s_strSbgSolutionMode="en_FULL";//NAV_POSITION
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -586,24 +596,32 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
|||||||
messageTimespan = 200;
|
messageTimespan = 200;
|
||||||
break;
|
break;
|
||||||
case 100:
|
case 100:
|
||||||
s_strStateOfXimea="未打开";
|
s_strStateOfXimea="未连接";
|
||||||
break;
|
break;
|
||||||
case 101:
|
case 101:
|
||||||
s_strStateOfXimea="打开成功";
|
s_strStateOfXimea="连接成功";
|
||||||
|
s_widgetValueList[9] = 0;
|
||||||
|
|
||||||
|
if(s_stateOfXimea == 100)
|
||||||
|
{
|
||||||
strcpy(s_strUIMessage,"系统启动成功!");
|
strcpy(s_strUIMessage,"系统启动成功!");
|
||||||
messageTimeCounter = 0;
|
messageTimeCounter = 0;
|
||||||
messageTimespan = 20;
|
messageTimespan = 20;
|
||||||
|
}
|
||||||
|
systemON_Control = 3;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 102:
|
case 102:
|
||||||
s_strStateOfXimea="帧率完成";
|
s_strStateOfXimea="连接成功";
|
||||||
|
s_widgetValueList[9] = 0;
|
||||||
break;
|
break;
|
||||||
case 103:
|
case 103:
|
||||||
s_strStateOfXimea="曝光完成";
|
s_strStateOfXimea="连接成功";
|
||||||
|
s_widgetValueList[9] = 0;
|
||||||
break;
|
break;
|
||||||
case 104:
|
case 104:
|
||||||
s_strStateOfXimea="采集中";
|
s_strStateOfXimea="采集中";
|
||||||
|
s_widgetValueList[9] = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -614,9 +632,9 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
|||||||
{
|
{
|
||||||
strcpy(XimeaExposeMaxValue, result[1]);
|
strcpy(XimeaExposeMaxValue, result[1]);
|
||||||
|
|
||||||
int exposeTimeTmp = atoi(result[2]);
|
exposeTimeInt = atoi(result[2]);
|
||||||
sprintf(XimeaExposeTime,"%d",exposeTimeTmp);
|
sprintf(XimeaExposeTime,"%d",exposeTimeInt);
|
||||||
s_widgetValueList[8] = exposeTimeTmp;
|
s_widgetValueList[8] = exposeTimeInt;
|
||||||
|
|
||||||
strcpy(s_strUIMessage,"曝光时间设置成功!");
|
strcpy(s_strUIMessage,"曝光时间设置成功!");
|
||||||
messageTimeCounter = 0;
|
messageTimeCounter = 0;
|
||||||
@ -667,7 +685,6 @@ static T_DjiReturnCode DjiTestWidget_GetWidgetValue(E_DjiWidgetType widgetType,
|
|||||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int frameRateGlobel = 0;
|
|
||||||
static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType widgetType, uint32_t index, int32_t value,
|
static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType widgetType, uint32_t index, int32_t value,
|
||||||
void *userData)
|
void *userData)
|
||||||
{
|
{
|
||||||
@ -675,17 +692,47 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
|||||||
|
|
||||||
USER_LOG_INFO("Set widget value, widgetType = %s, widgetIndex = %d ,widgetValue = %d",
|
USER_LOG_INFO("Set widget value, widgetType = %s, widgetIndex = %d ,widgetValue = %d",
|
||||||
s_widgetTypeNameArray[widgetType], index, value);
|
s_widgetTypeNameArray[widgetType], index, value);
|
||||||
|
int32_t valueTmp = s_widgetValueList[index];
|
||||||
s_widgetValueList[index] = value;
|
s_widgetValueList[index] = value;
|
||||||
|
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
|
case 4:
|
||||||
|
if (value==0)//等待指令
|
||||||
|
{
|
||||||
|
}
|
||||||
|
if (value==1)
|
||||||
|
{
|
||||||
|
system("reboot");
|
||||||
|
}
|
||||||
|
else if (value==2)
|
||||||
|
{
|
||||||
|
system("shutdown now");
|
||||||
|
}
|
||||||
|
else if (value==3)
|
||||||
|
{
|
||||||
|
system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 9,1");
|
||||||
|
}
|
||||||
|
else if (value==4)
|
||||||
|
{
|
||||||
|
system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 9,0");
|
||||||
|
}
|
||||||
|
else if (value==5)
|
||||||
|
{
|
||||||
|
strcpy(s_strUIMessage,"系统正在更新,稍后会自动重启!");
|
||||||
|
messageTimeCounter = 0;
|
||||||
|
messageTimespan = 10000;
|
||||||
|
|
||||||
|
system("/home/pi/tc_ShellScripts/update0.sh &> /media/nvme/300TC/update/log");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 5://系统启动关闭
|
case 5://系统启动关闭
|
||||||
if (value==0)//系统关闭
|
if (value==0)//系统关闭
|
||||||
{
|
{
|
||||||
printf("systemON_Control的值为:%d\n", systemON_Control);
|
printf("systemON_Control的值为:%d\n", systemON_Control);
|
||||||
if (0 <= systemON_Control && systemON_Control <= 4)
|
if (0 <= systemON_Control && systemON_Control <= 4)
|
||||||
{
|
{
|
||||||
strcpy(s_strUIMessage,"系统已经关闭!");
|
strcpy(s_strUIMessage,"系统正在关闭!");
|
||||||
messageTimeCounter = 0;
|
messageTimeCounter = 0;
|
||||||
messageTimespan = 1000;
|
messageTimespan = 1000;
|
||||||
|
|
||||||
@ -700,25 +747,7 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
|||||||
// printf("命令行指令为:%s\n",commandtmp);
|
// printf("命令行指令为:%s\n",commandtmp);
|
||||||
// system(commandtmp);
|
// system(commandtmp);
|
||||||
|
|
||||||
FILE *fp;
|
closeXimeaRecordSystem();
|
||||||
fp = popen("kill $(ps aux | grep ximeaAirborneSystem | grep -v grep | awk \'{print $2}\')", "r");
|
|
||||||
if (fp == NULL)
|
|
||||||
{
|
|
||||||
perror("popen");
|
|
||||||
}
|
|
||||||
|
|
||||||
s_strStateOfXimea=" ";
|
|
||||||
s_strStateOfSbg=" ";
|
|
||||||
s_strSbgSatelliteCounter=" ";
|
|
||||||
s_strSbgSolutionMode=" ";
|
|
||||||
sprintf(XimeaFramerate,"%s"," ");
|
|
||||||
sprintf(XimeaExposeTime,"%s"," ");
|
|
||||||
sprintf(XimeaExposeMaxValue,"%s"," ");
|
|
||||||
sprintf(s_spectralBin,"%s"," ");
|
|
||||||
s_remainingTime=" ";
|
|
||||||
|
|
||||||
s_widgetValueList[6] = 0;
|
|
||||||
s_widgetValueList[8] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (value==1)//系统启动
|
else if (value==1)//系统启动
|
||||||
@ -763,6 +792,13 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
|||||||
messageTimeCounter = 0;
|
messageTimeCounter = 0;
|
||||||
messageTimespan = 10;
|
messageTimespan = 10;
|
||||||
|
|
||||||
|
// printf("index-------:%d\n", index);
|
||||||
|
// printf("valueTmp-------:%d\n", valueTmp);
|
||||||
|
|
||||||
|
//下面的代码没有作用:无法恢复界面的值为默认值(valueTmp)
|
||||||
|
// DjiTestWidget_SetWidgetValue(widgetType, index, valueTmp, userData);
|
||||||
|
// s_widgetValueList[index] = valueTmp;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (s_stateOfXimea > 103)
|
else if (s_stateOfXimea > 103)
|
||||||
@ -794,12 +830,10 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
frameRateGlobel = value;
|
|
||||||
|
|
||||||
char command[50] = "5,";
|
char command[50] = "5,";
|
||||||
char framerate[20];
|
char framerate_str[20];
|
||||||
sprintf(framerate,"%d",value);
|
sprintf(framerate_str,"%d",value);
|
||||||
strcat(command,framerate);
|
strcat(command,framerate_str);
|
||||||
sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server));
|
sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -855,24 +889,13 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
|||||||
}
|
}
|
||||||
|
|
||||||
//曝光时间有效性判断
|
//曝光时间有效性判断
|
||||||
if(frameRateGlobel == 0)
|
float maxExposureTime = 1 / (float)framerate * 1000 * 1000;//单位是μs
|
||||||
{
|
|
||||||
strcpy(s_strUIMessage,"请先设置帧率!");
|
|
||||||
messageTimeCounter = 0;
|
|
||||||
messageTimespan = 10;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
float maxExposureTime = 1 / (float)frameRateGlobel * 1000;//单位是ms
|
|
||||||
|
|
||||||
if(value > maxExposureTime)
|
if(value > maxExposureTime)
|
||||||
{
|
{
|
||||||
strcpy(s_strUIMessage,"曝光时间超过上限,无效!");
|
strcpy(s_strUIMessage,"曝光时间已设置为最大!");
|
||||||
messageTimeCounter = 0;
|
messageTimeCounter = 0;
|
||||||
messageTimespan = 10;
|
messageTimespan = 10;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else if(value == 0)
|
else if(value == 0)
|
||||||
{
|
{
|
||||||
@ -895,6 +918,11 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
|||||||
case 9:
|
case 9:
|
||||||
if (value==0)//停止采集
|
if (value==0)//停止采集
|
||||||
{
|
{
|
||||||
|
if (s_stateOfXimea != 104)
|
||||||
|
{
|
||||||
|
s_strStateOfXimea="连接成功";
|
||||||
|
}
|
||||||
|
|
||||||
char* command = "4";
|
char* command = "4";
|
||||||
sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server));
|
sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server));
|
||||||
}
|
}
|
||||||
@ -908,72 +936,32 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (s_stateOfXimea == 101)
|
|
||||||
{
|
|
||||||
strcpy(s_strUIMessage,"请先设置帧率!");
|
|
||||||
messageTimeCounter = 0;
|
|
||||||
messageTimespan = 10;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (s_stateOfXimea == 102)
|
|
||||||
{
|
|
||||||
strcpy(s_strUIMessage,"请先设置曝光时间!");
|
|
||||||
messageTimeCounter = 0;
|
|
||||||
messageTimespan = 10;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
s_strStateOfXimea="预约采集";
|
||||||
char* command = "3";
|
char* command = "3";
|
||||||
sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server));
|
sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
if (value==0)//等待指令
|
|
||||||
{
|
|
||||||
}
|
|
||||||
if (value==1)
|
|
||||||
{
|
|
||||||
system("reboot");
|
|
||||||
}
|
|
||||||
else if (value==2)
|
|
||||||
{
|
|
||||||
system("shutdown now");
|
|
||||||
}
|
|
||||||
else if (value==3)
|
|
||||||
{
|
|
||||||
system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 9,1");
|
|
||||||
}
|
|
||||||
else if (value==4)
|
|
||||||
{
|
|
||||||
system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 9,0");
|
|
||||||
}
|
|
||||||
else if (value==5)
|
|
||||||
{
|
|
||||||
strcpy(s_strUIMessage,"系统正在更新,稍后会自动重启!");
|
|
||||||
messageTimeCounter = 0;
|
|
||||||
messageTimespan = 10000;
|
|
||||||
|
|
||||||
system("/home/pi/tc_ShellScripts/update0.sh &> /media/nvme/300TC/update/log");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 11:
|
|
||||||
if (value==0)//等待指令
|
if (value==0)//等待指令
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
if (value==1)
|
if (value==1)
|
||||||
{
|
{
|
||||||
system("sudo sed -i 's/spectralBin =.*/spectralBin = 1;/g' /media/nvme/300TC/config/ximea.cfg");
|
system("sudo sed -i 's/spectralBin =.*/spectralBin = 1;/g' /media/nvme/300TC/config/ximea.cfg");
|
||||||
|
system("sudo sed -i 's/spatialBin =.*/spatialBin = 1;/g' /media/nvme/300TC/config/ximea.cfg");
|
||||||
}
|
}
|
||||||
else if (value==2)
|
else if (value==2)
|
||||||
{
|
{
|
||||||
system("sudo sed -i 's/spectralBin =.*/spectralBin = 2;/g' /media/nvme/300TC/config/ximea.cfg");
|
system("sudo sed -i 's/spectralBin =.*/spectralBin = 2;/g' /media/nvme/300TC/config/ximea.cfg");
|
||||||
|
system("sudo sed -i 's/spatialBin =.*/spatialBin = 2;/g' /media/nvme/300TC/config/ximea.cfg");
|
||||||
}
|
}
|
||||||
|
closeXimeaRecordSystem();
|
||||||
|
|
||||||
extractSpectralBinAndBandnumber(true);
|
extractSpectralBinAndBandnumber(true);
|
||||||
|
extractSpatialBinAndWidth(true);
|
||||||
|
|
||||||
strcpy(s_strUIMessage,"请重新上电!");
|
strcpy(s_strUIMessage,"请等待采集系统重启!");
|
||||||
messageTimeCounter = 0;
|
messageTimeCounter = 0;
|
||||||
messageTimespan = 10000;
|
messageTimespan = 10000;
|
||||||
|
|
||||||
@ -985,6 +973,35 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
|||||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void closeXimeaRecordSystem()
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
fp = popen("kill $(ps aux | grep ximeaAirborneSystem | grep -v grep | awk \'{print $2}\')", "r");
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
perror("popen");
|
||||||
|
}
|
||||||
|
|
||||||
|
s_strStateOfXimea=" ";
|
||||||
|
s_strStateOfSbg=" ";
|
||||||
|
sprintf(s_strSbgSatelliteCounter,"%s"," ");
|
||||||
|
s_strSbgSolutionMode=" ";
|
||||||
|
sprintf(XimeaFramerate,"%s"," ");
|
||||||
|
sprintf(XimeaExposeTime,"%s"," ");
|
||||||
|
sprintf(XimeaExposeMaxValue,"%s"," ");
|
||||||
|
sprintf(s_spectralBin,"%s"," ");
|
||||||
|
sprintf(s_spatialBin,"%s"," ");
|
||||||
|
s_remainingTime=" ";
|
||||||
|
|
||||||
|
s_widgetValueList[5] = 0;
|
||||||
|
// s_widgetValueList[6] = 0;
|
||||||
|
// s_widgetValueList[8] = 0;
|
||||||
|
framerate = 0;
|
||||||
|
exposeTimeInt = 0;
|
||||||
|
|
||||||
|
system("sudo gpio write 10 0");
|
||||||
|
}
|
||||||
|
|
||||||
static void extractSpectralBinAndBandnumber(bool isModifyBin)
|
static void extractSpectralBinAndBandnumber(bool isModifyBin)
|
||||||
{
|
{
|
||||||
unsigned long long spectralBin, height;
|
unsigned long long spectralBin, height;
|
||||||
@ -1029,17 +1046,8 @@ static void extractSpectralBinAndBandnumber(bool isModifyBin)
|
|||||||
pclose(fp);
|
pclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
char command[256];
|
s_widgetValueList[10] = spectralBin;
|
||||||
memset(command, 0, sizeof(command));
|
spectralBinInt = spectralBin;
|
||||||
|
|
||||||
sprintf(command,"sudo sed -i 's/.*bin.*/ \"widget_name\": \"bin%d_%d\",/g' %s", spectralBin, height, jsonPathCn);
|
|
||||||
// printf("command: %s", command);
|
|
||||||
system(command);
|
|
||||||
|
|
||||||
memset(command, 0, sizeof(command));
|
|
||||||
sprintf(command,"sudo sed -i 's/.*bin.*/ \"widget_name\": \"bin%d_%d\",/g' %s", spectralBin, height, jsonPathEn);
|
|
||||||
// printf("command: %s", command);
|
|
||||||
system(command);
|
|
||||||
|
|
||||||
if (!isModifyBin)
|
if (!isModifyBin)
|
||||||
{
|
{
|
||||||
@ -1047,4 +1055,57 @@ static void extractSpectralBinAndBandnumber(bool isModifyBin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void extractSpatialBinAndWidth(bool isModifyBin)
|
||||||
|
{
|
||||||
|
unsigned long long spatialBinBin, width;
|
||||||
|
char buffer[128];
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
fp = popen("grep \"spatialBin = \" /media/nvme/300TC/config/ximea.cfg | awk '{print $3}' | tr -d ';'", "r");
|
||||||
|
if (fp == NULL) {
|
||||||
|
perror("popen");
|
||||||
|
}
|
||||||
|
if (fgets(buffer, sizeof(buffer), fp) != NULL)
|
||||||
|
{
|
||||||
|
// printf("当前字符串-----: %s \n", buffer);
|
||||||
|
spatialBinBin = strtoull(buffer, NULL, 10);
|
||||||
|
}
|
||||||
|
pclose(fp);
|
||||||
|
|
||||||
|
if (spatialBinBin == 1)
|
||||||
|
{
|
||||||
|
fp = popen("grep \"width\" /media/nvme/300TC/config/ximea.cfg | head -n 1 | awk '{print $3}' | tr -d ';'", "r");
|
||||||
|
if (fp == NULL) {
|
||||||
|
perror("popen");
|
||||||
|
}
|
||||||
|
if (fgets(buffer, sizeof(buffer), fp) != NULL)
|
||||||
|
{
|
||||||
|
// printf("当前字符串-----: %s \n", buffer);
|
||||||
|
width = strtoull(buffer, NULL, 10);
|
||||||
|
}
|
||||||
|
pclose(fp);
|
||||||
|
}
|
||||||
|
else if(spatialBinBin == 2)
|
||||||
|
{
|
||||||
|
fp = popen("grep \"width\" /media/nvme/300TC/config/ximea.cfg | head -n 2 | tail -n 1 | awk '{print $3}' | tr -d ';'", "r");
|
||||||
|
if (fp == NULL) {
|
||||||
|
perror("popen");
|
||||||
|
}
|
||||||
|
if (fgets(buffer, sizeof(buffer), fp) != NULL)
|
||||||
|
{
|
||||||
|
// printf("当前字符串-----: %s \n", buffer);
|
||||||
|
width = strtoull(buffer, NULL, 10);
|
||||||
|
}
|
||||||
|
pclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
s_widgetValueList[11] = spatialBinBin;
|
||||||
|
spatialBinInt = spatialBinBin;
|
||||||
|
|
||||||
|
if (!isModifyBin)
|
||||||
|
{
|
||||||
|
sprintf(s_spatialBin,"%d_%d", spatialBinBin, width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
/****************** (C) COPYRIGHT DJI Innovations *****END OF FILE****/
|
||||||
|
@ -8,128 +8,18 @@
|
|||||||
"is_enable": true
|
"is_enable": true
|
||||||
},
|
},
|
||||||
"speaker": {
|
"speaker": {
|
||||||
"is_enable_tts": true,
|
"is_enable_tts": false,
|
||||||
"is_enable_voice": false
|
"is_enable_voice": false
|
||||||
},
|
},
|
||||||
"widget_list": [
|
"widget_list": [
|
||||||
{
|
|
||||||
"widget_index": 0,
|
|
||||||
"widget_type": "button",
|
|
||||||
"widget_name": "按钮",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_button1.png",
|
|
||||||
"icon_file_name_unselected": "icon_button1.png"
|
|
||||||
},
|
|
||||||
"customize_rc_buttons_config": {
|
|
||||||
"is_enable": true,
|
|
||||||
"mapping_config_display_order": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 1,
|
|
||||||
"widget_type": "list",
|
|
||||||
"widget_name": "列表",
|
|
||||||
"list_item": [
|
|
||||||
{
|
|
||||||
"item_name": "选项_1",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_list_item1.png",
|
|
||||||
"icon_file_name_unselected": "icon_list_item1.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item_name": "选项_2",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_list_item2.png",
|
|
||||||
"icon_file_name_unselected": "icon_list_item2.png"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"customize_rc_buttons_config": {
|
|
||||||
"is_enable": true,
|
|
||||||
"mapping_config_display_order": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 2,
|
|
||||||
"widget_type": "switch",
|
|
||||||
"widget_name": "开关",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_switch_select.png",
|
|
||||||
"icon_file_name_unselected": "icon_switch_unselect.png"
|
|
||||||
},
|
|
||||||
"customize_rc_buttons_config": {
|
|
||||||
"is_enable": true,
|
|
||||||
"mapping_config_display_order": 2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 3,
|
|
||||||
"widget_type": "scale",
|
|
||||||
"widget_name": "范围条",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_scale.png",
|
|
||||||
"icon_file_name_unselected": "icon_scale.png"
|
|
||||||
},
|
|
||||||
"customize_rc_buttons_config": {
|
|
||||||
"is_enable": true,
|
|
||||||
"mapping_config_display_order": 3,
|
|
||||||
"button_value_step_length": 5
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 4,
|
|
||||||
"widget_type": "button",
|
|
||||||
"widget_name": "按钮",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_button1.png",
|
|
||||||
"icon_file_name_unselected": "icon_button1.png"
|
|
||||||
},
|
|
||||||
"customize_rc_buttons_config": {
|
|
||||||
"is_enable": true,
|
|
||||||
"mapping_config_display_order": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"config_interface": {
|
"config_interface": {
|
||||||
"text_input_box": {
|
|
||||||
"widget_name": "文本输入框",
|
|
||||||
"placeholder_text": "请输入消息",
|
|
||||||
"is_enable": true
|
|
||||||
},
|
|
||||||
"widget_list": [
|
"widget_list": [
|
||||||
{
|
{
|
||||||
"widget_index": 5,
|
"widget_index": 4,
|
||||||
"widget_type": "switch",
|
|
||||||
"widget_name": "系统启动"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 6,
|
|
||||||
"widget_type": "int_input_box",
|
|
||||||
"widget_name": "帧率",
|
|
||||||
"int_input_box_hint": "单位:hz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 7,
|
|
||||||
"widget_type": "button",
|
|
||||||
"widget_name": "自动曝光"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 8,
|
|
||||||
"widget_type": "int_input_box",
|
|
||||||
"widget_name": "曝光时间",
|
|
||||||
"int_input_box_hint": "单位:毫秒"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 9,
|
|
||||||
"widget_type": "switch",
|
|
||||||
"widget_name": "高光谱采集"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 10,
|
|
||||||
"widget_type": "list",
|
"widget_type": "list",
|
||||||
"widget_name": "系统指令",
|
"widget_name": "高级指令",
|
||||||
"list_item": [
|
"list_item": [
|
||||||
{
|
{
|
||||||
"item_name": "其他"
|
"item_name": "其他"
|
||||||
@ -152,7 +42,34 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"widget_index": 11,
|
"widget_index": 5,
|
||||||
|
"widget_type": "switch",
|
||||||
|
"widget_name": "系统启动"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widget_index": 6,
|
||||||
|
"widget_type": "int_input_box",
|
||||||
|
"widget_name": "帧率",
|
||||||
|
"int_input_box_hint": "单位:赫兹"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widget_index": 7,
|
||||||
|
"widget_type": "button",
|
||||||
|
"widget_name": "自动曝光"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widget_index": 8,
|
||||||
|
"widget_type": "int_input_box",
|
||||||
|
"widget_name": "曝光时间",
|
||||||
|
"int_input_box_hint": "单位:微秒"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widget_index": 9,
|
||||||
|
"widget_type": "switch",
|
||||||
|
"widget_name": "高光谱采集"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widget_index": 10,
|
||||||
"widget_type": "list",
|
"widget_type": "list",
|
||||||
"widget_name": "bin",
|
"widget_name": "bin",
|
||||||
"list_item": [
|
"list_item": [
|
||||||
@ -160,10 +77,10 @@
|
|||||||
"item_name": "其他"
|
"item_name": "其他"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"item_name": "光谱1"
|
"item_name": "1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"item_name": "光谱2"
|
"item_name": "2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -8,128 +8,18 @@
|
|||||||
"is_enable": true
|
"is_enable": true
|
||||||
},
|
},
|
||||||
"speaker": {
|
"speaker": {
|
||||||
"is_enable_tts": true,
|
"is_enable_tts": false,
|
||||||
"is_enable_voice": false
|
"is_enable_voice": false
|
||||||
},
|
},
|
||||||
"widget_list": [
|
"widget_list": [
|
||||||
{
|
|
||||||
"widget_index": 0,
|
|
||||||
"widget_type": "button",
|
|
||||||
"widget_name": "Button",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_button1.png",
|
|
||||||
"icon_file_name_unselected": "icon_button1.png"
|
|
||||||
},
|
|
||||||
"customize_rc_buttons_config": {
|
|
||||||
"is_enable": true,
|
|
||||||
"mapping_config_display_order": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 1,
|
|
||||||
"widget_type": "list",
|
|
||||||
"widget_name": "List",
|
|
||||||
"list_item": [
|
|
||||||
{
|
|
||||||
"item_name": "Item_1",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_list_item1.png",
|
|
||||||
"icon_file_name_unselected": "icon_list_item1.png"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item_name": "Item_2",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_list_item2.png",
|
|
||||||
"icon_file_name_unselected": "icon_list_item2.png"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"customize_rc_buttons_config": {
|
|
||||||
"is_enable": true,
|
|
||||||
"mapping_config_display_order": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 2,
|
|
||||||
"widget_type": "switch",
|
|
||||||
"widget_name": "Switch",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_switch_select.png",
|
|
||||||
"icon_file_name_unselected": "icon_switch_unselect.png"
|
|
||||||
},
|
|
||||||
"customize_rc_buttons_config": {
|
|
||||||
"is_enable": true,
|
|
||||||
"mapping_config_display_order": 2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 3,
|
|
||||||
"widget_type": "scale",
|
|
||||||
"widget_name": "Scale",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_scale.png",
|
|
||||||
"icon_file_name_unselected": "icon_scale.png"
|
|
||||||
},
|
|
||||||
"customize_rc_buttons_config": {
|
|
||||||
"is_enable": true,
|
|
||||||
"mapping_config_display_order": 3,
|
|
||||||
"button_value_step_length": 5
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 4,
|
|
||||||
"widget_type": "button",
|
|
||||||
"widget_name": "Button",
|
|
||||||
"icon_file_set": {
|
|
||||||
"icon_file_name_selected": "icon_button1.png",
|
|
||||||
"icon_file_name_unselected": "icon_button1.png"
|
|
||||||
},
|
|
||||||
"customize_rc_buttons_config": {
|
|
||||||
"is_enable": true,
|
|
||||||
"mapping_config_display_order": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"config_interface": {
|
"config_interface": {
|
||||||
"text_input_box": {
|
|
||||||
"widget_name": "TextInputBox",
|
|
||||||
"placeholder_text": "Please input message",
|
|
||||||
"is_enable": true
|
|
||||||
},
|
|
||||||
"widget_list": [
|
"widget_list": [
|
||||||
{
|
{
|
||||||
"widget_index": 5,
|
"widget_index": 4,
|
||||||
"widget_type": "switch",
|
|
||||||
"widget_name": "系统启动"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 6,
|
|
||||||
"widget_type": "int_input_box",
|
|
||||||
"widget_name": "帧率",
|
|
||||||
"int_input_box_hint": "单位:hz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 7,
|
|
||||||
"widget_type": "button",
|
|
||||||
"widget_name": "自动曝光"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 8,
|
|
||||||
"widget_type": "int_input_box",
|
|
||||||
"widget_name": "曝光时间",
|
|
||||||
"int_input_box_hint": "单位:毫秒"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 9,
|
|
||||||
"widget_type": "switch",
|
|
||||||
"widget_name": "高光谱采集"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widget_index": 10,
|
|
||||||
"widget_type": "list",
|
"widget_type": "list",
|
||||||
"widget_name": "系统指令",
|
"widget_name": "高级指令",
|
||||||
"list_item": [
|
"list_item": [
|
||||||
{
|
{
|
||||||
"item_name": "其他"
|
"item_name": "其他"
|
||||||
@ -152,7 +42,34 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"widget_index": 11,
|
"widget_index": 5,
|
||||||
|
"widget_type": "switch",
|
||||||
|
"widget_name": "系统启动"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widget_index": 6,
|
||||||
|
"widget_type": "int_input_box",
|
||||||
|
"widget_name": "帧率",
|
||||||
|
"int_input_box_hint": "单位:赫兹"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widget_index": 7,
|
||||||
|
"widget_type": "button",
|
||||||
|
"widget_name": "自动曝光"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widget_index": 8,
|
||||||
|
"widget_type": "int_input_box",
|
||||||
|
"widget_name": "曝光时间",
|
||||||
|
"int_input_box_hint": "单位:微秒"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widget_index": 9,
|
||||||
|
"widget_type": "switch",
|
||||||
|
"widget_name": "高光谱采集"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widget_index": 10,
|
||||||
"widget_type": "list",
|
"widget_type": "list",
|
||||||
"widget_name": "bin",
|
"widget_name": "bin",
|
||||||
"list_item": [
|
"list_item": [
|
||||||
@ -160,10 +77,10 @@
|
|||||||
"item_name": "其他"
|
"item_name": "其他"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"item_name": "光谱1"
|
"item_name": "1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"item_name": "光谱2"
|
"item_name": "2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ T_DjiReturnCode DjiTest_XPortStartService(void)
|
|||||||
return djiStat;
|
return djiStat;
|
||||||
}
|
}
|
||||||
|
|
||||||
//通过注册回调函数获取X-Port 的姿态信息.注册后,回调函数将会被自动调用,调用频率为
|
//通过注册回调函数获取X-Port 的姿态信息.注册后,回调函数将会被自动调用,调用频率为10hz
|
||||||
djiStat = DjiXPort_RegReceiveAttitudeInformationCallback(ReceiveXPortAttitudeInformation);
|
djiStat = DjiXPort_RegReceiveAttitudeInformationCallback(ReceiveXPortAttitudeInformation);
|
||||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||||
USER_LOG_ERROR("register receive XPort attitude information callback function error: 0x%08llX.",
|
USER_LOG_ERROR("register receive XPort attitude information callback function error: 0x%08llX.",
|
||||||
|
@ -95,6 +95,9 @@ target_link_libraries(${PROJECT_NAME}
|
|||||||
z
|
z
|
||||||
m
|
m
|
||||||
pthread
|
pthread
|
||||||
|
rt
|
||||||
|
crypt
|
||||||
|
wiringPi
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command(TARGET ${PROJECT_NAME}
|
add_custom_command(TARGET ${PROJECT_NAME}
|
||||||
|
@ -56,9 +56,9 @@
|
|||||||
#include "dji_sdk_config.h"
|
#include "dji_sdk_config.h"
|
||||||
|
|
||||||
/* Private constants ---------------------------------------------------------*/
|
/* Private constants ---------------------------------------------------------*/
|
||||||
#define DJI_LOG_PATH "Logs/DJI"
|
#define DJI_LOG_PATH "/media/nvme/300TC/programRunLog/djiLog/DJI"
|
||||||
#define DJI_LOG_INDEX_FILE_NAME "Logs/latest"
|
#define DJI_LOG_INDEX_FILE_NAME "/media/nvme/300TC/programRunLog/djiLog/latest"
|
||||||
#define DJI_LOG_FOLDER_NAME "Logs"
|
#define DJI_LOG_FOLDER_NAME "/media/nvme/300TC/programRunLog/djiLog"
|
||||||
#define DJI_LOG_PATH_MAX_SIZE (128)
|
#define DJI_LOG_PATH_MAX_SIZE (128)
|
||||||
#define DJI_LOG_FOLDER_NAME_MAX_SIZE (32)
|
#define DJI_LOG_FOLDER_NAME_MAX_SIZE (32)
|
||||||
#define DJI_LOG_MAX_COUNT (10)
|
#define DJI_LOG_MAX_COUNT (10)
|
||||||
@ -137,7 +137,7 @@ int main(int argc, char **argv)
|
|||||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
returnCode = DjiCore_SetAlias("300TC_3.32.37.21");
|
returnCode = DjiCore_SetAlias("300TC_3.38.43.21");
|
||||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||||
USER_LOG_ERROR("set alias error");
|
USER_LOG_ERROR("set alias error");
|
||||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||||
@ -721,12 +721,32 @@ delay:
|
|||||||
|
|
||||||
static T_DjiReturnCode DjiTest_HighPowerApplyPinInit()
|
static T_DjiReturnCode DjiTest_HighPowerApplyPinInit()
|
||||||
{
|
{
|
||||||
|
wiringPiSetup(); // 初始化WiringPi库
|
||||||
|
|
||||||
|
pinMode(HIGH_POWER_APPLY_PIN, OUTPUT); // 配置引脚为输出模式
|
||||||
|
pullUpDnControl(HIGH_POWER_APPLY_PIN, PUD_DOWN); // 启用下拉电阻,使引脚默认为低电平
|
||||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static T_DjiReturnCode DjiTest_WriteHighPowerApplyPin(E_DjiPowerManagementPinState pinState)
|
static T_DjiReturnCode DjiTest_WriteHighPowerApplyPin(E_DjiPowerManagementPinState pinState)
|
||||||
{
|
{
|
||||||
//attention: please pull up the HWPR pin state by hardware.
|
//attention: please pull up the HWPR pin state by hardware.
|
||||||
|
|
||||||
|
int wiringPiState;
|
||||||
|
|
||||||
|
switch (pinState) {
|
||||||
|
case DJI_POWER_MANAGEMENT_PIN_STATE_RESET:
|
||||||
|
wiringPiState = LOW; // WiringPi库中,LOW表示低电平
|
||||||
|
break;
|
||||||
|
case DJI_POWER_MANAGEMENT_PIN_STATE_SET:
|
||||||
|
wiringPiState = HIGH; // WiringPi库中,HIGH表示高电平
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
USER_LOG_ERROR("pin state unknown: %d.", pinState);
|
||||||
|
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
digitalWrite(HIGH_POWER_APPLY_PIN, wiringPiState); // 使用WiringPi库设置引脚状态
|
||||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user