作者 潘浩彬

1稳定版更新

正在显示 44 个修改的文件 包含 2416 行增加595 行删除

要显示太多修改。

为保证性能只显示 44 of 44+ 个文件。

... ... @@ -17,6 +17,16 @@
"gimbal_h3_h10.h": "c",
"gimbal_h3_h150st.h": "c",
"uartconnection.h": "c",
"megaphone_tts.h": "c"
"megaphone_tts.h": "c",
"jzsdk_uart_output.h": "c",
"jzsdk_uart_recvdeal.h": "c",
"jzsdk_uart_input.h": "c",
"baseconfig.h": "c",
"jzsdk_uart_uartdeal.h": "c",
"gimbal_v3s_u3.h": "c",
"gimbal_v3s_tfa1.h": "c",
"searchlight_v3s_h1t.h": "c",
"megaphone_recordvoice.h": "c",
"gimbal_inandout.h": "c"
}
}
\ No newline at end of file
... ...
... ... @@ -21,7 +21,7 @@ set(CMAKE_CXX_COMPILER "/usr/local/arm/4.9.3/bin/arm-cortexa9-linux-gnueabihf-g+
# 工程名 JZ_UART_APP
project(JZ_UART_APP)
# 设置滤波方式 24行不能被改动,因为会被sh修改滤波方式
set(filtering_type directed_stopband_filtering)
set(filtering_type high_pass_filtering)
# 海外版本 27行不能改动
set(firewarm_origin DOMESTIC_VERSION)
... ...
... ... @@ -119,7 +119,7 @@ typedef enum {
//5B类帧
JZ_INSCODE_5BFRAME_FRAME = 0x10004000, //发送帧
JZ_INSCODE_5BFRAME_INITIATECONNECT = 0x10004101, //主动连接
JZ_INSCODE_5BFRAME_INITIATECONNECT = 0x10004101, //回复连接
JZ_INSCODE_5BFRAME_SUCESS = 0x10004200, //操作成功
JZ_INSCODE_5BFRAME_DEFEAT = 0x10004201, //操作失败
... ... @@ -174,6 +174,8 @@ typedef enum {
JZ_INSCODE_6AFRAME_CHECKSTATUS_SECONDARY_DEVICE_NAME = 0x10008400, //查询从设备设备名
JZ_INSCODE_6AFRAME_CHECKSTATUS_GIMBAL_LINKAGE = 0x10008401, //查询云台联动
JZ_INSCODE_6AFRAME_UART_BITRATE_CHANGE = 0x10008500, //串口比特率修改
//6B类
JZ_INSCODE_6BFRAME_CHECKSTATUS_SECONDARY_DEVICE_NAME = 0x1000C400, //回复从设备名
JZ_INSCODE_6BFRAME_CHECKSTATUS_GIMBAL_LINKAGE = 0x1000C401, //回复云台联动
... ...
... ... @@ -55,7 +55,7 @@ int JZsdk_FrameComparsion(char *getdata, int len)
|| ( (getdata[len -2]!= 0x00) && (getdata[ len -1] != 0x23) )
)
{
printf("接受到的帧,没有帧头或者帧尾,退出recv帧判断函数\n");
//printf("接受到的帧,没有帧头或者帧尾,退出recv帧判断函数\n");
return JZ_ERROR_SYSTEM_FRAME_ERROR;
}
}
\ No newline at end of file
... ...
... ... @@ -61,6 +61,11 @@ static int Comparison_6AFRAME_FirstLevelCode_0x6F(char *getdata)
case 0x51:
return JZ_INSCODE_6AFRAME_CHECKSTATUS_GIMBAL_LINKAGE;
break;
//串口比特率修改
case 0x52:
return JZ_INSCODE_6AFRAME_UART_BITRATE_CHANGE;
break;
default:
return JZ_ERROR_SYSTEM_FRAME_ERROR;
... ...
... ... @@ -18,6 +18,14 @@ int JZsdk_GetFrameTemplate(int InsCode ,char *str, int *str_len)
*
********************************************************************************************************************************************************/
case JZ_INSCODE_5AFRAME_ASKFORCONNECT:
{
char sendbuf[12] = {0x5A ,0x5A ,0x77 ,0x00 ,0x0C ,0x00 ,0x00 ,0x50 ,0x51 ,0x00 ,0x00 ,0x23};
memcpy(str, sendbuf, 12);
*str_len = 12;
}
break;
case JZ_INSCODE_5AFRAME_SEARCHLIGHT_SET_FREQUENCY:
{
char sendbuf[13] = {0x5A ,0x5A ,0x77 ,0x00 ,0x0D ,0x00 ,0x00 ,0x61 ,0x51 ,0x00 ,0x00 ,0x00 ,0x23};
... ...
... ... @@ -152,6 +152,30 @@ T_JZsdkReturnCode writeToLogFile(const char *data)
pthread_mutex_unlock(&LogWriteMutex);
}
T_JZsdkReturnCode HexToLogFile(const char *data)
{
// 加锁
pthread_mutex_lock(&LogWriteMutex);
logFile = fopen(LogFileName, "a"); // 使用"a"模式打开文件,以在末尾追加数据
if (logFile == NULL) {
// 文件打开失败,输出错误消息
printf("Failed to open file: %s", LogFileName);
pthread_mutex_unlock(&LogWriteMutex);
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
fprintf(logFile, "%x ", data[0]); // 写入新的数据
fclose(logFile);
// 解锁
pthread_mutex_unlock(&LogWriteMutex);
}
void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...)
{
// 将日志级别转换为相应的字符串
... ... @@ -172,6 +196,14 @@ void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...)
default:
break;
}
//减少打印
if (level < JZSDK_LOG_LEVEL)
{
return;
}
// 使用可变参数处理传入的格式化字符串和可变参数
va_list args;
va_start(args, fmt);
... ... @@ -199,4 +231,49 @@ void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...)
//写入日志
writeToLogFile(finalLogMessage);
}
void JZsdk_User_OutputHex(E_JZsdkConsoleLogLevel level, const char *fmt, ...)
{
// 将日志级别转换为相应的字符串
const char *JZSDK_LOGGER_CONSOLE_LOG_LEVEL = "";
switch (level) {
case JZSDK_LOGGER_CONSOLE_LOG_LEVEL_DEBUG:
JZSDK_LOGGER_CONSOLE_LOG_LEVEL = "DEBUG";
break;
case JZSDK_LOGGER_CONSOLE_LOG_LEVEL_INFO:
JZSDK_LOGGER_CONSOLE_LOG_LEVEL = "INFO";
break;
case JZSDK_LOGGER_CONSOLE_LOG_LEVEL_WARN:
JZSDK_LOGGER_CONSOLE_LOG_LEVEL = "WARNING";
break;
case JZSDK_LOGGER_CONSOLE_LOG_LEVEL_ERROR:
JZSDK_LOGGER_CONSOLE_LOG_LEVEL = "ERROR";
break;
default:
break;
}
// 使用可变参数处理传入的格式化字符串和可变参数
va_list args;
va_start(args, fmt);
//格式化日志消息
char logMessage[10];
memset(logMessage, 0, sizeof(logMessage));
vsnprintf(logMessage, sizeof(logMessage), fmt, args);
va_end(args);
// 执行具体的日志输出操作
char finalLogMessage[512];
memset(finalLogMessage, 0, sizeof(finalLogMessage));
snprintf(finalLogMessage, 612, "%s", logMessage);
printf("%x ",finalLogMessage[0]);
//写入日志
HexToLogFile(finalLogMessage);
}
\ No newline at end of file
... ...
... ... @@ -45,6 +45,7 @@ typedef enum {
/* Exported functions --------------------------------------------------------*/
void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...);
T_JZsdkReturnCode JZsdk_LoggerInit();
void JZsdk_User_OutputHex(E_JZsdkConsoleLogLevel level, const char *fmt, ...);
/* Exported constants --------------------------------------------------------*/
#define JZSDK_LOG_DEBUG(fmt, ...) \
... ... @@ -55,6 +56,10 @@ T_JZsdkReturnCode JZsdk_LoggerInit();
JZsdk_UserLogOutput(JZSDK_LOGGER_CONSOLE_LOG_LEVEL_WARN, "[%s:%d) " fmt, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
#define JZSDK_LOG_ERROR(fmt, ...) \
JZsdk_UserLogOutput(JZSDK_LOGGER_CONSOLE_LOG_LEVEL_ERROR, "[%s:%d) " fmt, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
#define JZSDK_LOG_OUTPUTHEX(fmt, ...) \
JZsdk_User_OutputHex(JZSDK_LOGGER_CONSOLE_LOG_LEVEL_INFO, "" fmt , ##__VA_ARGS__)
#define JZSDK_LOG_LEVEL JZSDK_LOGGER_CONSOLE_LOG_LEVEL_DEBUG
#ifdef __cplusplus
... ...
... ... @@ -7,6 +7,7 @@
#include "BaseConfig.h"
#include "version_choose.h"
#include "JZsdk_Uart_Input.h"
#include "JZsdk_Uart_UartDeal.h"
#include "Gimbal_InAndOut.h"
#include "Uart_Config.h"
... ... @@ -33,11 +34,11 @@ int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME)
{
return UartDevUseFlag.UartDev_DEV1;
}
if (UART_DEV_NAME == UART_DEV_2)
else if (UART_DEV_NAME == UART_DEV_2)
{
return UartDevUseFlag.UartDev_DEV2;
}
if (UART_DEV_NAME == UART_4G)
else if (UART_DEV_NAME == UART_4G)
{
return UartDevUseFlag.UartDev_4G;
}
... ... @@ -50,38 +51,105 @@ int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME)
* *********/
int JZsdk_Uart_Init(int UART_DEV_NAME)
{
//初始化的是一号设备
if (UART_DEV_NAME == UART_DEV_1)
{
JZsdk_Uart_SecondInit(UART_DEV_1,UART_DEV1_BITRATE);
}
//初始化的是二号设备
else if (UART_DEV_NAME == UART_DEV_2)
{
JZsdk_Uart_SecondInit(UART_DEV_2, UART_DEV2_BITRATE);
}
else if (UART_DEV_NAME == UART_4G)
{
JZsdk_Uart_SecondInit(UART_4G, COMM_4G_UART_BITRATE);
}
printf("%x串口初始化完成\n", UART_DEV_NAME);
}
/**************
*
* 串口部分修改波特率
*
* *********/
int JZsdk_Uart_BitRateChange(int UART_DEV_NAME, int BitRate)
{
//1、释放掉原串口
if (UART_DEV_NAME == UART_DEV_1)
{
//将使用标识关闭
UartDevUseFlag.UartDev_DEV1 = JZ_FLAGCODE_OFF;
//等候关闭接收线程
JZsdk_Uart_CloseUartThead(UART_DEV_NAME, BitRate);
}
//1、释放掉原串口
else if (UART_DEV_NAME == UART_DEV_2)
{
//将使用标识关闭
UartDevUseFlag.UartDev_DEV2 = JZ_FLAGCODE_OFF;
//等候关闭接收线程
JZsdk_Uart_CloseUartThead(UART_DEV_NAME, BitRate);
}
//1、释放掉原串口
else if (UART_DEV_NAME == UART_4G)
{
//将使用标识关闭
UartDevUseFlag.UartDev_4G = JZ_FLAGCODE_OFF;
//等候关闭接收线程
JZsdk_Uart_CloseUartThead(UART_DEV_NAME, BitRate);
}
}
/**************
*
* 串口部分串口再注册
*
* *********/
int JZsdk_Uart_SecondInit(int UART_DEV_NAME, int BitRate)
{
int Uart_fd = 0;
printf("初始化串口%d\n",UART_DEV_NAME);
//初始化的是一号设备
if (UART_DEV_NAME == UART_DEV_1)
{
//1、串口初始化
Uart_fd = UartConnection_UartEnabled(UART_DEV1_NUM, UART_DEV1_BITRATE);
Uart_fd = UartConnection_UartEnabled(UART_DEV1_NUM, BitRate);
//2、串口接收初始化
JZsdk_Uart_UartDeal_Receive(Uart_fd, UART_DEV_1);
//3、将使用标识打开
UartDevUseFlag.UartDev_DEV1 = JZ_FLAGCODE_ON;
}
//初始化的是二号设备
if (UART_DEV_NAME == UART_DEV_2)
}
else if (UART_DEV_NAME == UART_DEV_2)
{
//1、串口初始化
Uart_fd = UartConnection_UartEnabled(UART_DEV2_NUM, UART_DEV2_BITRATE);
Uart_fd = UartConnection_UartEnabled(UART_DEV2_NUM, BitRate);
//2、串口接收初始化
JZsdk_Uart_UartDeal_Receive(Uart_fd, UART_DEV_2);
//3、将使用标识打开
UartDevUseFlag.UartDev_DEV2 = JZ_FLAGCODE_ON;
}
}
if (UART_DEV_NAME == UART_4G)
else if (UART_DEV_NAME == UART_4G)
{
//1、串口初始化
Uart_fd = UartConnection_UartEnabled(COMM_4G_UART_NUM, COMM_4G_UART_BITRATE);
Uart_fd = UartConnection_UartEnabled(COMM_4G_UART_NUM, BitRate);
//2、串口接收初始化
JZsdk_Uart_UartDeal_Receive(Uart_fd, UART_4G);
... ... @@ -89,9 +157,29 @@ int JZsdk_Uart_Init(int UART_DEV_NAME)
//3、将使用标识打开
UartDevUseFlag.UartDev_4G = JZ_FLAGCODE_ON;
}
}
/*
*
* 发送自由帧
*
*/
int JZsdk_Uart_Send_CustomOrder(int UartPort, char *sendbuf, int len)
{
JZsdk_Uart_SendDeal_Send_CustomOrder(UartPort, sendbuf, len);
}
/*
*
* 发送请求连接帧
*
*/
int JZsdk_Uart_Send_ConnectFrame(int PortNum)
{
//发送请求连接帧
JZsdk_Uart_SendDeal_Send_ConnectFrame(PortNum);
}
printf("%x串口初始化完成\n", UART_DEV_NAME);
}
/*
... ...
... ... @@ -25,6 +25,8 @@ extern "C" {
/* Exported functions --------------------------------------------------------*/
int JZsdk_Uart_Init(int UART_DEV_NAME);
int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME);
int JZsdk_Uart_Send_ConnectFrame(int PortNum);
int JZsdk_Uart_Send_CustomOrder(int UartPort, char *sendbuf, int len);
int JZsdk_Uart_Reply_PlayStatus_end(int PortNum);
int JZsdk_Uart_Send_PlayStatus(int Uartport ,int num);
... ... @@ -75,6 +77,8 @@ int JZsdk_Uart_Send_CheckStatus_WarningLightColor(int Uartport);
int JZsdk_Uart_Send_OutputPowerStatus(int Uartport, int FrameSequence, int status);
int JZsdk_Uart_BitRateChange(int UART_DEV_NAME, int BitRate);
int JZsdk_Uart_SecondInit(int UART_DEV_NAME, int BitRate);
#ifdef __cplusplus
}
... ...
... ... @@ -443,7 +443,7 @@ T_JZsdkReturnCode JZsdk_Uart_SearchLight_Control(int DeviceName, int mode)
**********/
T_JZsdkReturnCode JZsdk_Uart_SearchLight_Lumen(int DeviceName, int LeftLumen, int RightLumen)
{
return UIcontrol_Set_SearchLightLumen(DeviceName, LeftLumen, RightLumen);
return UIcontrol_Set_SearchLightLumen(DeviceName, 1, LeftLumen, RightLumen);
}
/*********
... ... @@ -728,6 +728,19 @@ T_JZsdkReturnCode JZsdk_Uart_Checkstatus_OutPutPower(int DeviceName, int FrameSe
********* ********|
********* ********|
*********************************************************************************************************/
/*********
*
* 收到连接回复帧
*
**********/
int JZsdl_Uart_ObtainConnectFrame(char *getbuf, int value)
{
#if APP_VERSION == APP_TEST
TestAPP_Connect(value);
#endif
}
/*******************************************************************************************************************************
*
... ...
... ... @@ -28,6 +28,7 @@ extern "C" {
/* Exported functions --------------------------------------------------------*/
int JZsdk_Uart_Init(int UART_DEV_NAME);
int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME);
int JZsdl_Uart_ObtainConnectFrame(char *getbuf, int value);
int JZsdk_Uart_Set_Amplifier(int status);
T_JZsdkReturnCode JZsdk_Uart_Set_Volume(int DeviceName, int value);
... ...
... ... @@ -7,6 +7,7 @@
#include "JZsdk_Uart_Send/JZsdk_Uart_Send.h"
#include "JZsdk_Uart_Output.h"
#include "JZsdk_Uart_Input.h"
#include "version_choose.h"
... ... @@ -15,7 +16,8 @@ int UART_4G_Receive_mode = 0;
static char TTS_Recv_buffer[1009]; //TTS接收数据缓冲区 1000中文 + 3个字中文的防溢出区
static int TTS_Recv_buffer_length = 0;
int JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(int value);
int JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(int value);
static T_JZsdkReturnCode JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
/********************************************************************************************************
********* ********|
... ... @@ -39,7 +41,7 @@ int JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(int value);
**********/
static int Uart_4G_RecvDeal_AskForConnect(char *getbuf)
{
JZSDK_LOG_INFO("串口设备4g,连接成功");
JZSDK_LOG_INFO("串口设备4G,连接成功");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
... ... @@ -50,7 +52,7 @@ static int Uart_4G_RecvDeal_AskForConnect(char *getbuf)
JZsdk_Uart_SendDeal_Send_Connect(UART_4G, Device_name);
//1、将串口程序设置为连接模式
//JZsdk_Uart_SetMainWorkMode(JZ_FLAGCODE_ON);s
//JZsdk_Uart_SetMainWorkMode(JZ_FLAGCODE_ON);
}
/*******************************************************************************************************************************
... ... @@ -65,7 +67,7 @@ static int Uart_4G_RecvDeal_AskForConnect(char *getbuf)
*
*
**********/
static int Uart_4G_RecvDeal_RealTimeMP2_start(char *getbuf)
static T_JZsdkReturnCode Uart_4G_RecvDeal_RealTimeMP2_start(char *getbuf)
{
JZSDK_LOG_INFO("开启MP2实时喊话功能\n");
T_JZsdkReturnCode ret;
... ... @@ -73,8 +75,18 @@ static int Uart_4G_RecvDeal_RealTimeMP2_start(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
JZSDK_LOG_ERROR("开启MP2实时喊话功能失败\n");
return ret;
}
//1、修改接收模式
JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION);
JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION);
//2、获取码率倍率 默认8k
int RateMagnification = (int)getbuf[9];
... ... @@ -124,7 +136,7 @@ static int Uart_4G_RecvDeal_RealTimeMP2_transmission(char *getdata, int len)
*
*
**********/
static int Uart_4G_RecvDeal_RealTimeMP2_stop(char *getbuf)
static T_JZsdkReturnCode Uart_4G_RecvDeal_RealTimeMP2_stop(char *getbuf)
{
JZSDK_LOG_INFO("关闭MP2实时喊话功能\n");
T_JZsdkReturnCode ret;
... ... @@ -132,8 +144,17 @@ static int Uart_4G_RecvDeal_RealTimeMP2_stop(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
if (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
JZSDK_LOG_ERROR("操作失败,mp2传输未开始,无法关闭");
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
//1、修改接收模式
JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP);
JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP);
//2、关闭实时MP2模式
ret = JZsdk_Uart_RealTimeMP2_Close();
... ... @@ -155,12 +176,21 @@ static int Uart_4G_RecvDeal_RealTimeMP2_stop(char *getbuf)
*
*
**********/
static int Uart_4G_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
static T_JZsdkReturnCode Uart_4G_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
{
JZSDK_LOG_INFO("开始传输的音频文件保存\n");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
JZSDK_LOG_ERROR("开始传输的音频文件保存失败");
return ret;
}
//1、处理帧长度,获取文件名长度
int FileNameLen = ((int)getbuf[3] << 8) + (int)getbuf[4] - 2 - 9;
... ... @@ -170,7 +200,7 @@ static int Uart_4G_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
memcpy(FileName, &getbuf[9], FileNameLen);
JZSDK_LOG_INFO("保存的文件名为%s",FileName);
T_JZsdkReturnCode ret = JZsdk_Uart_SaveAudioFileStart(FileName);
ret = JZsdk_Uart_SaveAudioFileStart(FileName);
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
... ... @@ -178,7 +208,7 @@ static int Uart_4G_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
}
//3、调整接收模式为音频文件传输
JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION);
JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION);
//4、回复操作成功
JZsdk_Uart_SendDeal_Reply_Sucesss(UART_4G, FrameSequence);
... ... @@ -207,9 +237,20 @@ static int Uart_4G_RecvDeal_SaveAudioFileTrans_stop(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
if (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
JZSDK_LOG_ERROR("关闭音频文件上传失败,音频文件上传未开始,无法关闭");
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
//1、保存音频数据
JZsdk_Uart_SaveAudioFileStop();
//3、调整接收模式为音频文件传输
JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP);
//2、回复操作成功
JZsdk_Uart_SendDeal_Reply_Sucesss(UART_4G, FrameSequence);
}
... ... @@ -849,12 +890,21 @@ static int Uart_4G_RecvDeal_TTS_SetSpeed(char *getbuf)
// 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x03 0x00 0x00 0x23 开始TTS发送
// 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX TTS数据
// 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x04 0x00 0x00 0x23 结束TTS发送
static int Uart_4G_RecvDeal_TTS_Trans_start(char *getbuf)
static T_JZsdkReturnCode Uart_4G_RecvDeal_TTS_Trans_start(char *getbuf)
{
JZSDK_LOG_INFO("tts开始传输");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
JZSDK_LOG_ERROR("tts开始传输失败");
return ret;
}
//1、重置缓冲区
memset(TTS_Recv_buffer, 0, 1009);
... ... @@ -862,7 +912,7 @@ static int Uart_4G_RecvDeal_TTS_Trans_start(char *getbuf)
TTS_Recv_buffer_length = 0;
//3、将接收模式设置为接收TTS数据模式
JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION);
JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION);
//回复操作成功
JZsdk_Uart_SendDeal_Reply_Sucesss(UART_4G, FrameSequence);
... ... @@ -897,17 +947,32 @@ static int Uart_4G_RecvDeal_TTS_Trans_transmission(char *getdata, int len)
*
*
**********/
static int Uart_4G_RecvDeal_TTS_Trans_stop(char *getbuf)
static T_JZsdkReturnCode Uart_4G_RecvDeal_TTS_Trans_stop(char *getbuf)
{
JZSDK_LOG_INFO("tts传输结束");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
if (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)
{
JZSDK_LOG_INFO("未刷新文本,TTS播放%s",TTS_Recv_buffer);
//3、播放TTS
JZsdk_Uart_TTS_Play(UART_4G, TTS_Recv_buffer, TTS_Recv_buffer_length);
//回复操作成功
JZsdk_Uart_SendDeal_Reply_Sucesss(UART_4G, FrameSequence);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
//1、打印一次TTS文本
JZSDK_LOG_INFO("TTS播放%s",TTS_Recv_buffer);
//2、播放TTS
//2、将接收模式设置为关闭接收TTS
JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP);
//3、播放TTS
JZsdk_Uart_TTS_Play(UART_4G, TTS_Recv_buffer, TTS_Recv_buffer_length);
//回复操作成功
... ... @@ -921,12 +986,21 @@ static int Uart_4G_RecvDeal_TTS_Trans_stop(char *getbuf)
*
*
**********/
static int Uart_4G_RecvDeal_OpusTrans_start(char *getbuf)
static T_JZsdkReturnCode Uart_4G_RecvDeal_OpusTrans_start(char *getbuf)
{
JZSDK_LOG_INFO("打开opus传输\n");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
JZSDK_LOG_ERROR("打开opus传输失败");
return ret;
}
//1、获取解码比特率
int decode_rate = getbuf[9] * 8000;
if(decode_rate == 0)
... ... @@ -938,7 +1012,7 @@ static int Uart_4G_RecvDeal_OpusTrans_start(char *getbuf)
JZsdk_Uart_SaveOpusStart(decode_rate);
//3、修改接收模式为传输opus
JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION);
JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION);
JZSDK_LOG_INFO("已完成打开opus传输处理\n");
... ... @@ -959,7 +1033,7 @@ static int Uart_4G_RecvDeal_OpusTrans_transmission(char *SaveData, int size)
}
/*********
*
* opus传输
* opus结束传输
*
*
**********/
... ... @@ -969,8 +1043,19 @@ static int Uart_4G_RecvDeal_OpusTrans_stop(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
if (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
JZSDK_LOG_ERROR("关闭opus结束传输失败,opus结束传输未开始,无法关闭");
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
JZsdk_Uart_SaveOpusStop();
JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP);
JZSDK_LOG_INFO("结束opus传输处理\n");
//回复操作成功
... ... @@ -988,6 +1073,15 @@ static int Uart_4G_RecvDeal_OpusPlay(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
JZSDK_LOG_ERROR("opus播放失败,存在传输模式打开中");
return ret;
}
JZsdk_Uart_Opus_PlayFixedFile(UART_4G);
//回复操作成功
... ... @@ -1002,14 +1096,23 @@ static int Uart_4G_RecvDeal_OpusPlay(char *getbuf)
*
*
**********/
static int Uart_4G_RecvDeal_Opus_RealTimeVoice_start(char *getbuf)
static T_JZsdkReturnCode Uart_4G_RecvDeal_Opus_RealTimeVoice_start(char *getbuf)
{
JZSDK_LOG_INFO("开启opus实时喊话功能\n");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
JZSDK_LOG_ERROR("开启opus实时喊话失败");
return ret;
}
//1、修改接收模式
JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION);
JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION);
//2、获取码率倍率 默认8k*1倍
int RateMagnification = (int)getbuf[9];
... ... @@ -1055,8 +1158,16 @@ static int Uart_4G_RecvDeal_Opus_RealTimeVoice_stop(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
if (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
JZSDK_LOG_ERROR("关闭opus实时语音发送功能失败,opus实时语音发送功能未开始,无法关闭");
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
//1、修改接收模式
JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP);
JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP);
//2、关闭实时语音模式
JZsdk_Uart_RealTimeVoiceClose();
... ... @@ -1319,7 +1430,7 @@ static int Uart_4G_RecvDeal_SearchLight_SubscriptionControl(char *getbuf)
**********/
static int Uart_4G_RecvDeal_CheckStatus_SerialNumber(char *getbuf)
{
JZSDK_LOG_INFO("消息订阅控制\n");
JZSDK_LOG_INFO("查询产品序列号\n");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
... ... @@ -1794,7 +1905,7 @@ static int Uart_4G_RecvDeal_GimbalLinkageControl(char *getbuf)
**********/
static int Uart_4G_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
{
JZSDK_LOG_INFO("收到查询是否开启云台联动\n");
JZSDK_LOG_INFO("收到查询是否开启云台联动");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
... ... @@ -1803,6 +1914,47 @@ static int Uart_4G_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
JZsdk_Uart_Checkstatus_GimbalLinkage(UART_4G, FrameSequence);
}
static int Uart_4G_RecvDeal_UartBitrateChange(char *getbuf)
{
JZSDK_LOG_INFO("收到串口比特率修改");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
//修改比特率
int BitRateChoose = getbuf[10];
int BitRate;
switch (BitRateChoose)
{
case 1:
BitRate = 115200;
break;
case 2:
BitRate = 230400;
break;
case 3:
BitRate = 460800;
break;
case 4:
BitRate = 921600;
break;
case 5:
BitRate = 1000000;
break;
default:
BitRate = 115200;
break;
}
JZsdk_Uart_BitRateChange(UART_4G, BitRate);
}
/********************************************************************************************************
********* ********|
********* ********|
... ... @@ -1938,7 +2090,7 @@ static int Uart_4G_RecvDeal_OperationFailed(char *getbuf)
*********************************************************************************************************/
int Uart_4G_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int len)
{
JZSDK_LOG_INFO("串口设备4g,接受到的模式为:%x",Receive_mode);
JZSDK_LOG_INFO("串口设备4G,接受到的模式为:%x",Receive_mode);
switch (Receive_mode)
{
/*******************************************************************************************************************************
... ... @@ -2345,6 +2497,12 @@ int Uart_4G_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int len)
return 0;
break;
//串口比特率修改
case JZ_INSCODE_6AFRAME_UART_BITRATE_CHANGE:
Uart_4G_RecvDeal_UartBitrateChange(getdata);
return 0;
break;
/*******************************************************************************************************************************
*
* 6B类部分
... ... @@ -2408,182 +2566,6 @@ int Uart_4G_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int len)
********* ********|
********* ********|
*********************************************************************************************************/
static int Uart_4G_RecvDeal_RecvTransmission_CharmDeal(char* getbuf, int len, int flag)
{
int data_len = 0; //剩余数据长度
/******************************
*
* 如果当前为传输opus文件的状态
*
* ***************************/
if (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION)
{
//如果 传过来的帧为关闭传输opus
if (flag == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)
{
//返回 关闭传输opus帧
return JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;
}
//要是回来的帧最后藏着结束帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)
{
//把前面的还有剩的数据处理掉
data_len = len - 12;
Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);
//返回 关闭传输opus帧
return JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;
}
//要是回来的帧最后藏着播放帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_PLAY)
{
//说明 还藏着结束帧
//先把前面的还有剩的数据处理掉
data_len = len - 24;
Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);
//处理结束帧
if (JZsdk_FrameComparsion(getbuf + len - 24, 12) == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)
{
UART_4G_Receive_mode = JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;
Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, len);
}
//返回播放帧
return JZ_INSCODE_5AFRAME_OPUS_PLAY;
}
//都没有 继续传输状态
return JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION;
}
/******************************
*
* 如果当前为传输opus实时语音的状态
*
* ***************************/
//如果 如果处于传输实时语音模式 且 传过来的关闭语音帧
if (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION)
{
//如果 传过来的帧为关闭实时语音
if (flag == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP)
{
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP;
}
//要是回来的帧最后藏着结束帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP)
{
//把前面的还有剩的数据处理掉
data_len = len - 12;
Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP;
}
//都没有 继续传输状态
return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION;
}
/******************************
*
* 如果当前为传输mp2实时语音的状态
*
* ***************************/
//如果 如果处于传输实时语音模式 且 传过来的关闭语音帧
if (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION)
{
//如果 传过来的帧为关闭实时语音
if (flag == JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP)
{
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP;
}
//要是回来的帧最后藏着结束帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP)
{
//把前面的还有剩的数据处理掉
data_len = len - 12;
Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP;
}
//都没有 继续传输状态
return JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION;
}
/******************************
*
* 如果当前为传输音频文件的状态
*
* ***************************/
//如果 如果处于传输实时语音模式 且 传过来的关闭语音帧
if (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION)
{
//如果 传过来的帧为关闭实时语音
if (flag == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP)
{
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP;
}
//要是回来的帧最后藏着结束帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP)
{
//把前面的还有剩的数据处理掉
data_len = len - 12;
Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP;
}
//都没有 继续传输状态
return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION;
}
/******************************
*
* 如果当前为传输TTS的状态
*
* ***************************/
//如果 如果处于传输TTS模式 且 传过来的关闭TTS帧
if (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)
{
//如果 传过来的帧为关闭TTS
if (flag == JZ_INSCODE_5AFRAME_TTS_TRANS_STOP)
{
//返回 关闭TTS
return JZ_INSCODE_5AFRAME_TTS_TRANS_STOP;
}
//要是回来的帧最后藏着结束帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_TTS_TRANS_STOP)
{
//把前面的还有剩的数据处理掉
data_len = len - 12;
Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);
//返回 关闭TTS
return JZ_INSCODE_5AFRAME_TTS_TRANS_STOP;
}
//都没有 继续传输状态
return JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION;
}
// 以上的帧都不是
return JZ_ERROR_SYSTEM_FRAME_ERROR;
}
/********************************************************************************************************
... ... @@ -2602,42 +2584,41 @@ static int Uart_4G_RecvDeal_RecvTransmission_CharmDeal(char* getbuf, int len, in
int JZsdk_Uart_RecvDeal_CharmDeal_Uart_4G(unsigned char *getbuf, int len)
{
//1、不进行切割处理
//2、进行指令帧对比,确认该帧的功能
//已经进行了切割预处理
//1、进行指令帧对比,确认该帧的功能
int flag = JZsdk_FrameComparsion(getbuf, len);
//3、进行回复帧对比,确认该帧的功能
//4、如果传过来的是正常帧 且不处于传输过程,接收模式改变
if ((flag != JZ_ERROR_SYSTEM_FRAME_ERROR )
&& (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
//2、如果传过来的是正常帧
if (flag != JZ_ERROR_SYSTEM_FRAME_ERROR )
{
Uart_4G_RecvDeal_RecvDeal(flag, getbuf, len);
//如果不处于5大传输模式
if ((UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
&& (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
&& (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
&& (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
&& (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式
{
UART_4G_Receive_mode = flag;
}
//否则进入 传输过程 处理模式
else
{
flag = Uart_4G_RecvDeal_RecvTransmission_CharmDeal(getbuf, len, flag);
if (flag != JZ_ERROR_SYSTEM_FRAME_ERROR)
&& (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式)
{
//刷新模式
UART_4G_Receive_mode = flag;
}
}
//两次判断 flag的值都是JZ_ERROR_SYSTEM_FRAME_ERROR 说明真的不是帧
if (flag == JZ_ERROR_SYSTEM_FRAME_ERROR)
//否则 如果处于传输传输过程 处理模式 正常录入数据
else if (flag == JZ_ERROR_SYSTEM_FRAME_ERROR
&& ((UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
|| (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
|| (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
|| (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
|| (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION))) //TTS传输模式)
{
UART_4G_Receive_mode = JZ_ERROR_SYSTEM_FRAME_ERROR;
Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, len);
}
//4、根据2 放入接收处理函数
Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, len);
//否则直接丢弃
return -1;
}
/*******************
... ... @@ -2646,9 +2627,28 @@ int JZsdk_Uart_RecvDeal_CharmDeal_Uart_4G(unsigned char *getbuf, int len)
* ps : 仅在开启语音传送和 文件传输时会启用该函数
*
* ****************/
int JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(int value)
int JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(int value)
{
JZSDK_LOG_INFO("串口设备4g,二次修改接收模式%x\n",value);
JZSDK_LOG_INFO("串口设备4G,二次修改接收模式%x\n",value);
UART_4G_Receive_mode = value;
return 0;
}
/*
*/
static T_JZsdkReturnCode JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide()
{
if ((UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
|| (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
|| (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
|| (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
|| (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式)
{
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
\ No newline at end of file
... ...
... ... @@ -7,6 +7,7 @@
#include "JZsdk_Uart_Send/JZsdk_Uart_Send.h"
#include "JZsdk_Uart_Output.h"
#include "JZsdk_Uart_Input.h"
#include "version_choose.h"
... ... @@ -68,7 +69,7 @@ static int Uart_DEV1_RecvDeal_AskForConnect(char *getbuf)
**********/
static T_JZsdkReturnCode Uart_DEV1_RecvDeal_RealTimeMP2_start(char *getbuf)
{
JZSDK_LOG_INFO("开启MP2实时喊话功能\n");
JZSDK_LOG_DEBUG("开启MP2实时喊话功能\n");
T_JZsdkReturnCode ret;
//获取帧的序列号
... ... @@ -137,7 +138,7 @@ static int Uart_DEV1_RecvDeal_RealTimeMP2_transmission(char *getdata, int len)
**********/
static T_JZsdkReturnCode Uart_DEV1_RecvDeal_RealTimeMP2_stop(char *getbuf)
{
JZSDK_LOG_INFO("关闭MP2实时喊话功能\n");
JZSDK_LOG_DEBUG("关闭MP2实时喊话功能\n");
T_JZsdkReturnCode ret;
//获取帧的序列号
... ... @@ -1072,6 +1073,15 @@ static int Uart_DEV1_RecvDeal_OpusPlay(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV1_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_1, FrameSequence);
JZSDK_LOG_ERROR("opus播放失败,存在传输模式打开中");
return ret;
}
JZsdk_Uart_Opus_PlayFixedFile(UART_DEV_1);
//回复操作成功
... ... @@ -1420,7 +1430,7 @@ static int Uart_DEV1_RecvDeal_SearchLight_SubscriptionControl(char *getbuf)
**********/
static int Uart_DEV1_RecvDeal_CheckStatus_SerialNumber(char *getbuf)
{
JZSDK_LOG_INFO("消息订阅控制\n");
JZSDK_LOG_INFO("查询产品序列号\n");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
... ... @@ -1572,6 +1582,26 @@ static int Uart_DEV1_RecvDeal_CheckStatus_WarningLightColor(char *getbuf)
* 设备相关
*
* *******************************************************************************************************************************/
/*********
*
* 收到连接回复帧
*
**********/
static int Uart_DEV1_RecvDeal_ObtainConnectFrame(char *getbuf)
{
JZSDK_LOG_INFO("收到连接回复帧\n");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
//1、通过数据帧2,获取值
int value = getbuf[9];
//2、发送到本地处理
JZsdl_Uart_ObtainConnectFrame(UART_DEV_1, value);
}
/*******************************************************************************************************************************
*
... ... @@ -1895,7 +1925,7 @@ static int Uart_DEV1_RecvDeal_GimbalLinkageControl(char *getbuf)
**********/
static int Uart_DEV1_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
{
JZSDK_LOG_INFO("收到查询是否开启云台联动\n");
JZSDK_LOG_INFO("收到查询是否开启云台联动");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
... ... @@ -1904,6 +1934,47 @@ static int Uart_DEV1_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
JZsdk_Uart_Checkstatus_GimbalLinkage(UART_DEV_1, FrameSequence);
}
static int Uart_DEV1_RecvDeal_UartBitrateChange(char *getbuf)
{
JZSDK_LOG_INFO("收到串口比特率修改");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
//修改比特率
int BitRateChoose = getbuf[10];
int BitRate;
switch (BitRateChoose)
{
case 1:
BitRate = 115200;
break;
case 2:
BitRate = 230400;
break;
case 3:
BitRate = 460800;
break;
case 4:
BitRate = 921600;
break;
case 5:
BitRate = 1000000;
break;
default:
BitRate = 115200;
break;
}
JZsdk_Uart_BitRateChange(UART_DEV_1, BitRate);
}
/********************************************************************************************************
********* ********|
********* ********|
... ... @@ -2367,6 +2438,11 @@ int Uart_DEV1_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le
* 5B类部分
*
* *******************************************************************************************************************************/
//连接回复
case JZ_INSCODE_5BFRAME_INITIATECONNECT:
Uart_DEV1_RecvDeal_ObtainConnectFrame(getdata);
break;
//回复灯光频率
case JZ_INSCODE_5BFRAME_CHECKSTATUS_SEARCHLIGHT_FREQUENCY:
Uart_DEV1_RecvDeal_ObtainSearchLight_Frequency(getdata);
... ... @@ -2446,6 +2522,12 @@ int Uart_DEV1_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le
return 0;
break;
//串口比特率修改
case JZ_INSCODE_6AFRAME_UART_BITRATE_CHANGE:
Uart_DEV1_RecvDeal_UartBitrateChange(getdata);
return 0;
break;
/*******************************************************************************************************************************
*
* 6B类部分
... ...
... ... @@ -7,6 +7,7 @@
#include "JZsdk_Uart_Send/JZsdk_Uart_Send.h"
#include "JZsdk_Uart_Output.h"
#include "JZsdk_Uart_Input.h"
#include "version_choose.h"
... ... @@ -15,7 +16,8 @@ int UART_DEV2_Receive_mode = 0;
static char TTS_Recv_buffer[1009]; //TTS接收数据缓冲区 1000中文 + 3个字中文的防溢出区
static int TTS_Recv_buffer_length = 0;
int JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(int value);
int JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(int value);
static T_JZsdkReturnCode JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
/********************************************************************************************************
********* ********|
... ... @@ -65,7 +67,7 @@ static int Uart_DEV2_RecvDeal_AskForConnect(char *getbuf)
*
*
**********/
static int Uart_DEV2_RecvDeal_RealTimeMP2_start(char *getbuf)
static T_JZsdkReturnCode Uart_DEV2_RecvDeal_RealTimeMP2_start(char *getbuf)
{
JZSDK_LOG_INFO("开启MP2实时喊话功能\n");
T_JZsdkReturnCode ret;
... ... @@ -73,8 +75,18 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_start(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
JZSDK_LOG_ERROR("开启MP2实时喊话功能失败\n");
return ret;
}
//1、修改接收模式
JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION);
JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION);
//2、获取码率倍率 默认8k
int RateMagnification = (int)getbuf[9];
... ... @@ -124,7 +136,7 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_transmission(char *getdata, int len)
*
*
**********/
static int Uart_DEV2_RecvDeal_RealTimeMP2_stop(char *getbuf)
static T_JZsdkReturnCode Uart_DEV2_RecvDeal_RealTimeMP2_stop(char *getbuf)
{
JZSDK_LOG_INFO("关闭MP2实时喊话功能\n");
T_JZsdkReturnCode ret;
... ... @@ -132,8 +144,17 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_stop(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
if (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
JZSDK_LOG_ERROR("操作失败,mp2传输未开始,无法关闭");
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
//1、修改接收模式
JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP);
JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP);
//2、关闭实时MP2模式
ret = JZsdk_Uart_RealTimeMP2_Close();
... ... @@ -155,12 +176,21 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_stop(char *getbuf)
*
*
**********/
static int Uart_DEV2_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
static T_JZsdkReturnCode Uart_DEV2_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
{
JZSDK_LOG_INFO("开始传输的音频文件保存\n");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
JZSDK_LOG_ERROR("开始传输的音频文件保存失败");
return ret;
}
//1、处理帧长度,获取文件名长度
int FileNameLen = ((int)getbuf[3] << 8) + (int)getbuf[4] - 2 - 9;
... ... @@ -170,7 +200,7 @@ static int Uart_DEV2_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
memcpy(FileName, &getbuf[9], FileNameLen);
JZSDK_LOG_INFO("保存的文件名为%s",FileName);
T_JZsdkReturnCode ret = JZsdk_Uart_SaveAudioFileStart(FileName);
ret = JZsdk_Uart_SaveAudioFileStart(FileName);
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
... ... @@ -178,7 +208,7 @@ static int Uart_DEV2_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
}
//3、调整接收模式为音频文件传输
JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION);
JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION);
//4、回复操作成功
JZsdk_Uart_SendDeal_Reply_Sucesss(UART_DEV_2, FrameSequence);
... ... @@ -207,9 +237,20 @@ static int Uart_DEV2_RecvDeal_SaveAudioFileTrans_stop(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
if (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
JZSDK_LOG_ERROR("关闭音频文件上传失败,音频文件上传未开始,无法关闭");
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
//1、保存音频数据
JZsdk_Uart_SaveAudioFileStop();
//3、调整接收模式为音频文件传输
JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP);
//2、回复操作成功
JZsdk_Uart_SendDeal_Reply_Sucesss(UART_DEV_2, FrameSequence);
}
... ... @@ -849,12 +890,21 @@ static int Uart_DEV2_RecvDeal_TTS_SetSpeed(char *getbuf)
// 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x03 0x00 0x00 0x23 开始TTS发送
// 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX TTS数据
// 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x04 0x00 0x00 0x23 结束TTS发送
static int Uart_DEV2_RecvDeal_TTS_Trans_start(char *getbuf)
static T_JZsdkReturnCode Uart_DEV2_RecvDeal_TTS_Trans_start(char *getbuf)
{
JZSDK_LOG_INFO("tts开始传输");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
JZSDK_LOG_ERROR("tts开始传输失败");
return ret;
}
//1、重置缓冲区
memset(TTS_Recv_buffer, 0, 1009);
... ... @@ -862,7 +912,7 @@ static int Uart_DEV2_RecvDeal_TTS_Trans_start(char *getbuf)
TTS_Recv_buffer_length = 0;
//3、将接收模式设置为接收TTS数据模式
JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION);
JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION);
//回复操作成功
JZsdk_Uart_SendDeal_Reply_Sucesss(UART_DEV_2, FrameSequence);
... ... @@ -897,17 +947,32 @@ static int Uart_DEV2_RecvDeal_TTS_Trans_transmission(char *getdata, int len)
*
*
**********/
static int Uart_DEV2_RecvDeal_TTS_Trans_stop(char *getbuf)
static T_JZsdkReturnCode Uart_DEV2_RecvDeal_TTS_Trans_stop(char *getbuf)
{
JZSDK_LOG_INFO("tts传输结束");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
if (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)
{
JZSDK_LOG_INFO("未刷新文本,TTS播放%s",TTS_Recv_buffer);
//3、播放TTS
JZsdk_Uart_TTS_Play(UART_DEV_2, TTS_Recv_buffer, TTS_Recv_buffer_length);
//回复操作成功
JZsdk_Uart_SendDeal_Reply_Sucesss(UART_DEV_2, FrameSequence);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
//1、打印一次TTS文本
JZSDK_LOG_INFO("TTS播放%s",TTS_Recv_buffer);
//2、播放TTS
//2、将接收模式设置为关闭接收TTS
JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP);
//3、播放TTS
JZsdk_Uart_TTS_Play(UART_DEV_2, TTS_Recv_buffer, TTS_Recv_buffer_length);
//回复操作成功
... ... @@ -921,12 +986,21 @@ static int Uart_DEV2_RecvDeal_TTS_Trans_stop(char *getbuf)
*
*
**********/
static int Uart_DEV2_RecvDeal_OpusTrans_start(char *getbuf)
static T_JZsdkReturnCode Uart_DEV2_RecvDeal_OpusTrans_start(char *getbuf)
{
JZSDK_LOG_INFO("打开opus传输\n");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
JZSDK_LOG_ERROR("打开opus传输失败");
return ret;
}
//1、获取解码比特率
int decode_rate = getbuf[9] * 8000;
if(decode_rate == 0)
... ... @@ -938,7 +1012,7 @@ static int Uart_DEV2_RecvDeal_OpusTrans_start(char *getbuf)
JZsdk_Uart_SaveOpusStart(decode_rate);
//3、修改接收模式为传输opus
JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION);
JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION);
JZSDK_LOG_INFO("已完成打开opus传输处理\n");
... ... @@ -959,7 +1033,7 @@ static int Uart_DEV2_RecvDeal_OpusTrans_transmission(char *SaveData, int size)
}
/*********
*
* opus传输
* opus结束传输
*
*
**********/
... ... @@ -969,8 +1043,19 @@ static int Uart_DEV2_RecvDeal_OpusTrans_stop(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
if (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
JZSDK_LOG_ERROR("关闭opus结束传输失败,opus结束传输未开始,无法关闭");
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
JZsdk_Uart_SaveOpusStop();
JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP);
JZSDK_LOG_INFO("结束opus传输处理\n");
//回复操作成功
... ... @@ -988,6 +1073,15 @@ static int Uart_DEV2_RecvDeal_OpusPlay(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
JZSDK_LOG_ERROR("opus播放失败,存在传输模式打开中");
return ret;
}
JZsdk_Uart_Opus_PlayFixedFile(UART_DEV_2);
//回复操作成功
... ... @@ -1002,14 +1096,23 @@ static int Uart_DEV2_RecvDeal_OpusPlay(char *getbuf)
*
*
**********/
static int Uart_DEV2_RecvDeal_Opus_RealTimeVoice_start(char *getbuf)
static T_JZsdkReturnCode Uart_DEV2_RecvDeal_Opus_RealTimeVoice_start(char *getbuf)
{
JZSDK_LOG_INFO("开启opus实时喊话功能\n");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
JZSDK_LOG_ERROR("开启opus实时喊话失败");
return ret;
}
//1、修改接收模式
JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION);
JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION);
//2、获取码率倍率 默认8k*1倍
int RateMagnification = (int)getbuf[9];
... ... @@ -1055,8 +1158,16 @@ static int Uart_DEV2_RecvDeal_Opus_RealTimeVoice_stop(char *getbuf)
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
if (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION)
{
//回复操作失败
JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
JZSDK_LOG_ERROR("关闭opus实时语音发送功能失败,opus实时语音发送功能未开始,无法关闭");
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
//1、修改接收模式
JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP);
JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP);
//2、关闭实时语音模式
JZsdk_Uart_RealTimeVoiceClose();
... ... @@ -1319,7 +1430,7 @@ static int Uart_DEV2_RecvDeal_SearchLight_SubscriptionControl(char *getbuf)
**********/
static int Uart_DEV2_RecvDeal_CheckStatus_SerialNumber(char *getbuf)
{
JZSDK_LOG_INFO("消息订阅控制\n");
JZSDK_LOG_INFO("查询产品序列号\n");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
... ... @@ -1794,7 +1905,7 @@ static int Uart_DEV2_RecvDeal_GimbalLinkageControl(char *getbuf)
**********/
static int Uart_DEV2_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
{
JZSDK_LOG_INFO("收到查询是否开启云台联动\n");
JZSDK_LOG_INFO("收到查询是否开启云台联动");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
... ... @@ -1803,6 +1914,47 @@ static int Uart_DEV2_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
JZsdk_Uart_Checkstatus_GimbalLinkage(UART_DEV_2, FrameSequence);
}
static int Uart_DEV2_RecvDeal_UartBitrateChange(char *getbuf)
{
JZSDK_LOG_INFO("收到串口比特率修改");
//获取帧的序列号
int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
//修改比特率
int BitRateChoose = getbuf[10];
int BitRate;
switch (BitRateChoose)
{
case 1:
BitRate = 115200;
break;
case 2:
BitRate = 230400;
break;
case 3:
BitRate = 460800;
break;
case 4:
BitRate = 921600;
break;
case 5:
BitRate = 1000000;
break;
default:
BitRate = 115200;
break;
}
JZsdk_Uart_BitRateChange(UART_DEV_2, BitRate);
}
/********************************************************************************************************
********* ********|
********* ********|
... ... @@ -2345,6 +2497,12 @@ int Uart_DEV2_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le
return 0;
break;
//串口比特率修改
case JZ_INSCODE_6AFRAME_UART_BITRATE_CHANGE:
Uart_DEV2_RecvDeal_UartBitrateChange(getdata);
return 0;
break;
/*******************************************************************************************************************************
*
* 6B类部分
... ... @@ -2408,182 +2566,6 @@ int Uart_DEV2_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le
********* ********|
********* ********|
*********************************************************************************************************/
static int Uart_DEV2_RecvDeal_RecvTransmission_CharmDeal(char* getbuf, int len, int flag)
{
int data_len = 0; //剩余数据长度
/******************************
*
* 如果当前为传输opus文件的状态
*
* ***************************/
if (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION)
{
//如果 传过来的帧为关闭传输opus
if (flag == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)
{
//返回 关闭传输opus帧
return JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;
}
//要是回来的帧最后藏着结束帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)
{
//把前面的还有剩的数据处理掉
data_len = len - 12;
Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);
//返回 关闭传输opus帧
return JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;
}
//要是回来的帧最后藏着播放帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_PLAY)
{
//说明 还藏着结束帧
//先把前面的还有剩的数据处理掉
data_len = len - 24;
Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);
//处理结束帧
if (JZsdk_FrameComparsion(getbuf + len - 24, 12) == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)
{
UART_DEV2_Receive_mode = JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;
Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, len);
}
//返回播放帧
return JZ_INSCODE_5AFRAME_OPUS_PLAY;
}
//都没有 继续传输状态
return JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION;
}
/******************************
*
* 如果当前为传输opus实时语音的状态
*
* ***************************/
//如果 如果处于传输实时语音模式 且 传过来的关闭语音帧
if (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION)
{
//如果 传过来的帧为关闭实时语音
if (flag == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP)
{
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP;
}
//要是回来的帧最后藏着结束帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP)
{
//把前面的还有剩的数据处理掉
data_len = len - 12;
Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP;
}
//都没有 继续传输状态
return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION;
}
/******************************
*
* 如果当前为传输mp2实时语音的状态
*
* ***************************/
//如果 如果处于传输实时语音模式 且 传过来的关闭语音帧
if (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION)
{
//如果 传过来的帧为关闭实时语音
if (flag == JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP)
{
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP;
}
//要是回来的帧最后藏着结束帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP)
{
//把前面的还有剩的数据处理掉
data_len = len - 12;
Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP;
}
//都没有 继续传输状态
return JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION;
}
/******************************
*
* 如果当前为传输音频文件的状态
*
* ***************************/
//如果 如果处于传输实时语音模式 且 传过来的关闭语音帧
if (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION)
{
//如果 传过来的帧为关闭实时语音
if (flag == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP)
{
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP;
}
//要是回来的帧最后藏着结束帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP)
{
//把前面的还有剩的数据处理掉
data_len = len - 12;
Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);
//返回 关闭实时语音
return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP;
}
//都没有 继续传输状态
return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION;
}
/******************************
*
* 如果当前为传输TTS的状态
*
* ***************************/
//如果 如果处于传输TTS模式 且 传过来的关闭TTS帧
if (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)
{
//如果 传过来的帧为关闭TTS
if (flag == JZ_INSCODE_5AFRAME_TTS_TRANS_STOP)
{
//返回 关闭TTS
return JZ_INSCODE_5AFRAME_TTS_TRANS_STOP;
}
//要是回来的帧最后藏着结束帧
if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_TTS_TRANS_STOP)
{
//把前面的还有剩的数据处理掉
data_len = len - 12;
Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);
//返回 关闭TTS
return JZ_INSCODE_5AFRAME_TTS_TRANS_STOP;
}
//都没有 继续传输状态
return JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION;
}
// 以上的帧都不是
return JZ_ERROR_SYSTEM_FRAME_ERROR;
}
/********************************************************************************************************
... ... @@ -2602,42 +2584,41 @@ static int Uart_DEV2_RecvDeal_RecvTransmission_CharmDeal(char* getbuf, int len,
int JZsdk_Uart_RecvDeal_CharmDeal_Uart_DEV2(unsigned char *getbuf, int len)
{
//1、不进行切割处理
//2、进行指令帧对比,确认该帧的功能
//已经进行了切割预处理
//1、进行指令帧对比,确认该帧的功能
int flag = JZsdk_FrameComparsion(getbuf, len);
//3、进行回复帧对比,确认该帧的功能
//4、如果传过来的是正常帧 且不处于传输过程,接收模式改变
if ((flag != JZ_ERROR_SYSTEM_FRAME_ERROR )
&& (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
//2、如果传过来的是正常帧
if (flag != JZ_ERROR_SYSTEM_FRAME_ERROR )
{
Uart_DEV2_RecvDeal_RecvDeal(flag, getbuf, len);
//如果不处于5大传输模式
if ((UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
&& (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
&& (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
&& (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
&& (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式
{
UART_DEV2_Receive_mode = flag;
}
//否则进入 传输过程 处理模式
else
{
flag = Uart_DEV2_RecvDeal_RecvTransmission_CharmDeal(getbuf, len, flag);
if (flag != JZ_ERROR_SYSTEM_FRAME_ERROR)
&& (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式)
{
//刷新模式
UART_DEV2_Receive_mode = flag;
}
}
//两次判断 flag的值都是JZ_ERROR_SYSTEM_FRAME_ERROR 说明真的不是帧
if (flag == JZ_ERROR_SYSTEM_FRAME_ERROR)
//否则 如果处于传输传输过程 处理模式 正常录入数据
else if (flag == JZ_ERROR_SYSTEM_FRAME_ERROR
&& ((UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
|| (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
|| (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
|| (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
|| (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION))) //TTS传输模式)
{
UART_DEV2_Receive_mode = JZ_ERROR_SYSTEM_FRAME_ERROR;
Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, len);
}
//4、根据2 放入接收处理函数
Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, len);
//否则直接丢弃
return -1;
}
/*******************
... ... @@ -2646,9 +2627,28 @@ int JZsdk_Uart_RecvDeal_CharmDeal_Uart_DEV2(unsigned char *getbuf, int len)
* ps : 仅在开启语音传送和 文件传输时会启用该函数
*
* ****************/
int JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(int value)
int JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(int value)
{
JZSDK_LOG_INFO("串口设备2号,二次修改接收模式%x\n",value);
UART_DEV2_Receive_mode = value;
return 0;
}
/*
*/
static T_JZsdkReturnCode JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide()
{
if ((UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
|| (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
|| (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
|| (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
|| (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式)
{
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
\ No newline at end of file
... ...
... ... @@ -8,13 +8,31 @@
#include "Jzsdk_Base/JZsdk_FrameComparsion/JZsdk_FrameComparsion.h"
//发送任务
static int JZsdk_Uart_SendDeal_SendOreder(int UartPort ,char *sendbuf, int len)
static int JZsdk_Uart_SendDeal_SendOrder(int UartPort ,char *sendbuf, int len)
{
JZsdk_Uart_UartSend(UartPort, sendbuf, len);
}
//发送自由帧
int JZsdk_Uart_SendDeal_Send_CustomOrder(int UartPort, char *sendbuf, int len)
{
JZsdk_Uart_UartSend(UartPort, sendbuf, len);
}
//发送连接帧
int JZsdk_Uart_SendDeal_Send_ConnectFrame(int Uartport)
{
char sendbuf[256];
int send_buf_len;
//1、获取帧样板
JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_ASKFORCONNECT , sendbuf, &send_buf_len);
//2、发送帧
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送回复连接帧
int JZsdk_Uart_SendDeal_Send_Connect(int Uartport ,int Version_flag)
{
char sendbuf[256];
... ... @@ -27,7 +45,7 @@ int JZsdk_Uart_SendDeal_Send_Connect(int Uartport ,int Version_flag)
sendbuf[9] = Version_flag;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送成功帧
... ... @@ -43,7 +61,7 @@ int JZsdk_Uart_SendDeal_Reply_Sucesss(int Uartport ,int FrameSequence)
sendbuf[6] = FrameSequence; //帧序列
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送失败帧
... ... @@ -59,7 +77,7 @@ int JZsdk_Uart_SendDeal_Reply_Failure(int Uartport ,int FrameSequence)
sendbuf[6] = FrameSequence; //帧序列
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送当前从设备名
... ... @@ -76,7 +94,7 @@ int JZsdk_Uart_SendDeal_Reply_SecondaryDeviceName(int Uartport , int device_name
sendbuf[10] = device_name;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
... ... @@ -93,7 +111,7 @@ int JZsdk_Uart_SendDeal_QuerySecondaryDeviceName(int Uartport ,int FrameSequence
sendbuf[6] = FrameSequence; //帧序列
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送当前设备序列号
... ... @@ -113,12 +131,14 @@ int JZsdk_Uart_SendDeal_SerialNumber(int UartPort, int FrameSequence, char *Seri
sendbuf[9+i] = SerialNumber[i];
}
sendbuf[21] = 0x00;
sendbuf[22] = 0x23;
sendbuf[23] = 0x00;
sendbuf[24] = 0x23;
sendbuf[4] = 0x17;
send_buf_len = 25;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(UartPort ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(UartPort ,sendbuf, send_buf_len);
}
... ... @@ -142,7 +162,7 @@ int JZsdk_Uart_SendDeal_Reply_Musiclist(int Uartport ,char *music_name, int musi
sendbuf[4] = len & 0xff;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, len);
}
//发送歌曲列表开始帧
... ... @@ -159,7 +179,7 @@ int JZsdk_Uart_SendDeal_Reply_Musiclist_start(int Uartport ,int num)
sendbuf[9] = num;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
... ... @@ -177,7 +197,7 @@ int JZsdk_Uart_SendDeal_Reply_Musiclist_end(int Uartport)
//2、写入数据
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送播放状态结束帧
... ... @@ -193,7 +213,7 @@ int JZsdk_Uart_SendDeal_Send_PlayStatus_end(int Uartport)
//2、写入数据
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送播放状态帧
... ... @@ -226,7 +246,7 @@ int JZsdk_Uart_SendDeal_Send_PlayStatus(int Uartport ,int num)
sendbuf[9] = (char)num;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//回复当前播放的歌曲名字
... ... @@ -250,7 +270,7 @@ int JZsdk_Uart_SendDeal_Reply_MusicName(int Uartport ,char *music_name, int musi
sendbuf[4] = len & 0xff;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, len);
}
//回复当前音量
... ... @@ -267,7 +287,7 @@ int JZsdk_Uart_SendDeal_Reply_Volume(int Uartport ,int num)
sendbuf[9] = (char)num;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
... ... @@ -290,7 +310,7 @@ int JZsdk_Uart_SendDeal_Reply_SoftVersion(int Uartport ,char majorVersion, char
sendbuf[12] = debugVersion;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送循环状态
... ... @@ -308,7 +328,7 @@ int JZsdk_Uart_SendDeal_Reply_LoopPlayStatus(int Uartport ,int status)
sendbuf[9] = status;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
... ... @@ -327,7 +347,7 @@ int JZsdk_Uart_SendDeal_Reply_TTS_tone(int Uartport ,int tone)
sendbuf[9] = tone;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送语速
... ... @@ -345,7 +365,7 @@ int JZsdk_Uart_SendDeal_Reply_TTS_speed(int Uartport ,int speed)
sendbuf[9] = speed;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
/****************************************************************************************************************************************************
... ... @@ -377,13 +397,13 @@ int JZsdk_Uart_SendDeal_Reply_GimbalPitchAngle(int Uartport ,int angle)
sendbuf[11] = (char)(angle & 255);
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//设置当前云台角度
int JZsdk_Uart_SendDeal_Set_GimbalPitchAngle(int Uartport ,int angle)
{
printf("发送设置云台角度帧\n");
printf("发送设置云台角度帧 %d\n",angle);
char sendbuf[256];
int send_buf_len;
... ... @@ -405,7 +425,7 @@ int JZsdk_Uart_SendDeal_Set_GimbalPitchAngle(int Uartport ,int angle)
sendbuf[11] = (angle & 0xff);
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//查询云台角度
... ... @@ -422,7 +442,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_GimbalAngle(int Uartport ,int FrameSequence)
sendbuf[6] = FrameSequence;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//微调云台pitch
... ... @@ -450,7 +470,7 @@ int JZsdk_Uart_SendDeal_Set_GimbalFineTuningPitch(int Uartport, int PitchFineTun
sendbuf[11] = (PitchFineTuning & 0xff);
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//查询云台角度微调值
... ... @@ -467,7 +487,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_GimbalFineTuningPitch(int Uartport, int Fram
sendbuf[6] = FrameSequence; //帧序列
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//回复云台pitch微调值
... ... @@ -495,7 +515,7 @@ int JZsdk_Uart_SendDeal_Reply_GimbalFineTuningPitch(int Uartport, int FrameSeque
sendbuf[11] = (FineTunigPitch & 0xff);
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//设置云台联动
... ... @@ -513,7 +533,7 @@ int JZsdk_Uart_SendDeal_Set_GimbalLinkageControl(int Uartport,int FrameSequence,
sendbuf[10] = value;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//查询云台联动值
... ... @@ -530,7 +550,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_GimbalLinkage(int Uartport,int FrameSequence
sendbuf[6] = FrameSequence; //帧序列
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送云台联动值
... ... @@ -548,7 +568,7 @@ int JZsdk_Uart_SendDeal_GimbalLinkageControl(int Uartport,int FrameSequence,int
sendbuf[10] = value;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送云台最大最小值帧
... ... @@ -566,7 +586,7 @@ int JZsdk_Uart_SendDeal_SetGimbalRange(int Uartport,int FrameSequence,int value)
sendbuf[10] = value;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
/****************************************************************************************************************************************************
... ... @@ -590,7 +610,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLightFrequency(int Uartport ,int Frequency)
sendbuf[10] = Frequency;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//设置探照灯控制
... ... @@ -608,7 +628,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Control(int Uartport,int mode)
sendbuf[10] = mode;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//设置探照灯亮度
... ... @@ -627,7 +647,7 @@ int JZsdk_Uart_SendDeal_SearchLight_SetLumen(int Uartport, int LeftLumen, int
sendbuf[10] = RightLumen;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//发送
... ... @@ -644,7 +664,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLight_CheckStatus_Frequency(int Uartport)
JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_FREQUENCY, sendbuf, &send_buf_len);
//2、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//查询探照灯亮度
... ... @@ -659,7 +679,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLight_CheckStatus_Lumen(int Uartport)
JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_LUMEN, sendbuf, &send_buf_len);
//2、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//查询探照灯模式
... ... @@ -674,7 +694,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLight_CheckStatus_Mode(int Uartport)
JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_MODE, sendbuf, &send_buf_len);
//2、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//查询探照灯属性
... ... @@ -689,7 +709,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_LightAttribute(int Uartport)
JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_LIGHTATTRIBUTE, sendbuf, &send_buf_len);
//2、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//查询探照灯温度
... ... @@ -704,13 +724,13 @@ int JZsdk_Uart_SendDeal_CheckStatus_SearchLightTemperture(int Uartport)
JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_TEMPERATURE, sendbuf, &send_buf_len);
//2、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//开启消息订阅
int JZsdk_Uart_SendDeal_MessageSubcription_Control(int Uartport, int value)
{
printf("发送开启消息订阅\n");
printf("发送开启消息订阅%d\n",value);
char sendbuf[256];
int send_buf_len;
... ... @@ -722,7 +742,7 @@ int JZsdk_Uart_SendDeal_MessageSubcription_Control(int Uartport, int value)
sendbuf[10] = value;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
/****************************************************************************************************************************************************
... ... @@ -750,7 +770,7 @@ int JZsdk_Uart_SendDeal_Set_WarningLight_Status(int Uartport,int status, int mod
sendbuf[10] = mode;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
/*************
... ... @@ -773,7 +793,7 @@ int JZsdk_Uart_SendDeal_Set_WarningLight_Color(int Uartport,int color1, int colo
sendbuf[10] = color2;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//查询警灯状态
... ... @@ -788,7 +808,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_WarningLightStatus(int Uartport)
JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_WARNINGLIGHT_STATUS, sendbuf, &send_buf_len);
//2、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
//查询警灯颜色
... ... @@ -803,7 +823,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_WarningLightColor(int Uartport)
JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_WARNINGLIGHT_COLOR, sendbuf, &send_buf_len);
//2、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
/****************************************************************************************************************************************************
... ... @@ -830,7 +850,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Frequency(int Uartport, int Frequency)
sendbuf[10] = Frequency;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
/*************
... ... @@ -852,7 +872,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Mode(int Uartport, int mode)
sendbuf[10] = mode;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
/*************
... ... @@ -875,7 +895,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Lumen(int Uartport,int LeftLumen, int RightL
sendbuf[10] = RightLumen;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
/*************
... ... @@ -898,7 +918,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Temperature(int Uartport, int LeftTemperatur
sendbuf[10] = RightTemperature;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
... ... @@ -922,7 +942,7 @@ int JZsdk_Uart_SendDeal_WarningLight_Status(int Uartport, int status, int mode)
sendbuf[10] = mode;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); }
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len); }
/*************
*
... ... @@ -944,7 +964,7 @@ int JZsdk_Uart_SendDeal_WarningLight_Color(int Uartport, int color1, int color2)
sendbuf[10] = color2;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
/*************
... ... @@ -966,5 +986,5 @@ int JZsdk_Uart_SendDeal_OutputPowerStatus(int Uartport, int FrameSequence, int s
sendbuf[9] = status;
//3、发送帧
JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len);
JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
}
\ No newline at end of file
... ...
... ... @@ -22,6 +22,8 @@ extern "C" {
/* Exported types ------------------------------------------------------------*/
int JZsdk_Uart_SendDeal_Send_Connect(int Uartport ,int Version_flag);
int JZsdk_Uart_SendDeal_Send_ConnectFrame(int Uartport);
int JZsdk_Uart_SendDeal_Send_CustomOrder(int UartPort, char *sendbuf, int len);
int JZsdk_Uart_SendDeal_Reply_SecondaryDeviceName(int Uartport , int device_name, int FrameSequence);
int JZsdk_Uart_SendDeal_QuerySecondaryDeviceName(int Uartport ,int FrameSequence);
... ...
... ... @@ -10,11 +10,13 @@
#include "Uart_Config.h"
#include "JZsdk_Uart_Recv/JZsdk_Uart_RecvDeal.h"
#include "JZsdkLib.h"
#include "JZsdk_Uart_Input.h"
// 串口参数结构体
typedef struct
{
int UartFd; // 串口识别符
int UartDevName; //串口名
char Message[1024]; // 传递的字符串
int MessageLength; // 字符串的长度
int ResLen; //剩余长度
... ... @@ -22,10 +24,27 @@ typedef struct
pthread_cond_t cond; // 条件变量
} s_SerialArgs;
// 再注册串口
typedef struct
{
int UartFd; // 串口识别符
int UartDevName; //串口名
int BitRate; //波特率
} s_SerialInitArg;
//不同串口的描述符
static int Uart_4G_fd;
static int Uart_DEV1_fd;
static int Uart_DEV2_fd;
//用于判断关闭的是哪个串口
static int Uart_4G_Switch = JZ_FLAGCODE_OFF;
static int Uart_DEV1_Switch = JZ_FLAGCODE_OFF;
static int Uart_DEV2_Switch = JZ_FLAGCODE_OFF;
static int Recv_Thread = JZ_FLAGCODE_OFF; //用于判断接收线程是否成功退出
static int Deal_Thread = JZ_FLAGCODE_OFF; //用于判断处理线程是否成功退出
static void *UartDeal_rece(void *arg);
static void *UartDeal_deal(void *arg);
static int UartDeal_Recv_interface(int Uart_fd, unsigned char *getbuf, int getbufLen);
... ... @@ -64,6 +83,7 @@ int JZsdk_Uart_UartDeal_Receive(int Uart_fd, int Uart_Dev_name)
s_SerialArgs *parameter = (s_SerialArgs *)malloc(sizeof(s_SerialArgs));
parameter->UartFd = Uart_fd;
parameter->UartDevName = Uart_Dev_name;
parameter->MessageLength = 0;
memset(parameter->Message, 0, sizeof(parameter->Message));
pthread_mutex_init(&parameter->mutex, NULL);
... ... @@ -102,7 +122,7 @@ static void *UartDeal_rece(void *arg)
{
s_SerialArgs *args = (s_SerialArgs *)arg;
struct timeval timeout; // 超时时间
fd_set fs_read;
static int ResidualLength = 0; // 未处理数据长度
... ... @@ -115,12 +135,34 @@ static void *UartDeal_rece(void *arg)
args->ResLen = 0;
args->MessageLength = 0;
while (1)
int *TheadSwtch = NULL;
if (args->UartDevName == UART_4G)
{
TheadSwtch = &Uart_4G_Switch;
Uart_4G_Switch = JZ_FLAGCODE_ON;
}
else if (args->UartDevName == UART_DEV_1)
{
TheadSwtch = &Uart_DEV1_Switch;
Uart_DEV1_Switch = JZ_FLAGCODE_ON;
}
else if (args->UartDevName == UART_DEV_2)
{
TheadSwtch = &Uart_DEV2_Switch;
Uart_DEV2_Switch = JZ_FLAGCODE_ON;
}
while (*TheadSwtch)
{
FD_ZERO(&fs_read);
FD_SET(Uart_fd,&fs_read);
timeout.tv_sec = 0; // 秒数设置为0
timeout.tv_usec = 100000; // 微秒数设置为100000(100毫秒)
// 检查fs_read套节字是否有数据
select(Uart_fd + 1, &fs_read, NULL, NULL, NULL);
delayMs(1); // 加多了可能导致实时播放难恢复,以及声音间隔 3ms32字节 会向上约1个3ms opus一帧80字节
select(Uart_fd + 1, &fs_read, NULL, NULL, &timeout);
delayMs(3); // 加多了可能导致实时播放难恢复,以及声音间隔 3ms32字节 会向上约1个3ms opus一帧80字节
if (FD_ISSET(Uart_fd, &fs_read))
{
... ... @@ -131,13 +173,27 @@ static void *UartDeal_rece(void *arg)
// 1、读取串口内容 ret 接收长度 getbuf 获取的字符
ResidualLength = args->MessageLength;
args->MessageLength = read(Uart_fd, &(args->Message[args->MessageLength]), (sizeof(args->Message) - ResidualLength)) + ResidualLength;
//JZSDK_LOG_INFO("从串口读取到,长度%d",(args->MessageLength-ResidualLength));
// JZSDK_LOG_INFO("从串口读取到,长度%d",(args->MessageLength-ResidualLength));
// for (int i = 0; i < (args->MessageLength-ResidualLength); i++)
// {
// JZSDK_LOG_OUTPUTHEX("%s",&args->Message[i+ResidualLength]);
// }
// 通知线程
pthread_cond_signal(&args->cond);
pthread_mutex_unlock(&args->mutex); // 解锁
}
}
//注销相关
Recv_Thread = JZ_FLAGCODE_OFF;
// 通知线程
pthread_cond_signal(&args->cond);
pthread_mutex_unlock(&args->mutex); // 解锁
JZSDK_LOG_WARN("串口接收线程被关闭");
}
/***
... ... @@ -152,7 +208,24 @@ static void *UartDeal_deal(void *arg)
static int ResidualLength = 0; // 未处理数据长度
while (1)
int *TheadSwtch = NULL;
if (args->UartDevName == UART_4G)
{
TheadSwtch = &Uart_4G_Switch;
Uart_4G_Switch = JZ_FLAGCODE_ON;
}
else if (args->UartDevName == UART_DEV_1)
{
TheadSwtch = &Uart_DEV1_Switch;
Uart_DEV1_Switch = JZ_FLAGCODE_ON;
}
else if (args->UartDevName == UART_DEV_2)
{
TheadSwtch = &Uart_DEV2_Switch;
Uart_DEV2_Switch = JZ_FLAGCODE_ON;
}
while (*TheadSwtch)
{
// 加锁
... ... @@ -202,11 +275,15 @@ static void *UartDeal_deal(void *arg)
pthread_mutex_unlock(&args->mutex); // 解锁
}
Deal_Thread = JZ_FLAGCODE_OFF;
free(args); //释放掉处理结构体
JZSDK_LOG_WARN("串口处理线程被关闭");
}
/*
数据排出函数s
数据排出函数
*/
static int UartDeal_Recv_Ouput(int Uart_fd, unsigned char *getbuf, int ReadLen)
... ... @@ -454,3 +531,111 @@ int JZsdk_Uart_UartSend(int UartPort, unsigned char *send, int num)
return 0;
}
}
/****************
*
* 串口识别符关闭
*
* ****************/
int JZsdk_Uart_CloseUartFd(int UartPort)
{
if (UartPort == UART_4G)
{
JZSDK_LOG_INFO("关闭4g串口识别符\n");
close(Uart_4G_fd);
return 0;
}
else if (UartPort == UART_DEV_1)
{
JZSDK_LOG_INFO("关闭串口1识别符\n");
close(Uart_DEV1_fd);
return 0;
}
else if (UartPort == UART_DEV_2)
{
JZSDK_LOG_INFO("关闭串口2识别符\n");
close(Uart_DEV1_fd);
return 0;
}
}
static void *CloseUart(void *arg)
{
s_SerialInitArg *args = (s_SerialInitArg *)arg;
int UartPort = args->UartDevName;
int BitRate = args->BitRate;
Recv_Thread = JZ_FLAGCODE_ON;
Deal_Thread = JZ_FLAGCODE_ON;
if (UartPort == UART_4G)
{
JZSDK_LOG_INFO("关闭4g线程\n");
Uart_4G_Switch = JZ_FLAGCODE_OFF;
}
else if (UartPort == UART_DEV_1)
{
JZSDK_LOG_INFO("关闭串口1线程\n");
Uart_DEV1_Switch = JZ_FLAGCODE_OFF;
}
else if (UartPort == UART_DEV_2)
{
JZSDK_LOG_INFO("关闭串口2线程\n");
Uart_DEV2_Switch = JZ_FLAGCODE_OFF;
}
else
{
return 0;
}
while ( (Recv_Thread != JZ_FLAGCODE_OFF) && (Deal_Thread != JZ_FLAGCODE_OFF))
{
delayMs(1);
}
delayMs(100);
//保证全部注销后
JZSDK_LOG_INFO("串口注销完毕");
//创建新的
JZsdk_Uart_SecondInit(UartPort, BitRate);
free(args);
}
/****************
*
* 线程关闭, 并创建一个新的串口
*
* ****************/
int JZsdk_Uart_CloseUartThead(int UartPort, int BitRate)
{
//将串口描述符关闭
JZsdk_Uart_CloseUartFd(UartPort);
s_SerialInitArg *parameter = (s_SerialInitArg *)malloc(sizeof(s_SerialInitArg));
parameter->UartDevName = UartPort;
parameter->BitRate = BitRate;
// 创建关闭串口的线程
pthread_t CloseThread;
pthread_attr_t task_attribute; // 线程属性
pthread_attr_setdetachstate(&task_attribute, PTHREAD_CREATE_DETACHED); // 设置线程分离属性
pthread_attr_init(&task_attribute);
// 创建串口数据处理线程
if (pthread_create(&CloseThread, &task_attribute, CloseUart, parameter) != 0)
{
JZSDK_LOG_ERROR("Failed to create receive thread");
return 1;
}
}
\ No newline at end of file
... ...
... ... @@ -24,6 +24,8 @@ extern "C" {
/* Exported functions --------------------------------------------------------*/
int JZsdk_Uart_UartSend(int UartPort ,unsigned char *send, int num);
int JZsdk_Uart_UartDeal_Receive(int Uart_fd, int Uart_Dev_name);
int JZsdk_Uart_CloseUartFd(int UartPort);
int JZsdk_Uart_CloseUartThead(int UartPort, int BitRate);
#ifdef __cplusplus
... ...
... ... @@ -93,5 +93,7 @@ int UartConnection_UartEnabled(char *UartDev, int BitRate)
tcflush(UartReceive_fd,TCIOFLUSH); //刷清输入、输出队列
tcsetattr(UartReceive_fd,TCSAFLUSH,&options); //串口设置使能
JZSDK_LOG_INFO("使能串口 波特率%d成功",BitRate);
return UartReceive_fd;
}
\ No newline at end of file
... ...
... ... @@ -8,15 +8,27 @@
#include "Gimbal_InAndOut.h"
#include "JZsdkLib.h"
#include "Psdk_UI_io.h"
//数值角度记录
#if DEVICE_VERSION == TF_A1
static int Gimbal_PitchAngle = 0;
static int Gimbal_YawAngle = 0;
#else
static int Gimbal_PitchAngle = 0;
static int Gimbal_YawAngle = 0;
#endif
//角度记录
static int Gimbal_PitchAngle = 0;
static int Gimbal_YawAngle = 0;
//微调角度
static int Gimbal_PitchFineTuning = 0;
static int Gimbal_YawFineTuning = 0;
//飞机自身角度
static int Gimbal_UavSelfPitch = 0;
//实际角度 (数值角度+飞机自身角度+微调角度)
static int Gimbal_RealPitchAngle = 0;
static int Gimbal_LinkageNum;
... ... @@ -48,6 +60,10 @@ int Gimbal_Init()
{
Gimbal_V3S_H1T_init_motor();
}
else if (DEVICE_VERSION == TF_A1)
{
Gimbal_V3S_TFA1_init_motor();
}
else
... ... @@ -132,6 +148,43 @@ T_JZsdkReturnCode Gimbal_Set_PitchAngle(int angle)
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
else if (DEVICE_VERSION == TF_A1)
{
//1、判断输入范围是否正确
if ((angle < -900) || (angle > 0))
{
printf("TFA1的云台俯仰输入值范围出错:%d\n", angle);
return JZ_ERRORCODE_GIMBAL_INVALID_PITCH;
}
//2、记录全局云台值
Gimbal_PitchAngle = angle;
//3、叠加飞机角度和微调角度
Gimbal_RealPitchAngle = angle - Gimbal_UavSelfPitch + Get_V3S_TFA1_motor_precise_adjustment_pitch();
//5、修正angle值
if (Gimbal_RealPitchAngle < -900)
{
angle = -900;
}
else if (Gimbal_RealPitchAngle > 0)
{
angle = 0;
}
else
{
angle = Gimbal_RealPitchAngle;
}
//6、发送到V3S_TFA1控制云台函数
Gimbal_V3S_TFA1_set_angle(angle);
//7、发送角度到飞机
Gimbal_ReplyPitchToUAV(Gimbal_PitchAngle);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
else if (DEVICE_VERSION == JZ_H1T)
{
//1、判断输入范围是否正确
... ... @@ -156,11 +209,9 @@ T_JZsdkReturnCode Gimbal_Set_PitchAngle(int angle)
//设置云台航向角度
int Gimbal_Set_YawAngle(int angle)
{
if (DEVICE_VERSION == JZ_H150S || DEVICE_VERSION == JZ_H150T)
{
printf("H150s没有航向角度\n");
return -1;
}
printf("没有航向角度\n");
return -1;
}
... ... @@ -180,6 +231,11 @@ T_JZsdkReturnCode Gimbal_SetGimbalRange(int value)
return V3S_U3_SetGimbalRange(value);
}
if (DEVICE_VERSION == TF_A1)
{
return V3S_TFA1_SetGimbalRange(value);
}
if (DEVICE_VERSION == JZ_H1T)
{
/* code */
... ... @@ -218,6 +274,18 @@ T_JZsdkReturnCode Gimbal_CheckStatus_GimbalFineTuning(int *FineTunigPitch, int *
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
if (DEVICE_VERSION == TF_A1)
{
//1、获取微调值
Gimbal_V3S_TFA1_CheckStatus_GimbalFineTuning(&Gimbal_PitchFineTuning);
//2、回复微调值
*FineTunigPitch = Gimbal_PitchFineTuning;
*FineTunigYaw = Gimbal_YawFineTuning;
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
if (DEVICE_VERSION == JZ_H1T)
{
//1、刷新微调值
... ... @@ -245,7 +313,6 @@ T_JZsdkReturnCode Gimbal_Obtain_GimbalFineTuning(int pitch)
//无操作
}
if (DEVICE_VERSION == JZ_U3)
{
//无操作
... ... @@ -264,25 +331,39 @@ T_JZsdkReturnCode Gimbal_Obtain_GimbalFineTuning(int pitch)
T_JZsdkReturnCode Gimbal_Set_PitchFineTuning(int DeviceName ,int pitch)
{
printf("设置云台pitch云台微调值\n");
T_JZsdkReturnCode ret;
//原值+修改值
Gimbal_PitchFineTuning = Gimbal_PitchFineTuning + pitch;
if (DEVICE_VERSION == JZ_H150S || DEVICE_VERSION == JZ_H150T)
{
return Gimbal_H3_H150ST_set_PitchFineTuning(pitch);
ret = Gimbal_H3_H150ST_set_PitchFineTuning(pitch);
}
if (DEVICE_VERSION == JZ_U3)
else if (DEVICE_VERSION == JZ_U3)
{
return Gimbal_V3S_U3_set_PitchFineTuning(pitch);
ret = Gimbal_V3S_U3_set_PitchFineTuning(pitch);
}
if (DEVICE_VERSION == JZ_H1T)
else if (DEVICE_VERSION == TF_A1)
{
return Gimbal_V3S_H1T_set_PitchFineTuning(pitch);
ret = Gimbal_V3S_TFA1_set_PitchFineTuning(pitch);
}
else if (DEVICE_VERSION == JZ_H1T)
{
ret = Gimbal_V3S_H1T_set_PitchFineTuning(pitch);
}
else
{
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
//微调后重设角度
Gimbal_Set_PitchAngle(Gimbal_PitchAngle);
return ret;
}
//设置云台联动
... ... @@ -371,7 +452,7 @@ T_JZsdkReturnCode Gimbal_Obtain_GimbalLinkage(int GimbalLinkage)
}
//获取探警灯状态
//获取数值角度
T_JZsdkReturnCode Gimbal_Get_Angle(int *PitchAngle, int *YawAngle)
{
*PitchAngle = Gimbal_PitchAngle;
... ... @@ -409,7 +490,122 @@ T_JZsdkReturnCode Gimbal_Get_PitchFineTuning()
return Gimbal_PitchFineTuning;
}
//获得云台值
T_JZsdkReturnCode Gimbal_Obtain_Gimbal_Pitch(int Pitch)
{
Gimbal_PitchAngle = Pitch;
//目前只有A1修改了真实角度值
if (DEVICE_VERSION == TF_A1)
{
//如果接受到的实际角度 - 飞机角度 + 微调角度 > 900 就不处理,避免角度左脚踩右脚上天
if ( (Pitch - Gimbal_UavSelfPitch + Get_V3S_TFA1_motor_precise_adjustment_pitch()) >900)
{
//Gimbal_PitchAngle不变
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
else
{
Gimbal_PitchAngle = (Pitch + Gimbal_UavSelfPitch - Get_V3S_TFA1_motor_precise_adjustment_pitch());
}
}
{
Gimbal_PitchAngle = Pitch;
}
}
/**************************************************************
*
*
* 飞机特殊控制云台方法
*
*
***************************************************************/
//1、飞机自身角度控制云台
T_JZsdkReturnCode Gimbal_PitchSelfangleMode(int Pitch)
{
if (Gimbal_UavSelfPitch == Pitch)
{
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
Gimbal_UavSelfPitch = Pitch;
//设置云台角度
Gimbal_Set_PitchAngle(Gimbal_PitchAngle);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
//2、滑动条控制云台
T_JZsdkReturnCode Gimbal_PitchScaleMode(int value)
{
int angle;
if (DEVICE_VERSION == TF_A1)
{
//0~100 转化为 -900~0
angle = value*9 -900;
}
else
{
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
Gimbal_Set_PitchAngle(angle);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
//3、拨轮控制云台
T_JZsdkReturnCode Gimbal_PitchRotationMode(int value)
{
int angle;
if (DEVICE_VERSION == TF_A1)
{
angle = Gimbal_PitchAngle + value;
if (angle > 0)
{
angle = 0;
}
else if (angle < -900)
{
angle = -900;
}
if (angle == Gimbal_PitchAngle)
{
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
}
else
{
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
Gimbal_Set_PitchAngle(angle);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
//回复角度到飞机
T_JZsdkReturnCode Gimbal_ReplyPitchToUAV(int angle)
{
int value;
if (DEVICE_VERSION == TF_A1)
{
//-900~0 转回 0~100
value = (angle+ 900)/9;
}
else
{
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
JZsdk_Psdk_Ui_io_Gimbal_PitchPrint(value);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
\ No newline at end of file
... ...
... ... @@ -38,6 +38,11 @@ T_JZsdkReturnCode Gimbal_CheckStatus_GimbalLinkage(int *value);
T_JZsdkReturnCode Gimbal_Obtain_GimbalLinkage(int GimbalLinkage);
T_JZsdkReturnCode Gimbal_CheckStatus_Angle(int *PitchAngle, int *YawAngle);
T_JZsdkReturnCode Gimbal_PitchSelfangleMode(int Pitch);
T_JZsdkReturnCode Gimbal_PitchScaleMode(int value);
T_JZsdkReturnCode Gimbal_PitchRotationMode(int value);
T_JZsdkReturnCode Gimbal_ReplyPitchToUAV(int angle);
#ifdef __cplusplus
}
#endif
... ...
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <sys/time.h>
static void *UartDeal_rece(void *arg);
static void *UartDeal_send(void *arg);
static int Gimbal_Uart_fd = 0;
/******************************************************************
创建一个接收Gimbal的接收线程
******************************************************************/
int Gimbal_UartDeal_Receive(int Uart_fd)
{
int ret = 0;
pthread_t Uart_rece_task;
Gimbal_Uart_fd = Uart_fd;
pthread_attr_t task_attribute; //线程属性
pthread_attr_init(&task_attribute); //初始化线程属性
pthread_attr_setdetachstate(&task_attribute, PTHREAD_CREATE_DETACHED); //设置线程属性
ret = pthread_create(&Uart_rece_task,&task_attribute,UartDeal_rece,NULL); //串口接收线程
if(ret != 0)
{
printf("创建展架串口接收线程失败!\n");
}
else{
printf("创建展架串口接收线程成功!\n");
}
}
static void *UartDeal_rece(void *arg)
{
char getbuf[1024];
int ret = 0;
fd_set fs_read;
struct timeval tv_timeout;
//FD_ZERO 将指定的文件描述符集清空,在对文件描述符集合进行设置前,必须对其进行初始化
//如果不清空,由于在系统分配内存空间后,通常并不作清空处理,所以结果是不可知的。
FD_ZERO(&fs_read);
//FD_SET 用于在文件描述符集合中增加一个新的文件描述符。
FD_SET(Gimbal_Uart_fd, &fs_read);
//115200 / char 8 位 = 14400 个char数据
tv_timeout.tv_sec = 6000;//(10*20/115200+2);
tv_timeout.tv_usec = 0;
//2、正常接收
while(1)
{
//检查fs_read套节字是否有数据
select(Gimbal_Uart_fd+1, &fs_read, NULL, NULL, &tv_timeout);
usleep(10000);
//FD_ISSET 用于测试指定的文件描述符是否在该集合中。
//Gimbal_Uart_fd 是否在fsread中
if (FD_ISSET(Gimbal_Uart_fd, &fs_read))
{
//1、读取串口内容 ret 接收长度 getbuf 获取的字符
memset(getbuf,0,sizeof(getbuf)); //清空接收数组
ret = read(Gimbal_Uart_fd,getbuf,sizeof(getbuf));
//printf("Gimbalret: %d Gimbalgetbuf: %s\n", ret, getbuf);
// for (int i = 0; i < ret; i++)
// {
// printf("%x ",getbuf[i]);
// }
// printf("\n");
//Comm_4G_RecvCharmDeal(getbuf, ret);
}
}
}
/****************
*
*
* 发送函数
*
* ****************/
int Gimbal_UartSend(unsigned char *send, int num)
{
write(Gimbal_Uart_fd,send, num);
return 0;
}
... ...
/**
********************************************************************
* @file Gimbal_UartDeal.h
* Gimbal_UartDeal的头文件
*
*********************************************************************
*/
/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
#ifndef GIMBAL_UART_DEAL_H
#define GIMBAL_UART_DEAL_H
/* Includes ------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
/* Exported constants --------------------------------------------------------*/
/* 常亮定义*/
/* Exported types ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
int Gimbal_UartDeal_Receive(int Uart_fd);
int Gimbal_UartSend(unsigned char *send, int num);
#ifdef __cplusplus
}
#endif
#endif
... ...
... ... @@ -21,6 +21,7 @@ extern "C" {
#include "Gimbal_V3S_H10T/Gimbal_V3S_H10T.h"
#include "Gimbal_V3S_U3/Gimbal_V3S_U3.h"
#include "Gimbal_V3S_H1T/Gimbal_V3S_H1T.h"
#include "Gimbal_V3S_TFA1/Gimbal_V3S_TFA1.h"
/* Exported types ------------------------------------------------------------*/
... ...
/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include "../Ircut/H3_ircut/wiringPi/wiringPi.h"
#include "./Gimbal_V3S_TFA1.h"
#include "JZsdk_Uart_Input.h"
#include "ircut.h"
#include "BaseConfig.h"
/* Private constants ---------------------------------------------------------*/
#define MOTOR_FILE_PATH "/root/motor"
#define V3S_TFA1_MOTOR_ADJUSTMENT 5 //云台微调值
/* Private types -------------------------------------------------------------*/
/* Private functions declaration ---------------------------------------------*/
static int V3S_TFA1_motor_precise_adjustment_pitch =0;//默认微调值为0
static void *Gimbal_V3S_TFA1_Motor_control(void *arg);
static int V3S_TFA1_Read_MotorAdjustmentPitch(void);
static void V3S_TFA1_Write_MotorAdjustmentPitch(int MotorAdjustmentPitch);
void Gimbal_V3S_TFA1_init_motor(void)
{
V3S_TFA1_motor_precise_adjustment_pitch = V3S_TFA1_Read_MotorAdjustmentPitch();//获取微调角度-读文件获取
Gimbal_V3S_TFA1_set_angle(0);
}
static int Gimbal_TFA1_sendAngle(int angle)
{
if(angle >= 0 )
{
angle = 0;
}
else if(angle <= -900)
{
angle = -900;
}
else if( (angle > -900) && (angle < 0) )
{
//angle不变
}
//发送角度给串口2
JZsdk_Uart_Send_SetGimbalPitch(UART_DEV_2, angle);
}
int Gimbal_V3S_TFA1_set_angle(int angle)
{
Gimbal_TFA1_sendAngle(angle);
// pthread_t MOTOR_task;
// pthread_attr_t task_attribute; //线程属性
// pthread_attr_init(&task_attribute); //初始化线程属性
// pthread_attr_setdetachstate(&task_attribute, PTHREAD_CREATE_DETACHED); //设置线程属性
// int *arg = (int*) malloc(sizeof(int)); // 分配动态内存
// *arg = angle; // 将参数值保存到动态内存中
// int angle_ret = pthread_create(&MOTOR_task,&task_attribute,Gimbal_V3S_TFA1_Motor_control,arg); //TTS mobie
// if(angle_ret != 0)
// {
// printf("创建motor线程失败!\n");
// return -1;
// }
// else
// {
// printf("创建motor线程成功\n");
// }
// return 0;
}
//控制电机线程
static void *Gimbal_V3S_TFA1_Motor_control(void *arg)
{
//传入的角度 -900~0
int angle = *(int*)arg;
//微调角度值 移动到上一步
//angle = angle + V3S_TFA1_motor_precise_adjustment_pitch;
printf("V3S_TFA1_RealAngle:%d\n",angle);
if(angle >= 0 )
{
angle = 0;
}
else if(angle <= -900)
{
angle = -900;
}
else if( (angle > -900) && (angle < 0) )
{
//angle不变
}
//发送角度给串口2
JZsdk_Uart_Send_SetGimbalPitch(UART_DEV_2, angle);
free(arg); // 在线程函数中释放动态内存
}
//云台微调
T_JZsdkReturnCode Gimbal_V3S_TFA1_set_PitchFineTuning(int Pitch)
{
//微调的角度值 提高Pitch
V3S_TFA1_motor_precise_adjustment_pitch += Pitch;
//写入本地文件
V3S_TFA1_Write_MotorAdjustmentPitch(V3S_TFA1_motor_precise_adjustment_pitch);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
//从文件中读出电机微调值
static int V3S_TFA1_Read_MotorAdjustmentPitch(void)
{
FILE *motor_file;
int MotorAdjustmentPitch = 0;
motor_file = fopen(MOTOR_FILE_PATH, "rb+");
if (motor_file == NULL)
{
motor_file = fopen(MOTOR_FILE_PATH, "wb+");
if (motor_file == NULL)
{
return 0;
}
}
else
{
int ret = fseek(motor_file, 0, SEEK_SET);
if (ret != 0) {
printf("Seek log count file error, ret: %d.\r\n", ret);
}
ret = fread((unsigned int *) &MotorAdjustmentPitch, 1, sizeof(unsigned int), motor_file);
if (ret != sizeof(unsigned int)) {
printf("Read motor weitiao error.\r\n");
}
else{
printf("Read motor weitiao=%d\n",MotorAdjustmentPitch);
}
}
fclose(motor_file);
return MotorAdjustmentPitch;
}
//写入电机微调值刀文件中
static void V3S_TFA1_Write_MotorAdjustmentPitch(int MotorAdjustmentPitch)
{
//写入文件
FILE *motor_file;
motor_file = fopen(MOTOR_FILE_PATH, "wb+");
int ret = fwrite((unsigned int *) &MotorAdjustmentPitch, 1, sizeof(unsigned int),motor_file);
if (ret != sizeof(unsigned int)) {
printf("Write motor weitiao error.\r\n");
}
else{
printf("Write motor weitiao=%d\n",MotorAdjustmentPitch);
}
fclose(motor_file);
}
int Gimbal_V3S_TFA1_CheckStatus_GimbalFineTuning(int *AdjustmentPitch)
{
*AdjustmentPitch = V3S_TFA1_motor_precise_adjustment_pitch;
}
//TFA1范围
T_JZsdkReturnCode V3S_TFA1_SetGimbalRange(int Range)
{
if (Range == 0xFF)
{
printf("设置TFA1云台最大值\n");
JZsdk_Uart_Send_SetGimbalRange(UART_DEV_2, 0, Range);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
else if (Range == 0x00)
{
printf("设置TFA1云台最小值\n");
JZsdk_Uart_Send_SetGimbalRange(UART_DEV_2, 0, Range);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
int Get_V3S_TFA1_motor_precise_adjustment_pitch()
{
return V3S_TFA1_motor_precise_adjustment_pitch;
}
\ No newline at end of file
... ...
/**
********************************************************************
* @file Gimbal_V3S_TFA1.h
* v3s板子的A1云台头文件
*
*********************************************************************
*/
/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
#ifndef GIMBAL_V3S_TFA1_H
#define GIMBAL_V3S_TFA1_H
/* Includes ------------------------------------------------------------------*/
#include "JZsdk_Base/JZsdk_Code/JZsdk_Code.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Exported constants --------------------------------------------------------*/
/* 常亮定义*/
/* Exported types ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
void Gimbal_V3S_TFA1_init_motor(void);
int Gimbal_V3S_TFA1_set_angle(int angle);
T_JZsdkReturnCode V3S_TFA1_SetGimbalRange(int Range);
T_JZsdkReturnCode Gimbal_V3S_TFA1_set_PitchFineTuning(int Pitch);
int Gimbal_V3S_TFA1_CheckStatus_GimbalFineTuning(int *AdjustmentPitch);
int Get_V3S_TFA1_motor_precise_adjustment_pitch();
#ifdef __cplusplus
}
#endif
#endif
... ...
... ... @@ -73,6 +73,9 @@ static int PowerContorl;
#elif DEVICE_VERSION == JZ_U3
#define AMPLIFIER_PIN PB
#define AMPLIFIER_PIN_NUM 4
#elif DEVICE_VERSION == TF_A1
#define AMPLIFIER_PIN PG
#define AMPLIFIER_PIN_NUM 5
#else
#define AMPLIFIER_PIN PB
#define AMPLIFIER_PIN_NUM 4
... ...
... ... @@ -9,7 +9,7 @@ static int OutPutPower = JZ_FLAGCODE_OFF;
void Ircut_Init()//引脚初始化
{
if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T || DEVICE_VERSION == JZ_H10T || DEVICE_VERSION == JZ_U3)
if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T || DEVICE_VERSION == JZ_H10T || DEVICE_VERSION == JZ_U3 || DEVICE_VERSION == TF_A1)
{
V3s_Ircut_Init();
}
... ... @@ -38,7 +38,7 @@ int Ircut_uInit()
//功放开关
void set_amplifier(int amplifier_mode)
{
if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T || DEVICE_VERSION == JZ_H10T || DEVICE_VERSION == JZ_U3)
if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T || DEVICE_VERSION == JZ_H10T || DEVICE_VERSION == JZ_U3 || DEVICE_VERSION == TF_A1)
{
V3s_set_amplifier(amplifier_mode);
}
... ...
... ... @@ -5,6 +5,9 @@
#include "Lighting_InAndOut.h"
#include "./SearchLight/SearchLight_V3S/SearchLight_V3S.h"
#include "./WarningLight/WarningLight_V3S/WarningLight_V3S.h"
#include "SearchLight/SearchLightTemControl/SearchLightTemControl.h"
#include "UI_control.h"
#include "BaseConfig.h"
static int SearchLight_Frequency; //探照灯频率
static int SearchLight_Mode; //探照灯模式
... ... @@ -19,6 +22,14 @@ static int WarningLight_Mode; //警灯模式
static int WarningLight_Color1; //警灯颜色1
static int WarningLight_Color2; //警灯颜色2
#define MAX(a,b) ( (a>b) ?a:b )
T_JZsdkReturnCode Lighting_Init()
{
//温控初始化
JZsdk_SearchLightTemControl_Init();
}
/********************************************************************************************************************************
*
* 探照灯 灯光属性
... ... @@ -63,7 +74,10 @@ T_JZsdkReturnCode Lighting_SearchLightControl(int mode)
{
return SearchLight_V3S_H1T_SearchLightControl(mode);
}
else if (DEVICE_VERSION == TF_A1)
{
return SearchLight_V3S_TFA1_SearchLightControl(mode);
}
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
... ... @@ -113,7 +127,10 @@ T_JZsdkReturnCode Lighting_Set_SearchLightLumen(int LeftLumen, int RightLumen)
{
return SearchLight_V3S_H1T_Set_SearchLightLumen(LeftLumen, RightLumen);
}
else if (DEVICE_VERSION == TF_A1)
{
return SearchLight_V3S_TFA1_Set_SearchLightLumen(LeftLumen, RightLumen);
}
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
... ... @@ -164,7 +181,10 @@ T_JZsdkReturnCode Lighting_Set_SearchLightFrequency(int value)
{
return SearchLight_V3S_H1T_Set_SearchLightFrequency(value);
}
else if (DEVICE_VERSION == TF_A1)
{
return SearchLight_V3S_TFA1_Set_SearchLightFrequency(value);
}
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
... ... @@ -199,13 +219,91 @@ T_JZsdkReturnCode Lighting_CheckStatus_SearchLightFrequency()
* 探照灯 温度相关
*
********************************************************************************************************************************/
static int Light_Luminance_StepBack_Calculation(int temper, int liumin)
{
//以下为假设值 未经实测
//以70度 为过热标准 91 为顶峰
//70度~ 73 度时 每次降低2亮度
//74~78时 每次降低3
//79~84时 每次降低5
//85~ 91时 每次降低8
//大于91时 每次降低12
//不过超过80后 灯那边会被强制关掉
int StepBackValue = 0;
if ( (temper >= 70 ) && (temper <= 73) )
{
StepBackValue = 1;
}
else if ( (temper >= 74 ) && (temper <= 78) )
{
StepBackValue = 2;
}
else if ( (temper >= 79 ) && (temper <= 84) )
{
StepBackValue = 4;
}
else if ( (temper >= 85 ) && (temper <= 91))
{
StepBackValue = 6;
}
else if ( (temper > 91 ))
{
StepBackValue = 8;
}
else
{
StepBackValue = 0;
}
return (liumin - StepBackValue);
}
//收到并修改探照灯的温度(中继修改)
T_JZsdkReturnCode Lighting_Obtain_SearchLightTemperature(int LeftTemperature, int RightTemperature)
{
printf("%x探照灯温度改变左灯%d 右灯%d\n",DEVICE_VERSION, LeftTemperature ,RightTemperature);
printf("设备0x1010%x探照灯温度改变左灯%d 右灯%d\n",DEVICE_VERSION, LeftTemperature ,RightTemperature);
SearchLight_LeftTemperature = LeftTemperature;
SearchLight_RightTemperature = RightTemperature;
int Max_tmeperature, Max_Liuminance;
Max_tmeperature = MAX(LeftTemperature, RightTemperature);
Max_Liuminance = MAX(SearchLight_LeftLumen, SearchLight_RightLumen);
int TempLumen;//临时亮度
//如果是JZ u3
if (DEVICE_VERSION == JZ_U3)
{
if (Max_tmeperature >= 70)
{
//温控开始
Max_Liuminance = Light_Luminance_StepBack_Calculation(Max_tmeperature, Max_Liuminance);
//重设亮度
Lighting_Set_SearchLightLumen(Max_Liuminance, Max_Liuminance);
}
}
if (DEVICE_VERSION == TF_A1)
{
//温控开始
TempLumen = JZsdk_SearchLightTemControl_Input(Max_tmeperature, Max_Liuminance);
if (TempLumen != Max_Liuminance)
{
//重设亮度
//Lighting_Set_SearchLightLumen(TempLumen, TempLumen);
UIcontrol_Set_SearchLightLumen(NO_SPECIFIED, 0, TempLumen, TempLumen);
}
}
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
... ... @@ -244,13 +342,17 @@ T_JZsdkReturnCode Lighting_Set_WarningLight_Status(int status, int mode)
{
printf("设置0x%x:警灯状态\n",DEVICE_VERSION);
if (DEVICE_VERSION == JZ_H1T)
{
return WarningLight_V3S_H1T_Set_WarningLight_Status(status, mode);
}
#if DEVICE_VERSION == JZ_H1T
return WarningLight_V3S_H1T_Set_WarningLight_Status(status, mode);
#elif DEVICE_VERSION == TF_A1
return WarningLight_V3S_TFA1_Set_WarningLight_Status(status, mode);
#else
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
#endif
}
//收到并修改警灯状态
... ... @@ -302,12 +404,16 @@ T_JZsdkReturnCode Lighting_Set_WarningLight_Color(int color1, int color2)
{
printf("设置0x%x:警灯颜色\n",DEVICE_VERSION);
if (DEVICE_VERSION == JZ_H1T)
{
return WarningLight_V3S_H1T_Set_WarningLight_Color(color1, color2);
}
#if DEVICE_VERSION == JZ_H1T
return WarningLight_V3S_H1T_Set_WarningLight_Color(color1, color2);
#elif DEVICE_VERSION == TF_A1
return WarningLight_V3S_TFA1_Set_WarningLight_Color(color1, color2);
#else
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
#endif
return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
}
... ...
... ... @@ -23,6 +23,8 @@ extern "C" {
/* Exported types ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
T_JZsdkReturnCode Lighting_Init();
T_JZsdkReturnCode Lighting_CheckStatus_SearchLightLightAttribute(int *ValueFrequency, int *ValueMode, int *ValueLeftLumen, int *ValueRightLumen);
T_JZsdkReturnCode Lighting_SearchLightControl(int mode);
... ...
/****************************************************/
#include <stdio.h>
#include "version_choose.h"
typedef enum {
DEFAULT_STATUS = 0x0000, //默认状态
LUMEN_UP = 0x0001, //温度提高
LUMEN_DOWN =0x0002, //温度降低
} JZ_TemControl_Code;
// typedef enum {
// JZ_T30 = 0x0000,
// JZ_T60 = 0x0001,
// JZ_T90 = 0x0002,
// JZ_T60S = 0x0003,
// JZ_U3 = 0x0004,
// JZ_A1 = 0x0005,
// } JZ_DeviceModel_Code;
static int InitialLumen = 0; //最初亮度
/***
*
* 控件修改时,给温控模块一个亮度初值
*
* ****/
int JZsdk_SearchLightSetInitialLumen(int value)
{
if (InitialLumen >= 100)
{
InitialLumen = 100;
}
else if (InitialLumen <= 0)
{
InitialLumen = 0;
}
InitialLumen = value;
}
/***
*
* 获取限制温度
*
* ****/
static int JZsdk_SearchLightGetLimitTemp(int DeviceMode)
{
switch (DeviceMode)
{
// case JZ_T30:
// return 65;
// break;
// case JZ_T60:
// return 80;
// break;
// case JZ_T90:
// return 70;
// break;
// case JZ_T60S:
// return 65;
// break;
case JZ_U3:
return 70;
break;
case TF_A1:
return 70;
break;
default:
break;
}
return -1;
}
/***
*
* 根据超出范围/ 小于范围 获取温控时间
* 如果要优化,可以改成余弦曲线
* ****/
static int JZsdk_SearchLightGetLumenControlTime(float value)
{
//如果范围在0.4度以内
if (value <= 0.4)
{
return 5000; //延时5000ms
}
//0.4~1.0
else if ( (value > 0.4) && (value <= 1.0))
{
return 4600;
}
//1.0~1.8
else if ( (value > 1.0) && (value <= 1.8))
{
return 4100;
}
//1.8~2.8
else if ( (value > 1.8) && (value <= 2.8))
{
return 3500;
}
//2.8~4.0
else if ( (value > 2.8) && (value <= 4.0))
{
return 2800;
}
//4.0~5.4
else if ( (value > 4.0) && (value <= 5.4))
{
return 2000;
}
//5.4~7.0
else if ( (value > 5.4) && (value <= 7.0))
{
return 1100;
}
//7.0~9.8
else if ( (value > 7.0) && (value <= 9.8))
{
return 200;
}
else
{
return 100;
}
}
int JZsdk_SearchLightTemControl(float InputTemp, int InputLumen, int *OutputLumen, int *OutputDelay)
{
//初始化
*OutputLumen = 0;
*OutputDelay = 0;
int ControlFlag = DEFAULT_STATUS; //无变化为0, 升温为1,降温为2
float TempRange = 0; //温度范围
int LumenVariation = 0; //亮度变化值
//1、获取限制温度
int LimitTemp = JZsdk_SearchLightGetLimitTemp(DEVICE_VERSION);
if (LimitTemp == -1)
{
//没有对应的限制温度,返回失败及亮度0
*OutputLumen = 0;
*OutputDelay = 0;
return -1;
}
//2、判断是否要升高/降低温度 以及 获取差距范围
//如果输入的温度高于限制温度,说明要降亮度
if (InputTemp >= LimitTemp)
{
TempRange = InputTemp - LimitTemp;
//控制标志位: 降低亮度
ControlFlag = LUMEN_DOWN;
}
//如果输出的温度 小于限制温度,则要判断输入亮度与亮度初值的关系
else if (InputTemp < LimitTemp)
{
//如果输入亮度小于初值亮度
if (InputLumen < InitialLumen)
{
TempRange = LimitTemp - InputTemp;
//控制标志位:提高亮度
ControlFlag = LUMEN_UP;
}
//否则,不用进行处理
else
{
*OutputLumen = InputLumen;
*OutputDelay = 0;
ControlFlag = DEFAULT_STATUS;
return 0;
}
}
//3、根据输入的温度范围 获取降低/升高 的时间间隔
*OutputDelay = JZsdk_SearchLightGetLumenControlTime(TempRange);
//4、根据输入的温度范围 获取降低/升高 的亮度的步长 并 加上原亮度 得到新亮度
//暂时固定一度
if (ControlFlag == LUMEN_DOWN)
{
*OutputLumen = InputLumen - 1;
//由于温度需要下降,说明初值亮度还是太高了
//将初值亮度降低2点
InitialLumen = InitialLumen-2;
}
else if (ControlFlag == LUMEN_UP)
{
*OutputLumen = InputLumen + 1;
}
else
{
//没有对应的标志位,温控失败
*OutputLumen = 0;
*OutputDelay = 0;
return -1;
}
return 0;
}
... ...
/**
********************************************************************
* @file JZ_SearchLightTemp_calculation.h
* JZ_SearchLightTemp_calculation.c的头文件
*
*
*********************************************************************
*/
/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
#ifndef JZ_SEARCHLIGHT_TEMP_CALCULATION_H
#define JZ_SEARCHLIGHT_TEMP_CALCULATION_H
/* Includes ------------------------------------------------------------------*/
int JZsdk_SearchLightSetInitialLumen(int value);
int JZsdk_SearchLightTemControl(float InputTemp, int InputLumen, int *OutputLumen, int *OutputDelay);
#endif
... ...
#include <stdio.h>
#include "Psdk_UI_io.h"
#include "JZsdk_Base/JZsdk_Code/JZsdk_InsCode.h"
#include "BaseConfig.h"
#include "Megaphone_InputAndOutput.h"
#include "JZsdkLib.h"
#include "UI_control.h"
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include "./JZ_SearchLightTemp_calculation.h"
#include "./SearchLightTemControl.h"
static int g_InputTemp = 0;
static int g_InputLumen = 0;
static int g_OutputLumen = 0;
//1、输入函数
T_JZsdkReturnCode JZsdk_SearchLightTemControl_Input(int InputTemp, int InputLumen)
{
//输入参数
g_InputTemp = InputTemp;
g_InputLumen = InputLumen;
delayMs(1);
return g_OutputLumen;
}
//2、刷新亮度函数
T_JZsdkReturnCode JZsdk_SearchLightTemControl_FlushLumen(int InputLumen)
{
g_InputLumen = InputLumen;
JZsdk_SearchLightSetInitialLumen(g_InputLumen);
}
//控温线程
static void *TempControl_Task(void *arg)
{
int DelayTime;
while (1)
{
JZsdk_SearchLightTemControl( (float)g_InputTemp, g_InputLumen, &g_OutputLumen, &DelayTime);
if (DelayTime > 0)
{
printf("触发温控延迟\n");
delayMs(DelayTime);
}
else
{
delayMs(1);
}
DelayTime = 0;
}
}
//控件
//控件控制初始化
T_JZsdkReturnCode JZsdk_SearchLightTemControl_Init()
{
pthread_t WriteDataTask;
pthread_attr_t task_attribute; //线程属性
pthread_attr_init(&task_attribute); //初始化线程属性
pthread_attr_setdetachstate(&task_attribute, PTHREAD_CREATE_DETACHED); //设置线程分离属性
int opus_Protection = pthread_create(&WriteDataTask,&task_attribute,TempControl_Task,NULL); //线程
if(opus_Protection != 0)
{
JZSDK_LOG_ERROR("创建控件写入线程失败!");
return -1;
}
}
\ No newline at end of file
... ...
/**
********************************************************************
* @file SearchLightTemControl.h
* SearchLightTemControl.c的头文件
*
*
*********************************************************************
*/
/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
#ifndef SEARCHLIGHT_TEM_CONTROL_H
#define SEARCHLIGHT_TEM_CONTROL_H
/* Includes ------------------------------------------------------------------*/
#include "JZsdk_Base/JZsdk_Code/JZsdk_Code.h"
T_JZsdkReturnCode JZsdk_SearchLightTemControl_Input(int InputTemp, int InputLumen);
T_JZsdkReturnCode JZsdk_SearchLightTemControl_FlushLumen(int InputLumen);
T_JZsdkReturnCode JZsdk_SearchLightTemControl_Init();
#endif
... ...
... ... @@ -13,6 +13,7 @@
/* Includes ------------------------------------------------------------------*/
#include "./SearchLight_V3S_U3/SearchLight_V3S_U3.h"
#include "./SearchLight_V3S_H1T/SearchLight_V3S_H1T.h"
#include "./SearchLight_V3S_TFA1/SearchLight_V3S_TFA1.h"
#ifdef __cplusplus
... ...
#include <stdio.h>
#include "./SearchLight_V3S_TFA1.h"
#include "JZsdk_Uart_Input.h"
#include "BaseConfig.h"
T_JZsdkReturnCode SearchLight_V3S_TFA1_Set_SearchLightFrequency(int value)
{
//向u3的单片机发送调节频率帧
JZsdk_Uart_Send_SearchLight_SetFrequency(UART_DEV_2, value);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
T_JZsdkReturnCode SearchLight_V3S_TFA1_SearchLightControl(int mode)
{
//向u3的单片机发送探照灯控制帧
JZsdk_Uart_Send_SearchLight_Control(UART_DEV_2, mode);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
T_JZsdkReturnCode SearchLight_V3S_TFA1_Set_SearchLightLumen(int LeftLumen, int RightLumen)
{
//向u3的单片机发送探照灯控制帧
JZsdk_Uart_Send_SearchLight_SetLumen(UART_DEV_2, LeftLumen, RightLumen);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
\ No newline at end of file
... ...
/**
********************************************************************
* @file SearchLight_V3S_TFA1.h
* SearchLight_V3S_TFA1的头文件
*
*********************************************************************
*/
/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
#ifndef SEARCHLIGHT_V3S_TFA1_H
#define SEARCHLIGHT_V3S_TFA1_H
/* Includes ------------------------------------------------------------------*/
#include "JZsdk_Base/JZsdk_Code/JZsdk_Code.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Exported constants --------------------------------------------------------*/
/* 常亮定义*/
/* Exported types ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
T_JZsdkReturnCode SearchLight_V3S_TFA1_Set_SearchLightFrequency(int value);
T_JZsdkReturnCode SearchLight_V3S_TFA1_SearchLightControl(int mode);
T_JZsdkReturnCode SearchLight_V3S_TFA1_Set_SearchLightLumen(int LeftLumen, int RightLumen);
#ifdef __cplusplus
}
#endif
#endif
... ...
... ... @@ -12,6 +12,7 @@
/* Includes ------------------------------------------------------------------*/
#include "./WarningLight_V3S_H1T/WarningLight_V3S_H1T.h"
#include "./WarningLight_V3S_TFA1/WarningLight_V3S_TFA1.h"
#ifdef __cplusplus
... ...
#include <stdio.h>
#include "./WarningLight_V3S_TFA1.h"
#include "JZsdk_Uart_Input.h"
#include "BaseConfig.h"
//设置警灯状态
T_JZsdkReturnCode WarningLight_V3S_TFA1_Set_WarningLight_Status(int status, int mode)
{
//向单片机发送警灯状态
JZsdk_Uart_Send_Set_WarningLight_Status(UART_DEV_2, status, mode);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
//设置警灯颜色
T_JZsdkReturnCode WarningLight_V3S_TFA1_Set_WarningLight_Color(int color1, int color2)
{
JZsdk_Uart_Send_Set_WarningLight_Color(UART_DEV_2, color1, color2);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
/*********
*
* 查询警灯状态
*
**********/
T_JZsdkReturnCode WarningLight_V3S_TFA1_CheckStatus_WarningLightStatus()
{
JZsdk_Uart_Send_CheckStatus_WarningLightStatus(UART_DEV_2);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
/*********
*
* 查询警灯颜色
*
**********/
T_JZsdkReturnCode WarningLight_V3S_TFA1_CheckStatus_WarningLightColor()
{
JZsdk_Uart_Send_CheckStatus_WarningLightColor(UART_DEV_2);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
\ No newline at end of file
... ...
/**
********************************************************************
* @file WarningLight_V3S_TFA1.h
* WarningLight_V3S_TFA1的头文件
*
*********************************************************************
*/
/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
#ifndef WARNINGLIGHT_V3S_TFA1_H
#define WARNINGLIGHT_V3S_TFA1_H
/* Includes ------------------------------------------------------------------*/
#include "JZsdk_Base/JZsdk_Code/JZsdk_Code.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Exported constants --------------------------------------------------------*/
/* 常亮定义*/
/* Exported types ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
T_JZsdkReturnCode WarningLight_V3S_TFA1_Set_WarningLight_Status(int status, int mode);
T_JZsdkReturnCode WarningLight_V3S_TFA1_Set_WarningLight_Color(int color1, int color2);
T_JZsdkReturnCode WarningLight_V3S_TFA1_CheckStatus_WarningLightStatus();
T_JZsdkReturnCode WarningLight_V3S_TFA1_CheckStatus_WarningLightColor();
#ifdef __cplusplus
}
#endif
#endif
... ...
... ... @@ -43,8 +43,19 @@ int Megaphone_Init()
#if FIRMWARE_ORIGIN == DOMESTIC_VERSION //国内版才有方言
//播放喊话器启动中
Megaphone_TTS_Play(strlen("喊话器直连模式启动中"),"喊话器直连模式启动中", 0);
if (APP_VERSION == APP_PSDK)
{
//播放喊话器启动中
//Megaphone_TTS_Play(strlen("喊话器启动中"),"喊话器启动中", 0);
}
else if (APP_VERSION == APP_UART)
{
//播放喊话器启动中
Megaphone_TTS_Play(strlen("喊话器直连模式启动中"),"喊话器直连模式启动中", 0);
}
#elif FIRMWARE_ORIGIN == OVERSEAS_VERSION //海外版才有其他国家的语音
//设置语音为英文
... ... @@ -227,22 +238,16 @@ T_JZsdkReturnCode Megaphone_audio_PlayPause()
T_JZsdkReturnCode Megaphone_audio_PlayStop()
{
//1、关闭功放
printf("stop1\n");
Megaphone_set_amplifier(JZ_FLAGCODE_OFF);
printf("stop2\n");
//2、向音频库发送暂停音乐帧
Music_SendFrame_PauseMusic();
printf("stop3\n");
//3、关闭TTS播放
TTS_ttsPlayStop();
printf("stop4\n");
//4、关闭opus播放
Opus_OpusPlayStop();
printf("stop5\n");
//5、返回成功
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
... ... @@ -266,6 +271,7 @@ T_JZsdkReturnCode Megaphone_audio_LastSong()
//2、获取上一首歌的名字与长度
char MusicName[256];
int MusicNameLen;
memset(MusicName,0,sizeof(MusicName));
int ret = Music_Get_LastMusic(MusicName,&MusicNameLen);
//3、播放上一首歌
... ... @@ -290,6 +296,7 @@ T_JZsdkReturnCode Megaphone_audio_NextSong()
//2、获取下一首歌的名字与长度
char MusicName[256];
int MusicNameLen;
memset(MusicName,0,sizeof(MusicName));
int ret = Music_Get_NextMusic(MusicName,&MusicNameLen);
//3、播放下一首歌
... ... @@ -362,7 +369,7 @@ static int Get_audio_status()
}
}
static int Get_TTS_status()
int Get_TTS_status()
{
//获取TTS的播放标志位
int ret = TTS_Get_TTS_play_flag();
... ... @@ -648,6 +655,8 @@ T_JZsdkReturnCode Megaphone_RealTimeVoice_Start(int decode_rate)
//4、开始实施喊话
Opus_RealTimeVoice_Start(decode_rate);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
/****
... ... @@ -656,9 +665,11 @@ T_JZsdkReturnCode Megaphone_RealTimeVoice_Start(int decode_rate)
* 22、写入数据进实时喊话的存储池
*
* ***/
int Megaphone_RealTimeVoice_Trans(char *data, int length)
T_JZsdkReturnCode Megaphone_RealTimeVoice_Trans(char *data, int length)
{
Opus_RealTimeVoice_WriteDataToLoop(data, length);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
/*********
... ... @@ -667,7 +678,7 @@ int Megaphone_RealTimeVoice_Trans(char *data, int length)
*
*
**********/
int Megaphone_RealTimeVoice_Close()
T_JZsdkReturnCode Megaphone_RealTimeVoice_Close()
{
... ... @@ -676,6 +687,8 @@ int Megaphone_RealTimeVoice_Close()
//2、关闭功放
Megaphone_set_amplifier(JZ_FLAGCODE_OFF);
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
... ... @@ -789,7 +802,7 @@ T_JZsdkReturnCode Megaphone_Opus_PlayFixedFile()
* 2、存储opus文件开始
*
*/
int Megaphone_SaveOpusStart(int decode_rate)
T_JZsdkReturnCode Megaphone_SaveOpusStart(int decode_rate)
{
Opus_RecordVoice_SaveOpusStart(decode_rate);
}
... ... @@ -799,7 +812,7 @@ int Megaphone_SaveOpusStart(int decode_rate)
* 3、存储opus文件中
*
*/
int Megaphone_SaveOpusTrans(char *SaveData, int size)
T_JZsdkReturnCode Megaphone_SaveOpusTrans(char *SaveData, int size)
{
Opus_RecordVoice_SaveOpusTrans(SaveData, size);
}
... ... @@ -809,7 +822,7 @@ int Megaphone_SaveOpusTrans(char *SaveData, int size)
* 4、存储opus文件结束
*
*/
int Megaphone_SaveOpusStop()
T_JZsdkReturnCode Megaphone_SaveOpusStop()
{
Opus_RecordVoice_SaveOpusStop();
}
... ...
... ... @@ -50,9 +50,9 @@ T_JZsdkReturnCode Megaphone_Opus_PlayFixedFile();
int Megaphone_set_amplifier(int value);
int Megaphone_SaveOpusStart(int decode_rate);
int Megaphone_SaveOpusTrans(char *SaveData, int size);
int Megaphone_SaveOpusStop();
T_JZsdkReturnCode Megaphone_SaveOpusStart(int decode_rate);
T_JZsdkReturnCode Megaphone_SaveOpusTrans(char *SaveData, int size);
T_JZsdkReturnCode Megaphone_SaveOpusStop();
int Megaphone_get_play_status();
int Megaphone_get_play_FileName(char *music_name, int *music_name_len);
... ... @@ -74,11 +74,13 @@ int Megaphone_SaveAudioFileStop();
//获取实时喊话的状态
T_JZsdkReturnCode Megaphone_RealTimeVoice_GetStatusFlag();
int Get_TTS_status();
//实时opus喊话
T_JZsdkReturnCode Megaphone_RealTimeVoice_Start(int decode_rate);
int Megaphone_RealTimeVoice_Trans(char *data, int length);
int Megaphone_RealTimeVoice_Close();
T_JZsdkReturnCode Megaphone_RealTimeVoice_Trans(char *data, int length);
T_JZsdkReturnCode Megaphone_RealTimeVoice_Close();
//实时MP2
T_JZsdkReturnCode Megaphone_RealTimeMP2_start();
... ...
... ... @@ -52,6 +52,9 @@
#elif DEVICE_VERSION == JZ_U3
#define MAX_VOLUME (100)
#define MAX_TTS_VOLUME (100)
#elif DEVICE_VERSION == TF_A1
#define MAX_VOLUME (75)
#define MAX_TTS_VOLUME (82)
#else
#define MAX_VOLUME (75)
#define MAX_TTS_VOLUME (75)
... ... @@ -72,6 +75,8 @@ static int MusicLoopPlayMode=0;//播放模式,MusicLoopPlayMode==1单曲循环
static int music_nowtime=0; //当前音频播放时间
static int music_time=0; //当前音频的总时间
int Intl_TTS_PlayFlag = 0;
int now_volume=20;//默认音量10--》50+10/2==55
int set_volume_value=0;//音量值
... ... @@ -467,7 +472,7 @@ void *SET_volume(void *arg)
{
snprintf(cmdBuffer,128, "amixer set -c 4 Master %d",set_volume_value);
}
else if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T)
else if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T || DEVICE_VERSION == TF_A1)
{
snprintf(cmdBuffer,128, "amixer set -c 0 Master %d",set_volume_value);
}
... ... @@ -539,13 +544,41 @@ void returnframe(char* data, int datasize)//回调函数,监听播放状态
//循环模式打开
if (MusicLoopPlayMode == 1)
{
delayMs(1000);
printf("循环播放%s %d",musiclist[music_num],musicname_len[music_num]);
Music_SendFrame_PlayMusic(musiclist[music_num],musicname_len[music_num]);
//如果没在播海外的tts
if (Intl_TTS_PlayFlag == 0)
{
//延时
for (int i = 0; (i < 1000) && (MusicLoopPlayMode == 1); i+=10)
{
delayMs(10);
}
printf("循环播放%s %d",musiclist[music_num],musicname_len[music_num]);
Music_SendFrame_PlayMusic(musiclist[music_num],musicname_len[music_num]);
}
else if(Intl_TTS_PlayFlag==1)
{
//延时
for (int i = 0; (i < 1000) && (MusicLoopPlayMode == 1); i+=10)
{
delayMs(10);
}
char tts_name[]="IntlTTS.wav";
Music_SendFrame_PlayMusic(tts_name,sizeof(tts_name));//再次播放
}
}
//播放结束
else
{
if (Intl_TTS_PlayFlag == 1)
{
Intl_TTS_PlayFlag = 0;
}
//关闭播放
Megaphone_audio_PlayStop();
... ... @@ -682,12 +715,12 @@ int Music_SendFrame_FramePlay(unsigned char* data, int DataSize)
*
* 获取音频列表信息
*
*
* *****************/
//3首歌版本
int Muisc_GetMusicListMessage(char *MusicListMessage)
{
//将5首歌曲写入显示信息
//播的前面两首 和 播的后面两首
//将3首歌曲写入显示信息
//播的前面1首 和 播的后面1首
char old_TempMusicList[256];
char new_TempMusicList[256];
... ... @@ -696,6 +729,9 @@ int Muisc_GetMusicListMessage(char *MusicListMessage)
//清空当前信息
memset(MusicListMessage,0,sizeof(MusicListMessage));
memset(old_TempMusicList,0,sizeof(old_TempMusicList));
memset(new_TempMusicList,0,sizeof(new_TempMusicList));
memset(TempMusicList,0,sizeof(TempMusicList));
//如果歌曲列表为空
if (music_sum == 0)
... ... @@ -710,8 +746,8 @@ int Muisc_GetMusicListMessage(char *MusicListMessage)
return 0;
}
//如果歌曲列表仅有1~4首歌
if ( (music_sum >= 1) && (music_sum <= 4) )
//如果歌曲列表仅有1~2首歌
if ( (music_sum >= 1) && (music_sum <= 2) )
{
for(i = 0;i<music_sum;i++)
{
... ... @@ -732,31 +768,31 @@ int Muisc_GetMusicListMessage(char *MusicListMessage)
return 0;
}
//如果歌曲列表有大于等于5首歌时
//如果歌曲列表有大于等于2首歌时
// 写入前两首歌曲
for (i = 0; i < 2; i++)
for (i = 0; i < 1; i++)
{
if (music_num - i - 1 >= 0)
{
index = music_num - i -1;
snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
} else
}
else
{
index = music_sum + (music_num - i -1);
snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
}
snprintf(old_TempMusicList,255,"%s",TempMusicList);
snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList);
snprintf(TempMusicList,255,"%s%s",new_TempMusicList,old_TempMusicList);
}
//写入当前歌
snprintf(new_TempMusicList,musicname_len[music_num]+8,"▶:%s\n",musiclist[music_num]);
snprintf(old_TempMusicList,255,"%s",TempMusicList);
snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList);
// 写入后两首歌曲
for (i = 0; i < 2; i++)
// 写入后1首歌曲
for (i = 0; i < 1; i++)
{
if (music_num + i + 1 < music_sum)
{
... ... @@ -777,4 +813,103 @@ int Muisc_GetMusicListMessage(char *MusicListMessage)
snprintf(MusicListMessage,255,"%s",TempMusicList);
return 0;
}
\ No newline at end of file
}
// 显示5首歌
// int Muisc_GetMusicListMessage(char *MusicListMessage)
// {
// //将5首歌曲写入显示信息
// //播的前面两首 和 播的后面两首
// char old_TempMusicList[256];
// char new_TempMusicList[256];
// char TempMusicList[256];
// int i,index;
// //清空当前信息
// memset(MusicListMessage,0,sizeof(MusicListMessage));
// memset(old_TempMusicList,0,sizeof(old_TempMusicList));
// memset(new_TempMusicList,0,sizeof(new_TempMusicList));
// memset(TempMusicList,0,sizeof(TempMusicList));
// //如果歌曲列表为空
// if (music_sum == 0)
// {
// snprintf(new_TempMusicList,255,"当前歌曲列表为空\n",musiclist[music_num]);
// snprintf(old_TempMusicList,255,"%s",TempMusicList);
// snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList);
// //将写好的歌曲放入返回的数组
// snprintf(MusicListMessage,255,"%s",TempMusicList);
// return 0;
// }
// //如果歌曲列表仅有1~4首歌
// if ( (music_sum >= 1) && (music_sum <= 4) )
// {
// for(i = 0;i<music_sum;i++)
// {
// if(i!=music_num)
// {
// snprintf(new_TempMusicList,255,"%s\n",musiclist[i]);
// }
// else{
// snprintf(new_TempMusicList,255,"▶:%s\n",musiclist[i]);
// }
// snprintf(old_TempMusicList,255,"%s",TempMusicList);
// snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList);
// }
// //将写好的歌曲放入返回的数组
// snprintf(MusicListMessage,255,"%s",TempMusicList);
// return 0;
// }
// //如果歌曲列表有大于等于5首歌时
// // 写入前两首歌曲
// for (i = 0; i < 2; i++)
// {
// if (music_num - i - 1 >= 0)
// {
// index = music_num - i -1;
// snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
// }
// else
// {
// index = music_sum + (music_num - i -1);
// snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
// }
// snprintf(old_TempMusicList,255,"%s",TempMusicList);
// snprintf(TempMusicList,255,"%s%s",new_TempMusicList,old_TempMusicList);
// }
// //写入当前歌
// snprintf(new_TempMusicList,musicname_len[music_num]+8,"▶:%s\n",musiclist[music_num]);
// snprintf(old_TempMusicList,255,"%s",TempMusicList);
// snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList);
// // 写入后两首歌曲
// for (i = 0; i < 2; i++)
// {
// if (music_num + i + 1 < music_sum)
// {
// index = music_num + i + 1 ;
// snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
// }
// else
// {
// index = (music_num + i + 1) - music_sum;
// snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
// }
// snprintf(old_TempMusicList,255,"%s",TempMusicList);
// snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList);
// }
// //将写好的歌曲放入返回的数组
// snprintf(MusicListMessage,255,"%s",TempMusicList);
// return 0;
// }
\ No newline at end of file
... ...