Compare commits
12 Commits
47153346cd
...
3.37.43.21
Author | SHA1 | Date | |
---|---|---|---|
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 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 ---------------------------------------------*/
|
||||
//用于s_commonHandler中的回调函数:相机类基础功能
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1399,6 +1409,15 @@ T_DjiReturnCode DjiTest_CameraEmuBaseStartService(void)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,13 @@
|
||||
#include "dji_typedef.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
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -42,6 +42,7 @@
|
||||
#define VIDEO_FRAME_MAX_COUNT 18000 // max video duration 10 minutes
|
||||
#define VIDEO_FRAME_AUD_LEN 6
|
||||
#define DATA_SEND_FROM_VIDEO_STREAM_MAX_LEN 60000
|
||||
#define MAXDATASIZE 100000
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
typedef enum {
|
||||
@ -123,6 +124,7 @@ static T_DjiReturnCode StopDownloadNotification(void);
|
||||
|
||||
_Noreturn static void *UserCameraMedia_SendVideoTask(void *arg);
|
||||
static void *UserCameraMedia_SendVideoTask_tc(void *arg);
|
||||
static void *UserCameraMedia_SendVideoTask_ximea(void *arg);
|
||||
|
||||
/* Private variables -------------------------------------------------------------*/
|
||||
static T_DjiCameraMediaDownloadPlaybackHandler s_psdkCameraMedia = {0};//控制相机类负载设备执行媒体文件下载回放功能
|
||||
@ -212,14 +214,24 @@ T_DjiReturnCode DjiTest_CameraEmuMediaStartService(void)
|
||||
}
|
||||
|
||||
// 创建线程执行用户自定义函数
|
||||
// if (DjiPlatform_GetHalNetworkHandler() != NULL || DjiPlatform_GetHalUsbBulkHandler() != NULL) {
|
||||
// returnCode = osalHandler->TaskCreate("user_camera_media_task", UserCameraMedia_SendVideoTask_tc, 2048,
|
||||
// NULL, &s_userSendVideoThread);
|
||||
// if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
// USER_LOG_ERROR("user send video task create error.");
|
||||
// return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
// }
|
||||
// }
|
||||
if (DjiPlatform_GetHalNetworkHandler() != NULL || DjiPlatform_GetHalUsbBulkHandler() != NULL) {
|
||||
returnCode = osalHandler->TaskCreate("user_camera_media_task", UserCameraMedia_SendVideoTask_ximea, 2048,
|
||||
NULL, &s_userSendVideoThread);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("user send video task create error.");
|
||||
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;
|
||||
}
|
||||
@ -559,7 +571,10 @@ static T_DjiReturnCode DjiPlayback_VideoFileTranscode(const char *inPath, const
|
||||
snprintf(ffmpegCmdStr, FFMPEG_CMD_BUF_SIZE,
|
||||
"echo \"y\" | ffmpeg -i \"%s\" -codec copy -f \"%s\" \"%s\" 1>/dev/null 2>&1", inPath,
|
||||
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);
|
||||
|
||||
fpCommand = popen(ffmpegCmdStr, "r");
|
||||
if (fpCommand == NULL) {
|
||||
USER_LOG_ERROR("execute transcode command fail.");
|
||||
@ -1178,7 +1193,7 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
|
||||
uint16_t lengthOfDataToBeSent = 0;
|
||||
int lengthOfDataHaveBeenSent = 0;
|
||||
char *dataBuffer = NULL;
|
||||
T_TestPayloadCameraPlaybackCommand playbackCommand = {0};//??????????????????????
|
||||
T_TestPayloadCameraPlaybackCommand playbackCommand = {0};//取出将要执行的命令,放入此变量
|
||||
uint16_t bufferReadSize = 0;
|
||||
char *videoFilePath = NULL;
|
||||
char *transcodedFilePath = NULL;//转换视频编码后的文件路径
|
||||
@ -1238,6 +1253,8 @@ static void *UserCameraMedia_SendVideoTask(void *arg)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int frameNumberSendCounter=0;
|
||||
|
||||
while (1) {
|
||||
osalHandler->TaskSleepMs(1000 / SEND_VIDEO_TASK_FREQ);
|
||||
|
||||
@ -1354,6 +1371,8 @@ send:
|
||||
//3. 解析视频流文件
|
||||
//基于PSDK 开发的相机类负载设备获取视频流文件的信息后,将解析视频流文件的内容,识别视频流文件的帧头。
|
||||
frameBufSize = frameInfo[frameNumber].size;//这行几行代码的意思:每一帧的大小不一样
|
||||
printf("第 %d 帧大小:%d\n", frameNumberSendCounter, frameBufSize);
|
||||
frameNumberSendCounter++;
|
||||
if (videoStreamType == DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT) {
|
||||
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 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;
|
||||
printf("摄像头的帧率%d\n",(int)dInputFps);
|
||||
printf("摄像头的帧率: %d\n",(int)dInputFps);
|
||||
|
||||
|
||||
//视频流的编解码器
|
||||
@ -1562,7 +1581,7 @@ static void *UserCameraMedia_SendVideoTask_tc(void *arg)
|
||||
AVCodec *pCodec;
|
||||
|
||||
pCodec=avcodec_find_decoder(v_ifmtCtx->streams[videoindex]->codecpar->codec_id);
|
||||
printf("编码器名字:%%s\n",pCodec->name);
|
||||
printf("编码器名字:%s\n",pCodec->name);
|
||||
|
||||
if(pCodec==NULL)
|
||||
{
|
||||
@ -1808,6 +1827,7 @@ static void *UserCameraMedia_SendVideoTask_tc(void *arg)
|
||||
//3. 解析视频流文件
|
||||
//基于PSDK 开发的相机类负载设备获取视频流文件的信息后,将解析视频流文件的内容,识别视频流文件的帧头。
|
||||
frameBufSize = datasize;
|
||||
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;
|
||||
}
|
||||
@ -1852,6 +1872,7 @@ static void *UserCameraMedia_SendVideoTask_tc(void *arg)
|
||||
dataLength - lengthOfDataHaveBeenSent);
|
||||
returnCode = DjiPayloadCamera_SendVideoStream((const uint8_t *) dataBuffer + lengthOfDataHaveBeenSent,
|
||||
lengthOfDataToBeSent);
|
||||
printf("fasong: %d!!!!\n", lengthOfDataToBeSent);
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
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
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
@ -33,6 +33,17 @@
|
||||
|
||||
#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
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -30,6 +30,9 @@
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "dji_typedef.h"
|
||||
#include "dji_power_management.h"
|
||||
#include <wiringPi.h>
|
||||
|
||||
#define HIGH_POWER_APPLY_PIN 11
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -54,6 +54,7 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
||||
|
||||
static void *PsdkTest_IrisRecordSystemChanged(void *arg);
|
||||
static void extractSpectralBinAndBandnumber(bool isModifyBin);
|
||||
static void closeXimeaRecordSystem();
|
||||
|
||||
/* Private values ------------------------------------------------------------*/
|
||||
static T_DjiTaskHandle s_widgetTestThread;
|
||||
@ -79,11 +80,12 @@ int systemON_Control = 0;
|
||||
|
||||
char s_strUIMessage[100]=" ";
|
||||
static char * s_strStateOfSbg=" ";
|
||||
static char * s_strSbgSatelliteCounter=" ";
|
||||
static char * s_strSbgAccuracy=" ";
|
||||
char s_strSbgSatelliteCounter[100]=" ";
|
||||
char s_strSbgAccuracy[100]=" ";
|
||||
char XimeaFramerate[100]=" ";
|
||||
int framerate = 0;
|
||||
char XimeaExposeTime[100]=" ";
|
||||
int exposeTimeInt = 0;
|
||||
char XimeaExposeMaxValue[100]=" ";
|
||||
char s_spectralBin[100]=" ";
|
||||
int spectralBinInt = 0;
|
||||
@ -111,14 +113,13 @@ static const T_DjiWidgetHandlerListItem s_widgetHandlerList[] = {
|
||||
{1, DJI_WIDGET_TYPE_LIST, 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},
|
||||
{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},
|
||||
{6, DJI_WIDGET_TYPE_INT_INPUT_BOX, 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},
|
||||
{9, DJI_WIDGET_TYPE_SWITCH, PsdkTestWidget_SetWidgetValue_StartRecord, DjiTestWidget_GetWidgetValue, NULL},
|
||||
{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[] = {
|
||||
@ -244,6 +245,8 @@ T_DjiReturnCode DjiTest_WidgetStartService(void)
|
||||
s_server.sin_family = AF_INET;
|
||||
s_server.sin_port = htons(PORT);
|
||||
s_server.sin_addr= *((struct in_addr *)he->h_addr);
|
||||
|
||||
system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 10");
|
||||
/* tc-----------------------------------------------*/
|
||||
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
|
||||
@ -285,18 +288,24 @@ static void *DjiTest_WidgetTask(void *arg)
|
||||
T_DjiReturnCode djiStat;
|
||||
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
|
||||
|
||||
extractSpectralBinAndBandnumber(false);
|
||||
|
||||
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);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("Get system time ms error, stat = 0x%08llX", djiStat);
|
||||
}
|
||||
|
||||
#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光谱bin: %s \n时间: %s min 空间: %s G\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);
|
||||
#else
|
||||
snprintf(message, DJI_WIDGET_FLOATING_WINDOW_MSG_MAX_LEN,
|
||||
@ -338,7 +347,7 @@ static void *DjiTest_WidgetTask(void *arg)
|
||||
|
||||
// 转换为MB
|
||||
double availableMB = availableBytes / (1024.0 * 1024.0);
|
||||
sprintf(remainingSpaceTmp, "%.0f", availableMB/1024);
|
||||
sprintf(remainingSpaceTmp, "%.2f", availableMB/1024);
|
||||
s_remainingSpace = remainingSpaceTmp;
|
||||
|
||||
if (spectralBinInt!=0 && framerate!=0)
|
||||
@ -355,7 +364,7 @@ static void *DjiTest_WidgetTask(void *arg)
|
||||
|
||||
double minTemp = availableMB / (frameSize * framerate * 60);
|
||||
|
||||
sprintf(remainingTimeTmp, "%.0f", minTemp);
|
||||
sprintf(remainingTimeTmp, "%.2f", minTemp);
|
||||
s_remainingTime = remainingTimeTmp;
|
||||
|
||||
// 打印结果
|
||||
@ -367,6 +376,8 @@ static void *DjiTest_WidgetTask(void *arg)
|
||||
// 关闭文件指针
|
||||
pclose(fp);
|
||||
|
||||
extractSpectralBinAndBandnumber(false);
|
||||
|
||||
|
||||
//判断ximeaAirborneSystem系统是否存活
|
||||
// if(ximeaAirborneSystemSurvivalTime > 10)
|
||||
@ -467,21 +478,11 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
||||
case 0:
|
||||
s_strStateOfSbg="未打开";
|
||||
|
||||
if (systemON_Control == 0 || systemON_Control == 4)
|
||||
{
|
||||
strcpy(s_strUIMessage,"系统已就绪!");
|
||||
messageTimeCounter = 0;
|
||||
messageTimespan = 1000;
|
||||
strcpy(s_strUIMessage,"系统已就绪!");
|
||||
messageTimeCounter = 0;
|
||||
messageTimespan = 1000;
|
||||
|
||||
systemON_Control = 1;//ximeaAirborneSystem系统一启动就会发送此信息 → 代表采集系统就绪;
|
||||
}
|
||||
|
||||
if (systemON_Control == 3)
|
||||
{
|
||||
strcpy(s_strUIMessage,"数据量过大,采集系统已经停止,请重新上电!");
|
||||
messageTimeCounter = 0;
|
||||
messageTimespan = 1000;
|
||||
}
|
||||
systemON_Control = 1;//ximeaAirborneSystem系统一启动就会发送此信息 → 代表采集系统就绪;
|
||||
|
||||
break;
|
||||
case 1:
|
||||
@ -492,7 +493,7 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
||||
break;
|
||||
case 3:
|
||||
s_strStateOfSbg="采集中";
|
||||
systemON_Control = 3;
|
||||
s_widgetValueList[5] = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -502,9 +503,10 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
||||
else if (strcmp(result[0],"Accuracy") == 0)
|
||||
{
|
||||
// printf("惯导定位精度为: %s\n\n", result[1]);
|
||||
// printf("卫星数为: %s\n\n", result[2]);
|
||||
|
||||
s_strSbgAccuracy=result[1];
|
||||
s_strSbgSatelliteCounter=result[2];
|
||||
strcpy(s_strSbgAccuracy,result[1]);
|
||||
strcpy(s_strSbgSatelliteCounter,result[2]);
|
||||
|
||||
ximeaAirborneSystemSurvivalTime++;
|
||||
|
||||
@ -531,19 +533,19 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
||||
switch (s_sbgMagState)
|
||||
{
|
||||
case 0:
|
||||
s_strSbgSolutionMode="UNINITI";//UNINITIALIZED
|
||||
s_strSbgSolutionMode="dis_UNINIT";//UNINITIALIZED
|
||||
break;
|
||||
case 1:
|
||||
s_strSbgSolutionMode="GYRO";//VERTICAL_GYRO
|
||||
s_strSbgSolutionMode="dis_GYRO";//VERTICAL_GYRO
|
||||
break;
|
||||
case 2:
|
||||
s_strSbgSolutionMode="AHRS";
|
||||
s_strSbgSolutionMode="dis_AHRS";
|
||||
break;
|
||||
case 3:
|
||||
s_strSbgSolutionMode="VELOCITY";//NAV_VELOCITY
|
||||
s_strSbgSolutionMode="dis_VELOCITY";//NAV_VELOCITY
|
||||
break;
|
||||
case 4:
|
||||
s_strSbgSolutionMode="FULL";//NAV_POSITION
|
||||
s_strSbgSolutionMode="en_FULL";//NAV_POSITION
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -586,24 +588,32 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
||||
messageTimespan = 200;
|
||||
break;
|
||||
case 100:
|
||||
s_strStateOfXimea="未打开";
|
||||
s_strStateOfXimea="未连接";
|
||||
break;
|
||||
case 101:
|
||||
s_strStateOfXimea="打开成功";
|
||||
s_strStateOfXimea="连接成功";
|
||||
s_widgetValueList[9] = 0;
|
||||
|
||||
strcpy(s_strUIMessage,"系统启动成功!");
|
||||
messageTimeCounter = 0;
|
||||
messageTimespan = 20;
|
||||
if(s_stateOfXimea == 100)
|
||||
{
|
||||
strcpy(s_strUIMessage,"系统启动成功!");
|
||||
messageTimeCounter = 0;
|
||||
messageTimespan = 20;
|
||||
}
|
||||
systemON_Control = 3;
|
||||
|
||||
break;
|
||||
case 102:
|
||||
s_strStateOfXimea="帧率完成";
|
||||
s_strStateOfXimea="连接成功";
|
||||
s_widgetValueList[9] = 0;
|
||||
break;
|
||||
case 103:
|
||||
s_strStateOfXimea="曝光完成";
|
||||
s_strStateOfXimea="连接成功";
|
||||
s_widgetValueList[9] = 0;
|
||||
break;
|
||||
case 104:
|
||||
s_strStateOfXimea="采集中";
|
||||
s_widgetValueList[9] = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -614,9 +624,9 @@ static void *PsdkTest_IrisRecordSystemChanged(void *arg)//
|
||||
{
|
||||
strcpy(XimeaExposeMaxValue, result[1]);
|
||||
|
||||
int exposeTimeTmp = atoi(result[2]);
|
||||
sprintf(XimeaExposeTime,"%d",exposeTimeTmp);
|
||||
s_widgetValueList[8] = exposeTimeTmp;
|
||||
exposeTimeInt = atoi(result[2]);
|
||||
sprintf(XimeaExposeTime,"%d",exposeTimeInt);
|
||||
s_widgetValueList[8] = exposeTimeInt;
|
||||
|
||||
strcpy(s_strUIMessage,"曝光时间设置成功!");
|
||||
messageTimeCounter = 0;
|
||||
@ -667,7 +677,6 @@ static T_DjiReturnCode DjiTestWidget_GetWidgetValue(E_DjiWidgetType widgetType,
|
||||
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,
|
||||
void *userData)
|
||||
{
|
||||
@ -675,17 +684,47 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
||||
|
||||
USER_LOG_INFO("Set widget value, widgetType = %s, widgetIndex = %d ,widgetValue = %d",
|
||||
s_widgetTypeNameArray[widgetType], index, value);
|
||||
int32_t valueTmp = s_widgetValueList[index];
|
||||
s_widgetValueList[index] = value;
|
||||
|
||||
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://系统启动关闭
|
||||
if (value==0)//系统关闭
|
||||
{
|
||||
printf("systemON_Control的值为:%d\n", systemON_Control);
|
||||
if (0 <= systemON_Control && systemON_Control <= 4)
|
||||
{
|
||||
strcpy(s_strUIMessage,"系统已经关闭!");
|
||||
strcpy(s_strUIMessage,"系统正在关闭!");
|
||||
messageTimeCounter = 0;
|
||||
messageTimespan = 1000;
|
||||
|
||||
@ -700,25 +739,7 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
||||
// printf("命令行指令为:%s\n",commandtmp);
|
||||
// system(commandtmp);
|
||||
|
||||
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=" ";
|
||||
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;
|
||||
closeXimeaRecordSystem();
|
||||
}
|
||||
}
|
||||
else if (value==1)//系统启动
|
||||
@ -763,6 +784,13 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
||||
messageTimeCounter = 0;
|
||||
messageTimespan = 10;
|
||||
|
||||
// printf("index-------:%d\n", index);
|
||||
// printf("valueTmp-------:%d\n", valueTmp);
|
||||
|
||||
//下面的代码没有作用:无法恢复界面的值为默认值(valueTmp)
|
||||
// DjiTestWidget_SetWidgetValue(widgetType, index, valueTmp, userData);
|
||||
// s_widgetValueList[index] = valueTmp;
|
||||
|
||||
break;
|
||||
}
|
||||
else if (s_stateOfXimea > 103)
|
||||
@ -794,12 +822,10 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
||||
}
|
||||
|
||||
//
|
||||
frameRateGlobel = value;
|
||||
|
||||
char command[50] = "5,";
|
||||
char framerate[20];
|
||||
sprintf(framerate,"%d",value);
|
||||
strcat(command,framerate);
|
||||
char framerate_str[20];
|
||||
sprintf(framerate_str,"%d",value);
|
||||
strcat(command,framerate_str);
|
||||
sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server));
|
||||
break;
|
||||
}
|
||||
@ -855,24 +881,13 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
||||
}
|
||||
|
||||
//曝光时间有效性判断
|
||||
if(frameRateGlobel == 0)
|
||||
{
|
||||
strcpy(s_strUIMessage,"请先设置帧率!");
|
||||
messageTimeCounter = 0;
|
||||
messageTimespan = 10;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
float maxExposureTime = 1 / (float)frameRateGlobel * 1000;//单位是ms
|
||||
float maxExposureTime = 1 / (float)framerate * 1000 * 1000;//单位是μs
|
||||
|
||||
if(value > maxExposureTime)
|
||||
{
|
||||
strcpy(s_strUIMessage,"曝光时间超过上限,无效!");
|
||||
strcpy(s_strUIMessage,"曝光时间已设置为最大!");
|
||||
messageTimeCounter = 0;
|
||||
messageTimespan = 10;
|
||||
|
||||
break;
|
||||
}
|
||||
else if(value == 0)
|
||||
{
|
||||
@ -895,6 +910,11 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
||||
case 9:
|
||||
if (value==0)//停止采集
|
||||
{
|
||||
if (s_stateOfXimea != 104)
|
||||
{
|
||||
s_strStateOfXimea="连接成功";
|
||||
}
|
||||
|
||||
char* command = "4";
|
||||
sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server));
|
||||
}
|
||||
@ -908,57 +928,13 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
||||
|
||||
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";
|
||||
sendto(s_sockfd, command,strlen(command),0,(struct sockaddr *)&s_server,sizeof(s_server));
|
||||
}
|
||||
break;
|
||||
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)//等待指令
|
||||
{
|
||||
}
|
||||
@ -970,10 +946,11 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
||||
{
|
||||
system("sudo sed -i 's/spectralBin =.*/spectralBin = 2;/g' /media/nvme/300TC/config/ximea.cfg");
|
||||
}
|
||||
closeXimeaRecordSystem();
|
||||
|
||||
extractSpectralBinAndBandnumber(true);
|
||||
|
||||
strcpy(s_strUIMessage,"请重新上电!");
|
||||
strcpy(s_strUIMessage,"请等待采集系统重启!");
|
||||
messageTimeCounter = 0;
|
||||
messageTimespan = 10000;
|
||||
|
||||
@ -985,6 +962,34 @@ static T_DjiReturnCode PsdkTestWidget_SetWidgetValue_StartRecord(E_DjiWidgetType
|
||||
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"," ");
|
||||
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)
|
||||
{
|
||||
unsigned long long spectralBin, height;
|
||||
@ -1029,17 +1034,8 @@ static void extractSpectralBinAndBandnumber(bool isModifyBin)
|
||||
pclose(fp);
|
||||
}
|
||||
|
||||
char command[256];
|
||||
memset(command, 0, sizeof(command));
|
||||
|
||||
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);
|
||||
s_widgetValueList[10] = spectralBin;
|
||||
spectralBinInt = spectralBin;
|
||||
|
||||
if (!isModifyBin)
|
||||
{
|
||||
|
@ -8,128 +8,18 @@
|
||||
"is_enable": true
|
||||
},
|
||||
"speaker": {
|
||||
"is_enable_tts": true,
|
||||
"is_enable_tts": false,
|
||||
"is_enable_voice": false
|
||||
},
|
||||
"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": {
|
||||
"text_input_box": {
|
||||
"widget_name": "文本输入框",
|
||||
"placeholder_text": "请输入消息",
|
||||
"is_enable": true
|
||||
},
|
||||
"widget_list": [
|
||||
{
|
||||
"widget_index": 5,
|
||||
"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_index": 4,
|
||||
"widget_type": "list",
|
||||
"widget_name": "系统指令",
|
||||
"widget_name": "高级指令",
|
||||
"list_item": [
|
||||
{
|
||||
"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_name": "bin",
|
||||
"list_item": [
|
||||
|
@ -8,128 +8,18 @@
|
||||
"is_enable": true
|
||||
},
|
||||
"speaker": {
|
||||
"is_enable_tts": true,
|
||||
"is_enable_tts": false,
|
||||
"is_enable_voice": false
|
||||
},
|
||||
"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": {
|
||||
"text_input_box": {
|
||||
"widget_name": "TextInputBox",
|
||||
"placeholder_text": "Please input message",
|
||||
"is_enable": true
|
||||
},
|
||||
"widget_list": [
|
||||
{
|
||||
"widget_index": 5,
|
||||
"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_index": 4,
|
||||
"widget_type": "list",
|
||||
"widget_name": "系统指令",
|
||||
"widget_name": "高级指令",
|
||||
"list_item": [
|
||||
{
|
||||
"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_name": "bin",
|
||||
"list_item": [
|
||||
|
@ -85,7 +85,7 @@ T_DjiReturnCode DjiTest_XPortStartService(void)
|
||||
return djiStat;
|
||||
}
|
||||
|
||||
//通过注册回调函数获取X-Port 的姿态信息.注册后,回调函数将会被自动调用,调用频率为
|
||||
//通过注册回调函数获取X-Port 的姿态信息.注册后,回调函数将会被自动调用,调用频率为10hz
|
||||
djiStat = DjiXPort_RegReceiveAttitudeInformationCallback(ReceiveXPortAttitudeInformation);
|
||||
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("register receive XPort attitude information callback function error: 0x%08llX.",
|
||||
|
@ -95,6 +95,9 @@ target_link_libraries(${PROJECT_NAME}
|
||||
z
|
||||
m
|
||||
pthread
|
||||
rt
|
||||
crypt
|
||||
wiringPi
|
||||
)
|
||||
|
||||
add_custom_command(TARGET ${PROJECT_NAME}
|
||||
|
@ -56,9 +56,9 @@
|
||||
#include "dji_sdk_config.h"
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define DJI_LOG_PATH "Logs/DJI"
|
||||
#define DJI_LOG_INDEX_FILE_NAME "Logs/latest"
|
||||
#define DJI_LOG_FOLDER_NAME "Logs"
|
||||
#define DJI_LOG_PATH "/media/nvme/300TC/programRunLog/djiLog/DJI"
|
||||
#define DJI_LOG_INDEX_FILE_NAME "/media/nvme/300TC/programRunLog/djiLog/latest"
|
||||
#define DJI_LOG_FOLDER_NAME "/media/nvme/300TC/programRunLog/djiLog"
|
||||
#define DJI_LOG_PATH_MAX_SIZE (128)
|
||||
#define DJI_LOG_FOLDER_NAME_MAX_SIZE (32)
|
||||
#define DJI_LOG_MAX_COUNT (10)
|
||||
@ -137,7 +137,7 @@ int main(int argc, char **argv)
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
}
|
||||
|
||||
returnCode = DjiCore_SetAlias("300TC_3.32.37.21");
|
||||
returnCode = DjiCore_SetAlias("300TC_3.37.43.21");
|
||||
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
|
||||
USER_LOG_ERROR("set alias error");
|
||||
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
|
||||
@ -721,12 +721,32 @@ delay:
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static T_DjiReturnCode DjiTest_WriteHighPowerApplyPin(E_DjiPowerManagementPinState pinState)
|
||||
{
|
||||
//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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user