作者 潘浩彬

1稳定版更新

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

要显示太多修改。

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

@@ -17,6 +17,16 @@ @@ -17,6 +17,16 @@
17 "gimbal_h3_h10.h": "c", 17 "gimbal_h3_h10.h": "c",
18 "gimbal_h3_h150st.h": "c", 18 "gimbal_h3_h150st.h": "c",
19 "uartconnection.h": "c", 19 "uartconnection.h": "c",
20 - "megaphone_tts.h": "c" 20 + "megaphone_tts.h": "c",
  21 + "jzsdk_uart_output.h": "c",
  22 + "jzsdk_uart_recvdeal.h": "c",
  23 + "jzsdk_uart_input.h": "c",
  24 + "baseconfig.h": "c",
  25 + "jzsdk_uart_uartdeal.h": "c",
  26 + "gimbal_v3s_u3.h": "c",
  27 + "gimbal_v3s_tfa1.h": "c",
  28 + "searchlight_v3s_h1t.h": "c",
  29 + "megaphone_recordvoice.h": "c",
  30 + "gimbal_inandout.h": "c"
21 } 31 }
22 } 32 }
@@ -21,7 +21,7 @@ set(CMAKE_CXX_COMPILER "/usr/local/arm/4.9.3/bin/arm-cortexa9-linux-gnueabihf-g+ @@ -21,7 +21,7 @@ set(CMAKE_CXX_COMPILER "/usr/local/arm/4.9.3/bin/arm-cortexa9-linux-gnueabihf-g+
21 # 工程名 JZ_UART_APP 21 # 工程名 JZ_UART_APP
22 project(JZ_UART_APP) 22 project(JZ_UART_APP)
23 # 设置滤波方式 24行不能被改动,因为会被sh修改滤波方式 23 # 设置滤波方式 24行不能被改动,因为会被sh修改滤波方式
24 -set(filtering_type directed_stopband_filtering) 24 +set(filtering_type high_pass_filtering)
25 25
26 # 海外版本 27行不能改动 26 # 海外版本 27行不能改动
27 set(firewarm_origin DOMESTIC_VERSION) 27 set(firewarm_origin DOMESTIC_VERSION)
@@ -119,7 +119,7 @@ typedef enum { @@ -119,7 +119,7 @@ typedef enum {
119 //5B类帧 119 //5B类帧
120 JZ_INSCODE_5BFRAME_FRAME = 0x10004000, //发送帧 120 JZ_INSCODE_5BFRAME_FRAME = 0x10004000, //发送帧
121 121
122 - JZ_INSCODE_5BFRAME_INITIATECONNECT = 0x10004101, //主动连接 122 + JZ_INSCODE_5BFRAME_INITIATECONNECT = 0x10004101, //回复连接
123 123
124 JZ_INSCODE_5BFRAME_SUCESS = 0x10004200, //操作成功 124 JZ_INSCODE_5BFRAME_SUCESS = 0x10004200, //操作成功
125 JZ_INSCODE_5BFRAME_DEFEAT = 0x10004201, //操作失败 125 JZ_INSCODE_5BFRAME_DEFEAT = 0x10004201, //操作失败
@@ -174,6 +174,8 @@ typedef enum { @@ -174,6 +174,8 @@ typedef enum {
174 JZ_INSCODE_6AFRAME_CHECKSTATUS_SECONDARY_DEVICE_NAME = 0x10008400, //查询从设备设备名 174 JZ_INSCODE_6AFRAME_CHECKSTATUS_SECONDARY_DEVICE_NAME = 0x10008400, //查询从设备设备名
175 JZ_INSCODE_6AFRAME_CHECKSTATUS_GIMBAL_LINKAGE = 0x10008401, //查询云台联动 175 JZ_INSCODE_6AFRAME_CHECKSTATUS_GIMBAL_LINKAGE = 0x10008401, //查询云台联动
176 176
  177 + JZ_INSCODE_6AFRAME_UART_BITRATE_CHANGE = 0x10008500, //串口比特率修改
  178 +
177 //6B类 179 //6B类
178 JZ_INSCODE_6BFRAME_CHECKSTATUS_SECONDARY_DEVICE_NAME = 0x1000C400, //回复从设备名 180 JZ_INSCODE_6BFRAME_CHECKSTATUS_SECONDARY_DEVICE_NAME = 0x1000C400, //回复从设备名
179 JZ_INSCODE_6BFRAME_CHECKSTATUS_GIMBAL_LINKAGE = 0x1000C401, //回复云台联动 181 JZ_INSCODE_6BFRAME_CHECKSTATUS_GIMBAL_LINKAGE = 0x1000C401, //回复云台联动
@@ -55,7 +55,7 @@ int JZsdk_FrameComparsion(char *getdata, int len) @@ -55,7 +55,7 @@ int JZsdk_FrameComparsion(char *getdata, int len)
55 || ( (getdata[len -2]!= 0x00) && (getdata[ len -1] != 0x23) ) 55 || ( (getdata[len -2]!= 0x00) && (getdata[ len -1] != 0x23) )
56 ) 56 )
57 { 57 {
58 - printf("接受到的帧,没有帧头或者帧尾,退出recv帧判断函数\n"); 58 + //printf("接受到的帧,没有帧头或者帧尾,退出recv帧判断函数\n");
59 return JZ_ERROR_SYSTEM_FRAME_ERROR; 59 return JZ_ERROR_SYSTEM_FRAME_ERROR;
60 } 60 }
61 } 61 }
@@ -62,6 +62,11 @@ static int Comparison_6AFRAME_FirstLevelCode_0x6F(char *getdata) @@ -62,6 +62,11 @@ static int Comparison_6AFRAME_FirstLevelCode_0x6F(char *getdata)
62 return JZ_INSCODE_6AFRAME_CHECKSTATUS_GIMBAL_LINKAGE; 62 return JZ_INSCODE_6AFRAME_CHECKSTATUS_GIMBAL_LINKAGE;
63 break; 63 break;
64 64
  65 + //串口比特率修改
  66 + case 0x52:
  67 + return JZ_INSCODE_6AFRAME_UART_BITRATE_CHANGE;
  68 + break;
  69 +
65 default: 70 default:
66 return JZ_ERROR_SYSTEM_FRAME_ERROR; 71 return JZ_ERROR_SYSTEM_FRAME_ERROR;
67 break; 72 break;
@@ -18,6 +18,14 @@ int JZsdk_GetFrameTemplate(int InsCode ,char *str, int *str_len) @@ -18,6 +18,14 @@ int JZsdk_GetFrameTemplate(int InsCode ,char *str, int *str_len)
18 * 18 *
19 ********************************************************************************************************************************************************/ 19 ********************************************************************************************************************************************************/
20 20
  21 + case JZ_INSCODE_5AFRAME_ASKFORCONNECT:
  22 + {
  23 + char sendbuf[12] = {0x5A ,0x5A ,0x77 ,0x00 ,0x0C ,0x00 ,0x00 ,0x50 ,0x51 ,0x00 ,0x00 ,0x23};
  24 + memcpy(str, sendbuf, 12);
  25 + *str_len = 12;
  26 + }
  27 + break;
  28 +
21 case JZ_INSCODE_5AFRAME_SEARCHLIGHT_SET_FREQUENCY: 29 case JZ_INSCODE_5AFRAME_SEARCHLIGHT_SET_FREQUENCY:
22 { 30 {
23 char sendbuf[13] = {0x5A ,0x5A ,0x77 ,0x00 ,0x0D ,0x00 ,0x00 ,0x61 ,0x51 ,0x00 ,0x00 ,0x00 ,0x23}; 31 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) @@ -152,6 +152,30 @@ T_JZsdkReturnCode writeToLogFile(const char *data)
152 pthread_mutex_unlock(&LogWriteMutex); 152 pthread_mutex_unlock(&LogWriteMutex);
153 } 153 }
154 154
  155 +T_JZsdkReturnCode HexToLogFile(const char *data)
  156 +{
  157 + // 加锁
  158 + pthread_mutex_lock(&LogWriteMutex);
  159 +
  160 + logFile = fopen(LogFileName, "a"); // 使用"a"模式打开文件,以在末尾追加数据
  161 +
  162 + if (logFile == NULL) {
  163 + // 文件打开失败,输出错误消息
  164 + printf("Failed to open file: %s", LogFileName);
  165 + pthread_mutex_unlock(&LogWriteMutex);
  166 +
  167 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  168 + }
  169 +
  170 + fprintf(logFile, "%x ", data[0]); // 写入新的数据
  171 +
  172 + fclose(logFile);
  173 +
  174 + // 解锁
  175 + pthread_mutex_unlock(&LogWriteMutex);
  176 +}
  177 +
  178 +
155 void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...) 179 void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...)
156 { 180 {
157 // 将日志级别转换为相应的字符串 181 // 将日志级别转换为相应的字符串
@@ -172,6 +196,14 @@ void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...) @@ -172,6 +196,14 @@ void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...)
172 default: 196 default:
173 break; 197 break;
174 } 198 }
  199 +
  200 + //减少打印
  201 + if (level < JZSDK_LOG_LEVEL)
  202 + {
  203 + return;
  204 + }
  205 +
  206 +
175 // 使用可变参数处理传入的格式化字符串和可变参数 207 // 使用可变参数处理传入的格式化字符串和可变参数
176 va_list args; 208 va_list args;
177 va_start(args, fmt); 209 va_start(args, fmt);
@@ -200,3 +232,48 @@ void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...) @@ -200,3 +232,48 @@ void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...)
200 //写入日志 232 //写入日志
201 writeToLogFile(finalLogMessage); 233 writeToLogFile(finalLogMessage);
202 } 234 }
  235 +
  236 +
  237 +
  238 +void JZsdk_User_OutputHex(E_JZsdkConsoleLogLevel level, const char *fmt, ...)
  239 +{
  240 + // 将日志级别转换为相应的字符串
  241 + const char *JZSDK_LOGGER_CONSOLE_LOG_LEVEL = "";
  242 + switch (level) {
  243 + case JZSDK_LOGGER_CONSOLE_LOG_LEVEL_DEBUG:
  244 + JZSDK_LOGGER_CONSOLE_LOG_LEVEL = "DEBUG";
  245 + break;
  246 + case JZSDK_LOGGER_CONSOLE_LOG_LEVEL_INFO:
  247 + JZSDK_LOGGER_CONSOLE_LOG_LEVEL = "INFO";
  248 + break;
  249 + case JZSDK_LOGGER_CONSOLE_LOG_LEVEL_WARN:
  250 + JZSDK_LOGGER_CONSOLE_LOG_LEVEL = "WARNING";
  251 + break;
  252 + case JZSDK_LOGGER_CONSOLE_LOG_LEVEL_ERROR:
  253 + JZSDK_LOGGER_CONSOLE_LOG_LEVEL = "ERROR";
  254 + break;
  255 + default:
  256 + break;
  257 + }
  258 + // 使用可变参数处理传入的格式化字符串和可变参数
  259 + va_list args;
  260 + va_start(args, fmt);
  261 +
  262 + //格式化日志消息
  263 + char logMessage[10];
  264 + memset(logMessage, 0, sizeof(logMessage));
  265 + vsnprintf(logMessage, sizeof(logMessage), fmt, args);
  266 +
  267 + va_end(args);
  268 +
  269 + // 执行具体的日志输出操作
  270 + char finalLogMessage[512];
  271 + memset(finalLogMessage, 0, sizeof(finalLogMessage));
  272 + snprintf(finalLogMessage, 612, "%s", logMessage);
  273 +
  274 +
  275 + printf("%x ",finalLogMessage[0]);
  276 +
  277 + //写入日志
  278 + HexToLogFile(finalLogMessage);
  279 +}
@@ -45,6 +45,7 @@ typedef enum { @@ -45,6 +45,7 @@ typedef enum {
45 /* Exported functions --------------------------------------------------------*/ 45 /* Exported functions --------------------------------------------------------*/
46 void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...); 46 void JZsdk_UserLogOutput(E_JZsdkConsoleLogLevel level, const char *fmt, ...);
47 T_JZsdkReturnCode JZsdk_LoggerInit(); 47 T_JZsdkReturnCode JZsdk_LoggerInit();
  48 +void JZsdk_User_OutputHex(E_JZsdkConsoleLogLevel level, const char *fmt, ...);
48 49
49 /* Exported constants --------------------------------------------------------*/ 50 /* Exported constants --------------------------------------------------------*/
50 #define JZSDK_LOG_DEBUG(fmt, ...) \ 51 #define JZSDK_LOG_DEBUG(fmt, ...) \
@@ -55,6 +56,10 @@ T_JZsdkReturnCode JZsdk_LoggerInit(); @@ -55,6 +56,10 @@ T_JZsdkReturnCode JZsdk_LoggerInit();
55 JZsdk_UserLogOutput(JZSDK_LOGGER_CONSOLE_LOG_LEVEL_WARN, "[%s:%d) " fmt, __FUNCTION__, __LINE__ , ##__VA_ARGS__) 56 JZsdk_UserLogOutput(JZSDK_LOGGER_CONSOLE_LOG_LEVEL_WARN, "[%s:%d) " fmt, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
56 #define JZSDK_LOG_ERROR(fmt, ...) \ 57 #define JZSDK_LOG_ERROR(fmt, ...) \
57 JZsdk_UserLogOutput(JZSDK_LOGGER_CONSOLE_LOG_LEVEL_ERROR, "[%s:%d) " fmt, __FUNCTION__, __LINE__ , ##__VA_ARGS__) 58 JZsdk_UserLogOutput(JZSDK_LOGGER_CONSOLE_LOG_LEVEL_ERROR, "[%s:%d) " fmt, __FUNCTION__, __LINE__ , ##__VA_ARGS__)
  59 +#define JZSDK_LOG_OUTPUTHEX(fmt, ...) \
  60 + JZsdk_User_OutputHex(JZSDK_LOGGER_CONSOLE_LOG_LEVEL_INFO, "" fmt , ##__VA_ARGS__)
  61 +
  62 +#define JZSDK_LOG_LEVEL JZSDK_LOGGER_CONSOLE_LOG_LEVEL_DEBUG
58 63
59 64
60 #ifdef __cplusplus 65 #ifdef __cplusplus
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 #include "BaseConfig.h" 7 #include "BaseConfig.h"
8 #include "version_choose.h" 8 #include "version_choose.h"
9 9
  10 +#include "JZsdk_Uart_Input.h"
10 #include "JZsdk_Uart_UartDeal.h" 11 #include "JZsdk_Uart_UartDeal.h"
11 #include "Gimbal_InAndOut.h" 12 #include "Gimbal_InAndOut.h"
12 #include "Uart_Config.h" 13 #include "Uart_Config.h"
@@ -33,11 +34,11 @@ int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME) @@ -33,11 +34,11 @@ int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME)
33 { 34 {
34 return UartDevUseFlag.UartDev_DEV1; 35 return UartDevUseFlag.UartDev_DEV1;
35 } 36 }
36 - if (UART_DEV_NAME == UART_DEV_2) 37 + else if (UART_DEV_NAME == UART_DEV_2)
37 { 38 {
38 return UartDevUseFlag.UartDev_DEV2; 39 return UartDevUseFlag.UartDev_DEV2;
39 } 40 }
40 - if (UART_DEV_NAME == UART_4G) 41 + else if (UART_DEV_NAME == UART_4G)
41 { 42 {
42 return UartDevUseFlag.UartDev_4G; 43 return UartDevUseFlag.UartDev_4G;
43 } 44 }
@@ -50,13 +51,81 @@ int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME) @@ -50,13 +51,81 @@ int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME)
50 * *********/ 51 * *********/
51 int JZsdk_Uart_Init(int UART_DEV_NAME) 52 int JZsdk_Uart_Init(int UART_DEV_NAME)
52 { 53 {
  54 +
  55 + //初始化的是一号设备
  56 + if (UART_DEV_NAME == UART_DEV_1)
  57 + {
  58 + JZsdk_Uart_SecondInit(UART_DEV_1,UART_DEV1_BITRATE);
  59 + }
  60 +
  61 + //初始化的是二号设备
  62 + else if (UART_DEV_NAME == UART_DEV_2)
  63 + {
  64 + JZsdk_Uart_SecondInit(UART_DEV_2, UART_DEV2_BITRATE);
  65 + }
  66 +
  67 + else if (UART_DEV_NAME == UART_4G)
  68 + {
  69 + JZsdk_Uart_SecondInit(UART_4G, COMM_4G_UART_BITRATE);
  70 + }
  71 +
  72 + printf("%x串口初始化完成\n", UART_DEV_NAME);
  73 +}
  74 +
  75 +/**************
  76 + *
  77 + * 串口部分修改波特率
  78 + *
  79 + * *********/
  80 +int JZsdk_Uart_BitRateChange(int UART_DEV_NAME, int BitRate)
  81 +{
  82 + //1、释放掉原串口
  83 + if (UART_DEV_NAME == UART_DEV_1)
  84 + {
  85 + //将使用标识关闭
  86 + UartDevUseFlag.UartDev_DEV1 = JZ_FLAGCODE_OFF;
  87 +
  88 + //等候关闭接收线程
  89 + JZsdk_Uart_CloseUartThead(UART_DEV_NAME, BitRate);
  90 + }
  91 +
  92 + //1、释放掉原串口
  93 + else if (UART_DEV_NAME == UART_DEV_2)
  94 + {
  95 + //将使用标识关闭
  96 + UartDevUseFlag.UartDev_DEV2 = JZ_FLAGCODE_OFF;
  97 +
  98 + //等候关闭接收线程
  99 + JZsdk_Uart_CloseUartThead(UART_DEV_NAME, BitRate);
  100 + }
  101 +
  102 + //1、释放掉原串口
  103 + else if (UART_DEV_NAME == UART_4G)
  104 + {
  105 + //将使用标识关闭
  106 + UartDevUseFlag.UartDev_4G = JZ_FLAGCODE_OFF;
  107 +
  108 + //等候关闭接收线程
  109 + JZsdk_Uart_CloseUartThead(UART_DEV_NAME, BitRate);
  110 + }
  111 +}
  112 +
  113 +/**************
  114 + *
  115 + * 串口部分串口再注册
  116 + *
  117 + * *********/
  118 +int JZsdk_Uart_SecondInit(int UART_DEV_NAME, int BitRate)
  119 +{
53 int Uart_fd = 0; 120 int Uart_fd = 0;
54 121
  122 + printf("初始化串口%d\n",UART_DEV_NAME);
  123 +
55 //初始化的是一号设备 124 //初始化的是一号设备
56 if (UART_DEV_NAME == UART_DEV_1) 125 if (UART_DEV_NAME == UART_DEV_1)
57 { 126 {
58 //1、串口初始化 127 //1、串口初始化
59 - Uart_fd = UartConnection_UartEnabled(UART_DEV1_NUM, UART_DEV1_BITRATE); 128 + Uart_fd = UartConnection_UartEnabled(UART_DEV1_NUM, BitRate);
60 129
61 //2、串口接收初始化 130 //2、串口接收初始化
62 JZsdk_Uart_UartDeal_Receive(Uart_fd, UART_DEV_1); 131 JZsdk_Uart_UartDeal_Receive(Uart_fd, UART_DEV_1);
@@ -65,11 +134,10 @@ int JZsdk_Uart_Init(int UART_DEV_NAME) @@ -65,11 +134,10 @@ int JZsdk_Uart_Init(int UART_DEV_NAME)
65 UartDevUseFlag.UartDev_DEV1 = JZ_FLAGCODE_ON; 134 UartDevUseFlag.UartDev_DEV1 = JZ_FLAGCODE_ON;
66 } 135 }
67 136
68 - //初始化的是二号设备  
69 - if (UART_DEV_NAME == UART_DEV_2) 137 + else if (UART_DEV_NAME == UART_DEV_2)
70 { 138 {
71 //1、串口初始化 139 //1、串口初始化
72 - Uart_fd = UartConnection_UartEnabled(UART_DEV2_NUM, UART_DEV2_BITRATE); 140 + Uart_fd = UartConnection_UartEnabled(UART_DEV2_NUM, BitRate);
73 141
74 //2、串口接收初始化 142 //2、串口接收初始化
75 JZsdk_Uart_UartDeal_Receive(Uart_fd, UART_DEV_2); 143 JZsdk_Uart_UartDeal_Receive(Uart_fd, UART_DEV_2);
@@ -78,10 +146,10 @@ int JZsdk_Uart_Init(int UART_DEV_NAME) @@ -78,10 +146,10 @@ int JZsdk_Uart_Init(int UART_DEV_NAME)
78 UartDevUseFlag.UartDev_DEV2 = JZ_FLAGCODE_ON; 146 UartDevUseFlag.UartDev_DEV2 = JZ_FLAGCODE_ON;
79 } 147 }
80 148
81 - if (UART_DEV_NAME == UART_4G) 149 + else if (UART_DEV_NAME == UART_4G)
82 { 150 {
83 //1、串口初始化 151 //1、串口初始化
84 - Uart_fd = UartConnection_UartEnabled(COMM_4G_UART_NUM, COMM_4G_UART_BITRATE); 152 + Uart_fd = UartConnection_UartEnabled(COMM_4G_UART_NUM, BitRate);
85 153
86 //2、串口接收初始化 154 //2、串口接收初始化
87 JZsdk_Uart_UartDeal_Receive(Uart_fd, UART_4G); 155 JZsdk_Uart_UartDeal_Receive(Uart_fd, UART_4G);
@@ -89,11 +157,31 @@ int JZsdk_Uart_Init(int UART_DEV_NAME) @@ -89,11 +157,31 @@ int JZsdk_Uart_Init(int UART_DEV_NAME)
89 //3、将使用标识打开 157 //3、将使用标识打开
90 UartDevUseFlag.UartDev_4G = JZ_FLAGCODE_ON; 158 UartDevUseFlag.UartDev_4G = JZ_FLAGCODE_ON;
91 } 159 }
  160 +}
92 161
93 - printf("%x串口初始化完成\n", UART_DEV_NAME); 162 +/*
  163 +*
  164 +* 发送自由帧
  165 +*
  166 +*/
  167 +int JZsdk_Uart_Send_CustomOrder(int UartPort, char *sendbuf, int len)
  168 +{
  169 + JZsdk_Uart_SendDeal_Send_CustomOrder(UartPort, sendbuf, len);
  170 +}
  171 +
  172 +/*
  173 +*
  174 +* 发送请求连接帧
  175 +*
  176 +*/
  177 +int JZsdk_Uart_Send_ConnectFrame(int PortNum)
  178 +{
  179 + //发送请求连接帧
  180 + JZsdk_Uart_SendDeal_Send_ConnectFrame(PortNum);
94 } 181 }
95 182
96 183
  184 +
97 /* 185 /*
98 * 186 *
99 * 发送播放结束状态帧 187 * 发送播放结束状态帧
@@ -25,6 +25,8 @@ extern "C" { @@ -25,6 +25,8 @@ extern "C" {
25 /* Exported functions --------------------------------------------------------*/ 25 /* Exported functions --------------------------------------------------------*/
26 int JZsdk_Uart_Init(int UART_DEV_NAME); 26 int JZsdk_Uart_Init(int UART_DEV_NAME);
27 int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME); 27 int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME);
  28 +int JZsdk_Uart_Send_ConnectFrame(int PortNum);
  29 +int JZsdk_Uart_Send_CustomOrder(int UartPort, char *sendbuf, int len);
28 30
29 int JZsdk_Uart_Reply_PlayStatus_end(int PortNum); 31 int JZsdk_Uart_Reply_PlayStatus_end(int PortNum);
30 int JZsdk_Uart_Send_PlayStatus(int Uartport ,int num); 32 int JZsdk_Uart_Send_PlayStatus(int Uartport ,int num);
@@ -75,6 +77,8 @@ int JZsdk_Uart_Send_CheckStatus_WarningLightColor(int Uartport); @@ -75,6 +77,8 @@ int JZsdk_Uart_Send_CheckStatus_WarningLightColor(int Uartport);
75 77
76 int JZsdk_Uart_Send_OutputPowerStatus(int Uartport, int FrameSequence, int status); 78 int JZsdk_Uart_Send_OutputPowerStatus(int Uartport, int FrameSequence, int status);
77 79
  80 +int JZsdk_Uart_BitRateChange(int UART_DEV_NAME, int BitRate);
  81 +int JZsdk_Uart_SecondInit(int UART_DEV_NAME, int BitRate);
78 82
79 #ifdef __cplusplus 83 #ifdef __cplusplus
80 } 84 }
@@ -443,7 +443,7 @@ T_JZsdkReturnCode JZsdk_Uart_SearchLight_Control(int DeviceName, int mode) @@ -443,7 +443,7 @@ T_JZsdkReturnCode JZsdk_Uart_SearchLight_Control(int DeviceName, int mode)
443 **********/ 443 **********/
444 T_JZsdkReturnCode JZsdk_Uart_SearchLight_Lumen(int DeviceName, int LeftLumen, int RightLumen) 444 T_JZsdkReturnCode JZsdk_Uart_SearchLight_Lumen(int DeviceName, int LeftLumen, int RightLumen)
445 { 445 {
446 - return UIcontrol_Set_SearchLightLumen(DeviceName, LeftLumen, RightLumen); 446 + return UIcontrol_Set_SearchLightLumen(DeviceName, 1, LeftLumen, RightLumen);
447 } 447 }
448 448
449 /********* 449 /*********
@@ -728,6 +728,19 @@ T_JZsdkReturnCode JZsdk_Uart_Checkstatus_OutPutPower(int DeviceName, int FrameSe @@ -728,6 +728,19 @@ T_JZsdkReturnCode JZsdk_Uart_Checkstatus_OutPutPower(int DeviceName, int FrameSe
728 ********* ********| 728 ********* ********|
729 ********* ********| 729 ********* ********|
730 *********************************************************************************************************/ 730 *********************************************************************************************************/
  731 +/*********
  732 + *
  733 + * 收到连接回复帧
  734 + *
  735 +**********/
  736 +int JZsdl_Uart_ObtainConnectFrame(char *getbuf, int value)
  737 +{
  738 +#if APP_VERSION == APP_TEST
  739 + TestAPP_Connect(value);
  740 +#endif
  741 +}
  742 +
  743 +
731 744
732 /******************************************************************************************************************************* 745 /*******************************************************************************************************************************
733 * 746 *
@@ -28,6 +28,7 @@ extern "C" { @@ -28,6 +28,7 @@ extern "C" {
28 /* Exported functions --------------------------------------------------------*/ 28 /* Exported functions --------------------------------------------------------*/
29 int JZsdk_Uart_Init(int UART_DEV_NAME); 29 int JZsdk_Uart_Init(int UART_DEV_NAME);
30 int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME); 30 int JZsdk_Get_UartDev_UseFlag(int UART_DEV_NAME);
  31 +int JZsdl_Uart_ObtainConnectFrame(char *getbuf, int value);
31 32
32 int JZsdk_Uart_Set_Amplifier(int status); 33 int JZsdk_Uart_Set_Amplifier(int status);
33 T_JZsdkReturnCode JZsdk_Uart_Set_Volume(int DeviceName, int value); 34 T_JZsdkReturnCode JZsdk_Uart_Set_Volume(int DeviceName, int value);
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 7
8 #include "JZsdk_Uart_Send/JZsdk_Uart_Send.h" 8 #include "JZsdk_Uart_Send/JZsdk_Uart_Send.h"
9 #include "JZsdk_Uart_Output.h" 9 #include "JZsdk_Uart_Output.h"
  10 +#include "JZsdk_Uart_Input.h"
10 11
11 #include "version_choose.h" 12 #include "version_choose.h"
12 13
@@ -15,7 +16,8 @@ int UART_4G_Receive_mode = 0; @@ -15,7 +16,8 @@ int UART_4G_Receive_mode = 0;
15 static char TTS_Recv_buffer[1009]; //TTS接收数据缓冲区 1000中文 + 3个字中文的防溢出区 16 static char TTS_Recv_buffer[1009]; //TTS接收数据缓冲区 1000中文 + 3个字中文的防溢出区
16 static int TTS_Recv_buffer_length = 0; 17 static int TTS_Recv_buffer_length = 0;
17 18
18 -int JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(int value); 19 +int JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(int value);
  20 +static T_JZsdkReturnCode JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
19 21
20 /******************************************************************************************************** 22 /********************************************************************************************************
21 ********* ********| 23 ********* ********|
@@ -39,7 +41,7 @@ int JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(int value); @@ -39,7 +41,7 @@ int JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(int value);
39 **********/ 41 **********/
40 static int Uart_4G_RecvDeal_AskForConnect(char *getbuf) 42 static int Uart_4G_RecvDeal_AskForConnect(char *getbuf)
41 { 43 {
42 - JZSDK_LOG_INFO("串口设备4g,连接成功"); 44 + JZSDK_LOG_INFO("串口设备4G,连接成功");
43 //获取帧的序列号 45 //获取帧的序列号
44 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 46 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
45 47
@@ -50,7 +52,7 @@ static int Uart_4G_RecvDeal_AskForConnect(char *getbuf) @@ -50,7 +52,7 @@ static int Uart_4G_RecvDeal_AskForConnect(char *getbuf)
50 JZsdk_Uart_SendDeal_Send_Connect(UART_4G, Device_name); 52 JZsdk_Uart_SendDeal_Send_Connect(UART_4G, Device_name);
51 53
52 //1、将串口程序设置为连接模式 54 //1、将串口程序设置为连接模式
53 - //JZsdk_Uart_SetMainWorkMode(JZ_FLAGCODE_ON);s 55 + //JZsdk_Uart_SetMainWorkMode(JZ_FLAGCODE_ON);
54 } 56 }
55 57
56 /******************************************************************************************************************************* 58 /*******************************************************************************************************************************
@@ -65,7 +67,7 @@ static int Uart_4G_RecvDeal_AskForConnect(char *getbuf) @@ -65,7 +67,7 @@ static int Uart_4G_RecvDeal_AskForConnect(char *getbuf)
65 * 67 *
66 * 68 *
67 **********/ 69 **********/
68 -static int Uart_4G_RecvDeal_RealTimeMP2_start(char *getbuf) 70 +static T_JZsdkReturnCode Uart_4G_RecvDeal_RealTimeMP2_start(char *getbuf)
69 { 71 {
70 JZSDK_LOG_INFO("开启MP2实时喊话功能\n"); 72 JZSDK_LOG_INFO("开启MP2实时喊话功能\n");
71 T_JZsdkReturnCode ret; 73 T_JZsdkReturnCode ret;
@@ -73,8 +75,18 @@ static int Uart_4G_RecvDeal_RealTimeMP2_start(char *getbuf) @@ -73,8 +75,18 @@ static int Uart_4G_RecvDeal_RealTimeMP2_start(char *getbuf)
73 //获取帧的序列号 75 //获取帧的序列号
74 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 76 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
75 77
  78 + ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
  79 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  80 + {
  81 + //回复操作失败
  82 + JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
  83 + JZSDK_LOG_ERROR("开启MP2实时喊话功能失败\n");
  84 +
  85 + return ret;
  86 + }
  87 +
76 //1、修改接收模式 88 //1、修改接收模式
77 - JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION); 89 + JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION);
78 90
79 //2、获取码率倍率 默认8k 91 //2、获取码率倍率 默认8k
80 int RateMagnification = (int)getbuf[9]; 92 int RateMagnification = (int)getbuf[9];
@@ -124,7 +136,7 @@ static int Uart_4G_RecvDeal_RealTimeMP2_transmission(char *getdata, int len) @@ -124,7 +136,7 @@ static int Uart_4G_RecvDeal_RealTimeMP2_transmission(char *getdata, int len)
124 * 136 *
125 * 137 *
126 **********/ 138 **********/
127 -static int Uart_4G_RecvDeal_RealTimeMP2_stop(char *getbuf) 139 +static T_JZsdkReturnCode Uart_4G_RecvDeal_RealTimeMP2_stop(char *getbuf)
128 { 140 {
129 JZSDK_LOG_INFO("关闭MP2实时喊话功能\n"); 141 JZSDK_LOG_INFO("关闭MP2实时喊话功能\n");
130 T_JZsdkReturnCode ret; 142 T_JZsdkReturnCode ret;
@@ -132,8 +144,17 @@ static int Uart_4G_RecvDeal_RealTimeMP2_stop(char *getbuf) @@ -132,8 +144,17 @@ static int Uart_4G_RecvDeal_RealTimeMP2_stop(char *getbuf)
132 //获取帧的序列号 144 //获取帧的序列号
133 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 145 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
134 146
  147 + if (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION)
  148 + {
  149 + //回复操作失败
  150 + JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
  151 + JZSDK_LOG_ERROR("操作失败,mp2传输未开始,无法关闭");
  152 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  153 + }
  154 +
  155 +
135 //1、修改接收模式 156 //1、修改接收模式
136 - JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP); 157 + JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP);
137 158
138 //2、关闭实时MP2模式 159 //2、关闭实时MP2模式
139 ret = JZsdk_Uart_RealTimeMP2_Close(); 160 ret = JZsdk_Uart_RealTimeMP2_Close();
@@ -155,12 +176,21 @@ static int Uart_4G_RecvDeal_RealTimeMP2_stop(char *getbuf) @@ -155,12 +176,21 @@ static int Uart_4G_RecvDeal_RealTimeMP2_stop(char *getbuf)
155 * 176 *
156 * 177 *
157 **********/ 178 **********/
158 -static int Uart_4G_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len) 179 +static T_JZsdkReturnCode Uart_4G_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
159 { 180 {
160 JZSDK_LOG_INFO("开始传输的音频文件保存\n"); 181 JZSDK_LOG_INFO("开始传输的音频文件保存\n");
161 //获取帧的序列号 182 //获取帧的序列号
162 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 183 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
163 184
  185 + T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
  186 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  187 + {
  188 + //回复操作失败
  189 + JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
  190 + JZSDK_LOG_ERROR("开始传输的音频文件保存失败");
  191 + return ret;
  192 + }
  193 +
164 //1、处理帧长度,获取文件名长度 194 //1、处理帧长度,获取文件名长度
165 int FileNameLen = ((int)getbuf[3] << 8) + (int)getbuf[4] - 2 - 9; 195 int FileNameLen = ((int)getbuf[3] << 8) + (int)getbuf[4] - 2 - 9;
166 196
@@ -170,7 +200,7 @@ static int Uart_4G_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len) @@ -170,7 +200,7 @@ static int Uart_4G_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
170 memcpy(FileName, &getbuf[9], FileNameLen); 200 memcpy(FileName, &getbuf[9], FileNameLen);
171 JZSDK_LOG_INFO("保存的文件名为%s",FileName); 201 JZSDK_LOG_INFO("保存的文件名为%s",FileName);
172 202
173 - T_JZsdkReturnCode ret = JZsdk_Uart_SaveAudioFileStart(FileName); 203 + ret = JZsdk_Uart_SaveAudioFileStart(FileName);
174 if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS) 204 if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
175 { 205 {
176 JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence); 206 JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
@@ -178,7 +208,7 @@ static int Uart_4G_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len) @@ -178,7 +208,7 @@ static int Uart_4G_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
178 } 208 }
179 209
180 //3、调整接收模式为音频文件传输 210 //3、调整接收模式为音频文件传输
181 - JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION); 211 + JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION);
182 212
183 //4、回复操作成功 213 //4、回复操作成功
184 JZsdk_Uart_SendDeal_Reply_Sucesss(UART_4G, FrameSequence); 214 JZsdk_Uart_SendDeal_Reply_Sucesss(UART_4G, FrameSequence);
@@ -207,9 +237,20 @@ static int Uart_4G_RecvDeal_SaveAudioFileTrans_stop(char *getbuf) @@ -207,9 +237,20 @@ static int Uart_4G_RecvDeal_SaveAudioFileTrans_stop(char *getbuf)
207 //获取帧的序列号 237 //获取帧的序列号
208 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 238 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
209 239
  240 + if (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION)
  241 + {
  242 + //回复操作失败
  243 + JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
  244 + JZSDK_LOG_ERROR("关闭音频文件上传失败,音频文件上传未开始,无法关闭");
  245 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  246 + }
  247 +
210 //1、保存音频数据 248 //1、保存音频数据
211 JZsdk_Uart_SaveAudioFileStop(); 249 JZsdk_Uart_SaveAudioFileStop();
212 250
  251 + //3、调整接收模式为音频文件传输
  252 + JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP);
  253 +
213 //2、回复操作成功 254 //2、回复操作成功
214 JZsdk_Uart_SendDeal_Reply_Sucesss(UART_4G, FrameSequence); 255 JZsdk_Uart_SendDeal_Reply_Sucesss(UART_4G, FrameSequence);
215 } 256 }
@@ -849,12 +890,21 @@ static int Uart_4G_RecvDeal_TTS_SetSpeed(char *getbuf) @@ -849,12 +890,21 @@ static int Uart_4G_RecvDeal_TTS_SetSpeed(char *getbuf)
849 // 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x03 0x00 0x00 0x23 开始TTS发送 890 // 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x03 0x00 0x00 0x23 开始TTS发送
850 // 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX TTS数据 891 // 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX TTS数据
851 // 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x04 0x00 0x00 0x23 结束TTS发送 892 // 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x04 0x00 0x00 0x23 结束TTS发送
852 -static int Uart_4G_RecvDeal_TTS_Trans_start(char *getbuf) 893 +static T_JZsdkReturnCode Uart_4G_RecvDeal_TTS_Trans_start(char *getbuf)
853 { 894 {
854 JZSDK_LOG_INFO("tts开始传输"); 895 JZSDK_LOG_INFO("tts开始传输");
855 //获取帧的序列号 896 //获取帧的序列号
856 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 897 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
857 898
  899 + T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
  900 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  901 + {
  902 + //回复操作失败
  903 + JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
  904 + JZSDK_LOG_ERROR("tts开始传输失败");
  905 + return ret;
  906 + }
  907 +
858 //1、重置缓冲区 908 //1、重置缓冲区
859 memset(TTS_Recv_buffer, 0, 1009); 909 memset(TTS_Recv_buffer, 0, 1009);
860 910
@@ -862,7 +912,7 @@ static int Uart_4G_RecvDeal_TTS_Trans_start(char *getbuf) @@ -862,7 +912,7 @@ static int Uart_4G_RecvDeal_TTS_Trans_start(char *getbuf)
862 TTS_Recv_buffer_length = 0; 912 TTS_Recv_buffer_length = 0;
863 913
864 //3、将接收模式设置为接收TTS数据模式 914 //3、将接收模式设置为接收TTS数据模式
865 - JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION); 915 + JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION);
866 916
867 //回复操作成功 917 //回复操作成功
868 JZsdk_Uart_SendDeal_Reply_Sucesss(UART_4G, FrameSequence); 918 JZsdk_Uart_SendDeal_Reply_Sucesss(UART_4G, FrameSequence);
@@ -897,17 +947,32 @@ static int Uart_4G_RecvDeal_TTS_Trans_transmission(char *getdata, int len) @@ -897,17 +947,32 @@ static int Uart_4G_RecvDeal_TTS_Trans_transmission(char *getdata, int len)
897 * 947 *
898 * 948 *
899 **********/ 949 **********/
900 -static int Uart_4G_RecvDeal_TTS_Trans_stop(char *getbuf) 950 +static T_JZsdkReturnCode Uart_4G_RecvDeal_TTS_Trans_stop(char *getbuf)
901 { 951 {
902 JZSDK_LOG_INFO("tts传输结束"); 952 JZSDK_LOG_INFO("tts传输结束");
903 //获取帧的序列号 953 //获取帧的序列号
904 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 954 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
905 955
  956 + if (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)
  957 + {
  958 + JZSDK_LOG_INFO("未刷新文本,TTS播放%s",TTS_Recv_buffer);
  959 +
  960 + //3、播放TTS
  961 + JZsdk_Uart_TTS_Play(UART_4G, TTS_Recv_buffer, TTS_Recv_buffer_length);
  962 +
  963 + //回复操作成功
  964 + JZsdk_Uart_SendDeal_Reply_Sucesss(UART_4G, FrameSequence);
  965 +
  966 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  967 + }
906 968
907 //1、打印一次TTS文本 969 //1、打印一次TTS文本
908 JZSDK_LOG_INFO("TTS播放%s",TTS_Recv_buffer); 970 JZSDK_LOG_INFO("TTS播放%s",TTS_Recv_buffer);
909 971
910 - //2、播放TTS 972 + //2、将接收模式设置为关闭接收TTS
  973 + JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP);
  974 +
  975 + //3、播放TTS
911 JZsdk_Uart_TTS_Play(UART_4G, TTS_Recv_buffer, TTS_Recv_buffer_length); 976 JZsdk_Uart_TTS_Play(UART_4G, TTS_Recv_buffer, TTS_Recv_buffer_length);
912 977
913 //回复操作成功 978 //回复操作成功
@@ -921,12 +986,21 @@ static int Uart_4G_RecvDeal_TTS_Trans_stop(char *getbuf) @@ -921,12 +986,21 @@ static int Uart_4G_RecvDeal_TTS_Trans_stop(char *getbuf)
921 * 986 *
922 * 987 *
923 **********/ 988 **********/
924 -static int Uart_4G_RecvDeal_OpusTrans_start(char *getbuf) 989 +static T_JZsdkReturnCode Uart_4G_RecvDeal_OpusTrans_start(char *getbuf)
925 { 990 {
926 JZSDK_LOG_INFO("打开opus传输\n"); 991 JZSDK_LOG_INFO("打开opus传输\n");
927 //获取帧的序列号 992 //获取帧的序列号
928 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 993 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
929 994
  995 + T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
  996 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  997 + {
  998 + //回复操作失败
  999 + JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
  1000 + JZSDK_LOG_ERROR("打开opus传输失败");
  1001 + return ret;
  1002 + }
  1003 +
930 //1、获取解码比特率 1004 //1、获取解码比特率
931 int decode_rate = getbuf[9] * 8000; 1005 int decode_rate = getbuf[9] * 8000;
932 if(decode_rate == 0) 1006 if(decode_rate == 0)
@@ -938,7 +1012,7 @@ static int Uart_4G_RecvDeal_OpusTrans_start(char *getbuf) @@ -938,7 +1012,7 @@ static int Uart_4G_RecvDeal_OpusTrans_start(char *getbuf)
938 JZsdk_Uart_SaveOpusStart(decode_rate); 1012 JZsdk_Uart_SaveOpusStart(decode_rate);
939 1013
940 //3、修改接收模式为传输opus 1014 //3、修改接收模式为传输opus
941 - JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION); 1015 + JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION);
942 1016
943 JZSDK_LOG_INFO("已完成打开opus传输处理\n"); 1017 JZSDK_LOG_INFO("已完成打开opus传输处理\n");
944 1018
@@ -959,7 +1033,7 @@ static int Uart_4G_RecvDeal_OpusTrans_transmission(char *SaveData, int size) @@ -959,7 +1033,7 @@ static int Uart_4G_RecvDeal_OpusTrans_transmission(char *SaveData, int size)
959 } 1033 }
960 /********* 1034 /*********
961 * 1035 *
962 - * opus传输 1036 + * opus结束传输
963 * 1037 *
964 * 1038 *
965 **********/ 1039 **********/
@@ -969,8 +1043,19 @@ static int Uart_4G_RecvDeal_OpusTrans_stop(char *getbuf) @@ -969,8 +1043,19 @@ static int Uart_4G_RecvDeal_OpusTrans_stop(char *getbuf)
969 //获取帧的序列号 1043 //获取帧的序列号
970 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1044 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
971 1045
  1046 + if (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION)
  1047 + {
  1048 + //回复操作失败
  1049 + JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
  1050 + JZSDK_LOG_ERROR("关闭opus结束传输失败,opus结束传输未开始,无法关闭");
  1051 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  1052 + }
  1053 +
  1054 +
972 JZsdk_Uart_SaveOpusStop(); 1055 JZsdk_Uart_SaveOpusStop();
973 1056
  1057 + JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP);
  1058 +
974 JZSDK_LOG_INFO("结束opus传输处理\n"); 1059 JZSDK_LOG_INFO("结束opus传输处理\n");
975 1060
976 //回复操作成功 1061 //回复操作成功
@@ -988,6 +1073,15 @@ static int Uart_4G_RecvDeal_OpusPlay(char *getbuf) @@ -988,6 +1073,15 @@ static int Uart_4G_RecvDeal_OpusPlay(char *getbuf)
988 //获取帧的序列号 1073 //获取帧的序列号
989 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1074 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
990 1075
  1076 + T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
  1077 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  1078 + {
  1079 + //回复操作失败
  1080 + JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
  1081 + JZSDK_LOG_ERROR("opus播放失败,存在传输模式打开中");
  1082 + return ret;
  1083 + }
  1084 +
991 JZsdk_Uart_Opus_PlayFixedFile(UART_4G); 1085 JZsdk_Uart_Opus_PlayFixedFile(UART_4G);
992 1086
993 //回复操作成功 1087 //回复操作成功
@@ -1002,14 +1096,23 @@ static int Uart_4G_RecvDeal_OpusPlay(char *getbuf) @@ -1002,14 +1096,23 @@ static int Uart_4G_RecvDeal_OpusPlay(char *getbuf)
1002 * 1096 *
1003 * 1097 *
1004 **********/ 1098 **********/
1005 -static int Uart_4G_RecvDeal_Opus_RealTimeVoice_start(char *getbuf) 1099 +static T_JZsdkReturnCode Uart_4G_RecvDeal_Opus_RealTimeVoice_start(char *getbuf)
1006 { 1100 {
1007 JZSDK_LOG_INFO("开启opus实时喊话功能\n"); 1101 JZSDK_LOG_INFO("开启opus实时喊话功能\n");
1008 //获取帧的序列号 1102 //获取帧的序列号
1009 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1103 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
1010 1104
  1105 + T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide();
  1106 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  1107 + {
  1108 + //回复操作失败
  1109 + JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
  1110 + JZSDK_LOG_ERROR("开启opus实时喊话失败");
  1111 + return ret;
  1112 + }
  1113 +
1011 //1、修改接收模式 1114 //1、修改接收模式
1012 - JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION); 1115 + JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION);
1013 1116
1014 //2、获取码率倍率 默认8k*1倍 1117 //2、获取码率倍率 默认8k*1倍
1015 int RateMagnification = (int)getbuf[9]; 1118 int RateMagnification = (int)getbuf[9];
@@ -1055,8 +1158,16 @@ static int Uart_4G_RecvDeal_Opus_RealTimeVoice_stop(char *getbuf) @@ -1055,8 +1158,16 @@ static int Uart_4G_RecvDeal_Opus_RealTimeVoice_stop(char *getbuf)
1055 //获取帧的序列号 1158 //获取帧的序列号
1056 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1159 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
1057 1160
  1161 + if (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION)
  1162 + {
  1163 + //回复操作失败
  1164 + JZsdk_Uart_SendDeal_Reply_Failure(UART_4G, FrameSequence);
  1165 + JZSDK_LOG_ERROR("关闭opus实时语音发送功能失败,opus实时语音发送功能未开始,无法关闭");
  1166 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  1167 + }
  1168 +
1058 //1、修改接收模式 1169 //1、修改接收模式
1059 - JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP); 1170 + JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP);
1060 1171
1061 //2、关闭实时语音模式 1172 //2、关闭实时语音模式
1062 JZsdk_Uart_RealTimeVoiceClose(); 1173 JZsdk_Uart_RealTimeVoiceClose();
@@ -1319,7 +1430,7 @@ static int Uart_4G_RecvDeal_SearchLight_SubscriptionControl(char *getbuf) @@ -1319,7 +1430,7 @@ static int Uart_4G_RecvDeal_SearchLight_SubscriptionControl(char *getbuf)
1319 **********/ 1430 **********/
1320 static int Uart_4G_RecvDeal_CheckStatus_SerialNumber(char *getbuf) 1431 static int Uart_4G_RecvDeal_CheckStatus_SerialNumber(char *getbuf)
1321 { 1432 {
1322 - JZSDK_LOG_INFO("消息订阅控制\n"); 1433 + JZSDK_LOG_INFO("查询产品序列号\n");
1323 //获取帧的序列号 1434 //获取帧的序列号
1324 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1435 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
1325 1436
@@ -1794,7 +1905,7 @@ static int Uart_4G_RecvDeal_GimbalLinkageControl(char *getbuf) @@ -1794,7 +1905,7 @@ static int Uart_4G_RecvDeal_GimbalLinkageControl(char *getbuf)
1794 **********/ 1905 **********/
1795 static int Uart_4G_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf) 1906 static int Uart_4G_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
1796 { 1907 {
1797 - JZSDK_LOG_INFO("收到查询是否开启云台联动\n"); 1908 + JZSDK_LOG_INFO("收到查询是否开启云台联动");
1798 1909
1799 //获取帧的序列号 1910 //获取帧的序列号
1800 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1911 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
@@ -1803,6 +1914,47 @@ static int Uart_4G_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf) @@ -1803,6 +1914,47 @@ static int Uart_4G_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
1803 JZsdk_Uart_Checkstatus_GimbalLinkage(UART_4G, FrameSequence); 1914 JZsdk_Uart_Checkstatus_GimbalLinkage(UART_4G, FrameSequence);
1804 } 1915 }
1805 1916
  1917 +static int Uart_4G_RecvDeal_UartBitrateChange(char *getbuf)
  1918 +{
  1919 + JZSDK_LOG_INFO("收到串口比特率修改");
  1920 +
  1921 + //获取帧的序列号
  1922 + int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
  1923 +
  1924 + //修改比特率
  1925 + int BitRateChoose = getbuf[10];
  1926 + int BitRate;
  1927 +
  1928 + switch (BitRateChoose)
  1929 + {
  1930 + case 1:
  1931 + BitRate = 115200;
  1932 + break;
  1933 +
  1934 + case 2:
  1935 + BitRate = 230400;
  1936 + break;
  1937 +
  1938 + case 3:
  1939 + BitRate = 460800;
  1940 + break;
  1941 +
  1942 + case 4:
  1943 + BitRate = 921600;
  1944 + break;
  1945 +
  1946 + case 5:
  1947 + BitRate = 1000000;
  1948 + break;
  1949 +
  1950 + default:
  1951 + BitRate = 115200;
  1952 + break;
  1953 + }
  1954 +
  1955 + JZsdk_Uart_BitRateChange(UART_4G, BitRate);
  1956 +}
  1957 +
1806 /******************************************************************************************************** 1958 /********************************************************************************************************
1807 ********* ********| 1959 ********* ********|
1808 ********* ********| 1960 ********* ********|
@@ -1938,7 +2090,7 @@ static int Uart_4G_RecvDeal_OperationFailed(char *getbuf) @@ -1938,7 +2090,7 @@ static int Uart_4G_RecvDeal_OperationFailed(char *getbuf)
1938 *********************************************************************************************************/ 2090 *********************************************************************************************************/
1939 int Uart_4G_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int len) 2091 int Uart_4G_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int len)
1940 { 2092 {
1941 - JZSDK_LOG_INFO("串口设备4g,接受到的模式为:%x",Receive_mode); 2093 + JZSDK_LOG_INFO("串口设备4G,接受到的模式为:%x",Receive_mode);
1942 switch (Receive_mode) 2094 switch (Receive_mode)
1943 { 2095 {
1944 /******************************************************************************************************************************* 2096 /*******************************************************************************************************************************
@@ -2345,6 +2497,12 @@ int Uart_4G_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int len) @@ -2345,6 +2497,12 @@ int Uart_4G_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int len)
2345 return 0; 2497 return 0;
2346 break; 2498 break;
2347 2499
  2500 + //串口比特率修改
  2501 + case JZ_INSCODE_6AFRAME_UART_BITRATE_CHANGE:
  2502 + Uart_4G_RecvDeal_UartBitrateChange(getdata);
  2503 + return 0;
  2504 + break;
  2505 +
2348 /******************************************************************************************************************************* 2506 /*******************************************************************************************************************************
2349 * 2507 *
2350 * 6B类部分 2508 * 6B类部分
@@ -2408,182 +2566,6 @@ int Uart_4G_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int len) @@ -2408,182 +2566,6 @@ int Uart_4G_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int len)
2408 ********* ********| 2566 ********* ********|
2409 ********* ********| 2567 ********* ********|
2410 *********************************************************************************************************/ 2568 *********************************************************************************************************/
2411 -static int Uart_4G_RecvDeal_RecvTransmission_CharmDeal(char* getbuf, int len, int flag)  
2412 -{  
2413 - int data_len = 0; //剩余数据长度  
2414 -  
2415 - /******************************  
2416 - *  
2417 - * 如果当前为传输opus文件的状态  
2418 - *  
2419 - * ***************************/  
2420 - if (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION)  
2421 - {  
2422 - //如果 传过来的帧为关闭传输opus  
2423 - if (flag == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)  
2424 - {  
2425 - //返回 关闭传输opus帧  
2426 - return JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;  
2427 - }  
2428 -  
2429 - //要是回来的帧最后藏着结束帧  
2430 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)  
2431 - {  
2432 - //把前面的还有剩的数据处理掉  
2433 - data_len = len - 12;  
2434 - Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);  
2435 -  
2436 - //返回 关闭传输opus帧  
2437 - return JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;  
2438 - }  
2439 -  
2440 - //要是回来的帧最后藏着播放帧  
2441 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_PLAY)  
2442 - {  
2443 - //说明 还藏着结束帧  
2444 -  
2445 - //先把前面的还有剩的数据处理掉  
2446 - data_len = len - 24;  
2447 - Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);  
2448 -  
2449 - //处理结束帧  
2450 - if (JZsdk_FrameComparsion(getbuf + len - 24, 12) == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)  
2451 - {  
2452 - UART_4G_Receive_mode = JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;  
2453 - Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, len);  
2454 - }  
2455 -  
2456 - //返回播放帧  
2457 - return JZ_INSCODE_5AFRAME_OPUS_PLAY;  
2458 - }  
2459 -  
2460 - //都没有 继续传输状态  
2461 - return JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION;  
2462 - }  
2463 -  
2464 - /******************************  
2465 - *  
2466 - * 如果当前为传输opus实时语音的状态  
2467 - *  
2468 - * ***************************/  
2469 - //如果 如果处于传输实时语音模式 且 传过来的关闭语音帧  
2470 - if (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION)  
2471 - {  
2472 - //如果 传过来的帧为关闭实时语音  
2473 - if (flag == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP)  
2474 - {  
2475 - //返回 关闭实时语音  
2476 - return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP;  
2477 - }  
2478 -  
2479 - //要是回来的帧最后藏着结束帧  
2480 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP)  
2481 - {  
2482 - //把前面的还有剩的数据处理掉  
2483 - data_len = len - 12;  
2484 - Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);  
2485 -  
2486 - //返回 关闭实时语音  
2487 - return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP;  
2488 - }  
2489 -  
2490 - //都没有 继续传输状态  
2491 - return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION;  
2492 - }  
2493 -  
2494 - /******************************  
2495 - *  
2496 - * 如果当前为传输mp2实时语音的状态  
2497 - *  
2498 - * ***************************/  
2499 - //如果 如果处于传输实时语音模式 且 传过来的关闭语音帧  
2500 - if (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION)  
2501 - {  
2502 - //如果 传过来的帧为关闭实时语音  
2503 - if (flag == JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP)  
2504 - {  
2505 - //返回 关闭实时语音  
2506 - return JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP;  
2507 - }  
2508 -  
2509 - //要是回来的帧最后藏着结束帧  
2510 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP)  
2511 - {  
2512 - //把前面的还有剩的数据处理掉  
2513 - data_len = len - 12;  
2514 - Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);  
2515 -  
2516 - //返回 关闭实时语音  
2517 - return JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP;  
2518 - }  
2519 -  
2520 - //都没有 继续传输状态  
2521 - return JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION;  
2522 - }  
2523 -  
2524 - /******************************  
2525 - *  
2526 - * 如果当前为传输音频文件的状态  
2527 - *  
2528 - * ***************************/  
2529 - //如果 如果处于传输实时语音模式 且 传过来的关闭语音帧  
2530 - if (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION)  
2531 - {  
2532 - //如果 传过来的帧为关闭实时语音  
2533 - if (flag == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP)  
2534 - {  
2535 - //返回 关闭实时语音  
2536 - return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP;  
2537 - }  
2538 -  
2539 - //要是回来的帧最后藏着结束帧  
2540 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP)  
2541 - {  
2542 - //把前面的还有剩的数据处理掉  
2543 - data_len = len - 12;  
2544 - Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);  
2545 -  
2546 - //返回 关闭实时语音  
2547 - return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP;  
2548 - }  
2549 -  
2550 - //都没有 继续传输状态  
2551 - return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION;  
2552 - }  
2553 -  
2554 - /******************************  
2555 - *  
2556 - * 如果当前为传输TTS的状态  
2557 - *  
2558 - * ***************************/  
2559 - //如果 如果处于传输TTS模式 且 传过来的关闭TTS帧  
2560 - if (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)  
2561 - {  
2562 - //如果 传过来的帧为关闭TTS  
2563 - if (flag == JZ_INSCODE_5AFRAME_TTS_TRANS_STOP)  
2564 - {  
2565 - //返回 关闭TTS  
2566 - return JZ_INSCODE_5AFRAME_TTS_TRANS_STOP;  
2567 - }  
2568 -  
2569 - //要是回来的帧最后藏着结束帧  
2570 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_TTS_TRANS_STOP)  
2571 - {  
2572 - //把前面的还有剩的数据处理掉  
2573 - data_len = len - 12;  
2574 - Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, data_len);  
2575 -  
2576 - //返回 关闭TTS  
2577 - return JZ_INSCODE_5AFRAME_TTS_TRANS_STOP;  
2578 - }  
2579 -  
2580 - //都没有 继续传输状态  
2581 - return JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION;  
2582 - }  
2583 -  
2584 - // 以上的帧都不是  
2585 - return JZ_ERROR_SYSTEM_FRAME_ERROR;  
2586 -}  
2587 2569
2588 2570
2589 /******************************************************************************************************** 2571 /********************************************************************************************************
@@ -2602,42 +2584,41 @@ static int Uart_4G_RecvDeal_RecvTransmission_CharmDeal(char* getbuf, int len, in @@ -2602,42 +2584,41 @@ static int Uart_4G_RecvDeal_RecvTransmission_CharmDeal(char* getbuf, int len, in
2602 2584
2603 int JZsdk_Uart_RecvDeal_CharmDeal_Uart_4G(unsigned char *getbuf, int len) 2585 int JZsdk_Uart_RecvDeal_CharmDeal_Uart_4G(unsigned char *getbuf, int len)
2604 { 2586 {
2605 - //1、不进行切割处理 2587 + //已经进行了切割预处理
2606 2588
2607 - //2、进行指令帧对比,确认该帧的功能 2589 + //1、进行指令帧对比,确认该帧的功能
2608 int flag = JZsdk_FrameComparsion(getbuf, len); 2590 int flag = JZsdk_FrameComparsion(getbuf, len);
2609 2591
2610 - //3、进行回复帧对比,确认该帧的功能  
2611 -  
2612 - //4、如果传过来的是正常帧 且不处于传输过程,接收模式改变  
2613 - if ((flag != JZ_ERROR_SYSTEM_FRAME_ERROR )  
2614 - && (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式 2592 + //2、如果传过来的是正常帧
  2593 + if (flag != JZ_ERROR_SYSTEM_FRAME_ERROR )
  2594 + {
  2595 + Uart_4G_RecvDeal_RecvDeal(flag, getbuf, len);
  2596 + //如果不处于5大传输模式
  2597 + if ((UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
2615 && (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式 2598 && (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
2616 && (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式 2599 && (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
2617 && (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式 2600 && (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
2618 - && (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式  
2619 - {  
2620 - UART_4G_Receive_mode = flag;  
2621 - }  
2622 - //否则进入 传输过程 处理模式  
2623 - else  
2624 - {  
2625 - flag = Uart_4G_RecvDeal_RecvTransmission_CharmDeal(getbuf, len, flag);  
2626 - if (flag != JZ_ERROR_SYSTEM_FRAME_ERROR) 2601 + && (UART_4G_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式)
2627 { 2602 {
  2603 + //刷新模式
2628 UART_4G_Receive_mode = flag; 2604 UART_4G_Receive_mode = flag;
2629 } 2605 }
2630 - }  
2631 2606
2632 - //两次判断 flag的值都是JZ_ERROR_SYSTEM_FRAME_ERROR 说明真的不是帧  
2633 - if (flag == JZ_ERROR_SYSTEM_FRAME_ERROR)  
2634 - {  
2635 - UART_4G_Receive_mode = JZ_ERROR_SYSTEM_FRAME_ERROR;  
2636 } 2607 }
2637 2608
2638 - //4、根据2 放入接收处理函数 2609 + //否则 如果处于传输传输过程 处理模式 正常录入数据
  2610 + else if (flag == JZ_ERROR_SYSTEM_FRAME_ERROR
  2611 + && ((UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
  2612 + || (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
  2613 + || (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
  2614 + || (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
  2615 + || (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION))) //TTS传输模式)
  2616 + {
2639 Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, len); 2617 Uart_4G_RecvDeal_RecvDeal(UART_4G_Receive_mode, getbuf, len);
  2618 + }
2640 2619
  2620 + //否则直接丢弃
  2621 + return -1;
2641 } 2622 }
2642 2623
2643 /******************* 2624 /*******************
@@ -2646,9 +2627,28 @@ int JZsdk_Uart_RecvDeal_CharmDeal_Uart_4G(unsigned char *getbuf, int len) @@ -2646,9 +2627,28 @@ int JZsdk_Uart_RecvDeal_CharmDeal_Uart_4G(unsigned char *getbuf, int len)
2646 * ps : 仅在开启语音传送和 文件传输时会启用该函数 2627 * ps : 仅在开启语音传送和 文件传输时会启用该函数
2647 * 2628 *
2648 * ****************/ 2629 * ****************/
2649 -int JZsdk_Uart_RecvDeal_Set_UART_4G_Receive_mode(int value) 2630 +int JZsdk_Uart_RecvDeal_Set_UART_4G_ReceiveMode(int value)
2650 { 2631 {
2651 - JZSDK_LOG_INFO("串口设备4g,二次修改接收模式%x\n",value); 2632 + JZSDK_LOG_INFO("串口设备4G,二次修改接收模式%x\n",value);
2652 UART_4G_Receive_mode = value; 2633 UART_4G_Receive_mode = value;
2653 return 0; 2634 return 0;
2654 } 2635 }
  2636 +
  2637 +/*
  2638 +
  2639 +
  2640 +
  2641 +*/
  2642 +static T_JZsdkReturnCode JZsdk_Uart_RecvDeal_UART_4G_TransmodeDecide()
  2643 +{
  2644 + if ((UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
  2645 + || (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
  2646 + || (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
  2647 + || (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
  2648 + || (UART_4G_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式)
  2649 + {
  2650 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  2651 + }
  2652 +
  2653 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  2654 +}
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 7
8 #include "JZsdk_Uart_Send/JZsdk_Uart_Send.h" 8 #include "JZsdk_Uart_Send/JZsdk_Uart_Send.h"
9 #include "JZsdk_Uart_Output.h" 9 #include "JZsdk_Uart_Output.h"
  10 +#include "JZsdk_Uart_Input.h"
10 11
11 #include "version_choose.h" 12 #include "version_choose.h"
12 13
@@ -68,7 +69,7 @@ static int Uart_DEV1_RecvDeal_AskForConnect(char *getbuf) @@ -68,7 +69,7 @@ static int Uart_DEV1_RecvDeal_AskForConnect(char *getbuf)
68 **********/ 69 **********/
69 static T_JZsdkReturnCode Uart_DEV1_RecvDeal_RealTimeMP2_start(char *getbuf) 70 static T_JZsdkReturnCode Uart_DEV1_RecvDeal_RealTimeMP2_start(char *getbuf)
70 { 71 {
71 - JZSDK_LOG_INFO("开启MP2实时喊话功能\n"); 72 + JZSDK_LOG_DEBUG("开启MP2实时喊话功能\n");
72 T_JZsdkReturnCode ret; 73 T_JZsdkReturnCode ret;
73 74
74 //获取帧的序列号 75 //获取帧的序列号
@@ -137,7 +138,7 @@ static int Uart_DEV1_RecvDeal_RealTimeMP2_transmission(char *getdata, int len) @@ -137,7 +138,7 @@ static int Uart_DEV1_RecvDeal_RealTimeMP2_transmission(char *getdata, int len)
137 **********/ 138 **********/
138 static T_JZsdkReturnCode Uart_DEV1_RecvDeal_RealTimeMP2_stop(char *getbuf) 139 static T_JZsdkReturnCode Uart_DEV1_RecvDeal_RealTimeMP2_stop(char *getbuf)
139 { 140 {
140 - JZSDK_LOG_INFO("关闭MP2实时喊话功能\n"); 141 + JZSDK_LOG_DEBUG("关闭MP2实时喊话功能\n");
141 T_JZsdkReturnCode ret; 142 T_JZsdkReturnCode ret;
142 143
143 //获取帧的序列号 144 //获取帧的序列号
@@ -1072,6 +1073,15 @@ static int Uart_DEV1_RecvDeal_OpusPlay(char *getbuf) @@ -1072,6 +1073,15 @@ static int Uart_DEV1_RecvDeal_OpusPlay(char *getbuf)
1072 //获取帧的序列号 1073 //获取帧的序列号
1073 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1074 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
1074 1075
  1076 + T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV1_TransmodeDecide();
  1077 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  1078 + {
  1079 + //回复操作失败
  1080 + JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_1, FrameSequence);
  1081 + JZSDK_LOG_ERROR("opus播放失败,存在传输模式打开中");
  1082 + return ret;
  1083 + }
  1084 +
1075 JZsdk_Uart_Opus_PlayFixedFile(UART_DEV_1); 1085 JZsdk_Uart_Opus_PlayFixedFile(UART_DEV_1);
1076 1086
1077 //回复操作成功 1087 //回复操作成功
@@ -1420,7 +1430,7 @@ static int Uart_DEV1_RecvDeal_SearchLight_SubscriptionControl(char *getbuf) @@ -1420,7 +1430,7 @@ static int Uart_DEV1_RecvDeal_SearchLight_SubscriptionControl(char *getbuf)
1420 **********/ 1430 **********/
1421 static int Uart_DEV1_RecvDeal_CheckStatus_SerialNumber(char *getbuf) 1431 static int Uart_DEV1_RecvDeal_CheckStatus_SerialNumber(char *getbuf)
1422 { 1432 {
1423 - JZSDK_LOG_INFO("消息订阅控制\n"); 1433 + JZSDK_LOG_INFO("查询产品序列号\n");
1424 //获取帧的序列号 1434 //获取帧的序列号
1425 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1435 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
1426 1436
@@ -1572,6 +1582,26 @@ static int Uart_DEV1_RecvDeal_CheckStatus_WarningLightColor(char *getbuf) @@ -1572,6 +1582,26 @@ static int Uart_DEV1_RecvDeal_CheckStatus_WarningLightColor(char *getbuf)
1572 * 设备相关 1582 * 设备相关
1573 * 1583 *
1574 * *******************************************************************************************************************************/ 1584 * *******************************************************************************************************************************/
  1585 +/*********
  1586 + *
  1587 + * 收到连接回复帧
  1588 + *
  1589 +**********/
  1590 +static int Uart_DEV1_RecvDeal_ObtainConnectFrame(char *getbuf)
  1591 +{
  1592 + JZSDK_LOG_INFO("收到连接回复帧\n");
  1593 +
  1594 + //获取帧的序列号
  1595 + int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
  1596 +
  1597 + //1、通过数据帧2,获取值
  1598 + int value = getbuf[9];
  1599 +
  1600 + //2、发送到本地处理
  1601 + JZsdl_Uart_ObtainConnectFrame(UART_DEV_1, value);
  1602 +
  1603 +}
  1604 +
1575 1605
1576 /******************************************************************************************************************************* 1606 /*******************************************************************************************************************************
1577 * 1607 *
@@ -1895,7 +1925,7 @@ static int Uart_DEV1_RecvDeal_GimbalLinkageControl(char *getbuf) @@ -1895,7 +1925,7 @@ static int Uart_DEV1_RecvDeal_GimbalLinkageControl(char *getbuf)
1895 **********/ 1925 **********/
1896 static int Uart_DEV1_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf) 1926 static int Uart_DEV1_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
1897 { 1927 {
1898 - JZSDK_LOG_INFO("收到查询是否开启云台联动\n"); 1928 + JZSDK_LOG_INFO("收到查询是否开启云台联动");
1899 1929
1900 //获取帧的序列号 1930 //获取帧的序列号
1901 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1931 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
@@ -1904,6 +1934,47 @@ static int Uart_DEV1_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf) @@ -1904,6 +1934,47 @@ static int Uart_DEV1_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
1904 JZsdk_Uart_Checkstatus_GimbalLinkage(UART_DEV_1, FrameSequence); 1934 JZsdk_Uart_Checkstatus_GimbalLinkage(UART_DEV_1, FrameSequence);
1905 } 1935 }
1906 1936
  1937 +static int Uart_DEV1_RecvDeal_UartBitrateChange(char *getbuf)
  1938 +{
  1939 + JZSDK_LOG_INFO("收到串口比特率修改");
  1940 +
  1941 + //获取帧的序列号
  1942 + int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
  1943 +
  1944 + //修改比特率
  1945 + int BitRateChoose = getbuf[10];
  1946 + int BitRate;
  1947 +
  1948 + switch (BitRateChoose)
  1949 + {
  1950 + case 1:
  1951 + BitRate = 115200;
  1952 + break;
  1953 +
  1954 + case 2:
  1955 + BitRate = 230400;
  1956 + break;
  1957 +
  1958 + case 3:
  1959 + BitRate = 460800;
  1960 + break;
  1961 +
  1962 + case 4:
  1963 + BitRate = 921600;
  1964 + break;
  1965 +
  1966 + case 5:
  1967 + BitRate = 1000000;
  1968 + break;
  1969 +
  1970 + default:
  1971 + BitRate = 115200;
  1972 + break;
  1973 + }
  1974 +
  1975 + JZsdk_Uart_BitRateChange(UART_DEV_1, BitRate);
  1976 +}
  1977 +
1907 /******************************************************************************************************** 1978 /********************************************************************************************************
1908 ********* ********| 1979 ********* ********|
1909 ********* ********| 1980 ********* ********|
@@ -2367,6 +2438,11 @@ int Uart_DEV1_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le @@ -2367,6 +2438,11 @@ int Uart_DEV1_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le
2367 * 5B类部分 2438 * 5B类部分
2368 * 2439 *
2369 * *******************************************************************************************************************************/ 2440 * *******************************************************************************************************************************/
  2441 + //连接回复
  2442 + case JZ_INSCODE_5BFRAME_INITIATECONNECT:
  2443 + Uart_DEV1_RecvDeal_ObtainConnectFrame(getdata);
  2444 + break;
  2445 +
2370 //回复灯光频率 2446 //回复灯光频率
2371 case JZ_INSCODE_5BFRAME_CHECKSTATUS_SEARCHLIGHT_FREQUENCY: 2447 case JZ_INSCODE_5BFRAME_CHECKSTATUS_SEARCHLIGHT_FREQUENCY:
2372 Uart_DEV1_RecvDeal_ObtainSearchLight_Frequency(getdata); 2448 Uart_DEV1_RecvDeal_ObtainSearchLight_Frequency(getdata);
@@ -2446,6 +2522,12 @@ int Uart_DEV1_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le @@ -2446,6 +2522,12 @@ int Uart_DEV1_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le
2446 return 0; 2522 return 0;
2447 break; 2523 break;
2448 2524
  2525 + //串口比特率修改
  2526 + case JZ_INSCODE_6AFRAME_UART_BITRATE_CHANGE:
  2527 + Uart_DEV1_RecvDeal_UartBitrateChange(getdata);
  2528 + return 0;
  2529 + break;
  2530 +
2449 /******************************************************************************************************************************* 2531 /*******************************************************************************************************************************
2450 * 2532 *
2451 * 6B类部分 2533 * 6B类部分
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 7
8 #include "JZsdk_Uart_Send/JZsdk_Uart_Send.h" 8 #include "JZsdk_Uart_Send/JZsdk_Uart_Send.h"
9 #include "JZsdk_Uart_Output.h" 9 #include "JZsdk_Uart_Output.h"
  10 +#include "JZsdk_Uart_Input.h"
10 11
11 #include "version_choose.h" 12 #include "version_choose.h"
12 13
@@ -15,7 +16,8 @@ int UART_DEV2_Receive_mode = 0; @@ -15,7 +16,8 @@ int UART_DEV2_Receive_mode = 0;
15 static char TTS_Recv_buffer[1009]; //TTS接收数据缓冲区 1000中文 + 3个字中文的防溢出区 16 static char TTS_Recv_buffer[1009]; //TTS接收数据缓冲区 1000中文 + 3个字中文的防溢出区
16 static int TTS_Recv_buffer_length = 0; 17 static int TTS_Recv_buffer_length = 0;
17 18
18 -int JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(int value); 19 +int JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(int value);
  20 +static T_JZsdkReturnCode JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
19 21
20 /******************************************************************************************************** 22 /********************************************************************************************************
21 ********* ********| 23 ********* ********|
@@ -65,7 +67,7 @@ static int Uart_DEV2_RecvDeal_AskForConnect(char *getbuf) @@ -65,7 +67,7 @@ static int Uart_DEV2_RecvDeal_AskForConnect(char *getbuf)
65 * 67 *
66 * 68 *
67 **********/ 69 **********/
68 -static int Uart_DEV2_RecvDeal_RealTimeMP2_start(char *getbuf) 70 +static T_JZsdkReturnCode Uart_DEV2_RecvDeal_RealTimeMP2_start(char *getbuf)
69 { 71 {
70 JZSDK_LOG_INFO("开启MP2实时喊话功能\n"); 72 JZSDK_LOG_INFO("开启MP2实时喊话功能\n");
71 T_JZsdkReturnCode ret; 73 T_JZsdkReturnCode ret;
@@ -73,8 +75,18 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_start(char *getbuf) @@ -73,8 +75,18 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_start(char *getbuf)
73 //获取帧的序列号 75 //获取帧的序列号
74 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 76 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
75 77
  78 + ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
  79 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  80 + {
  81 + //回复操作失败
  82 + JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
  83 + JZSDK_LOG_ERROR("开启MP2实时喊话功能失败\n");
  84 +
  85 + return ret;
  86 + }
  87 +
76 //1、修改接收模式 88 //1、修改接收模式
77 - JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION); 89 + JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION);
78 90
79 //2、获取码率倍率 默认8k 91 //2、获取码率倍率 默认8k
80 int RateMagnification = (int)getbuf[9]; 92 int RateMagnification = (int)getbuf[9];
@@ -124,7 +136,7 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_transmission(char *getdata, int len) @@ -124,7 +136,7 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_transmission(char *getdata, int len)
124 * 136 *
125 * 137 *
126 **********/ 138 **********/
127 -static int Uart_DEV2_RecvDeal_RealTimeMP2_stop(char *getbuf) 139 +static T_JZsdkReturnCode Uart_DEV2_RecvDeal_RealTimeMP2_stop(char *getbuf)
128 { 140 {
129 JZSDK_LOG_INFO("关闭MP2实时喊话功能\n"); 141 JZSDK_LOG_INFO("关闭MP2实时喊话功能\n");
130 T_JZsdkReturnCode ret; 142 T_JZsdkReturnCode ret;
@@ -132,8 +144,17 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_stop(char *getbuf) @@ -132,8 +144,17 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_stop(char *getbuf)
132 //获取帧的序列号 144 //获取帧的序列号
133 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 145 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
134 146
  147 + if (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION)
  148 + {
  149 + //回复操作失败
  150 + JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
  151 + JZSDK_LOG_ERROR("操作失败,mp2传输未开始,无法关闭");
  152 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  153 + }
  154 +
  155 +
135 //1、修改接收模式 156 //1、修改接收模式
136 - JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP); 157 + JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP);
137 158
138 //2、关闭实时MP2模式 159 //2、关闭实时MP2模式
139 ret = JZsdk_Uart_RealTimeMP2_Close(); 160 ret = JZsdk_Uart_RealTimeMP2_Close();
@@ -155,12 +176,21 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_stop(char *getbuf) @@ -155,12 +176,21 @@ static int Uart_DEV2_RecvDeal_RealTimeMP2_stop(char *getbuf)
155 * 176 *
156 * 177 *
157 **********/ 178 **********/
158 -static int Uart_DEV2_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len) 179 +static T_JZsdkReturnCode Uart_DEV2_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
159 { 180 {
160 JZSDK_LOG_INFO("开始传输的音频文件保存\n"); 181 JZSDK_LOG_INFO("开始传输的音频文件保存\n");
161 //获取帧的序列号 182 //获取帧的序列号
162 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 183 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
163 184
  185 + T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
  186 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  187 + {
  188 + //回复操作失败
  189 + JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
  190 + JZSDK_LOG_ERROR("开始传输的音频文件保存失败");
  191 + return ret;
  192 + }
  193 +
164 //1、处理帧长度,获取文件名长度 194 //1、处理帧长度,获取文件名长度
165 int FileNameLen = ((int)getbuf[3] << 8) + (int)getbuf[4] - 2 - 9; 195 int FileNameLen = ((int)getbuf[3] << 8) + (int)getbuf[4] - 2 - 9;
166 196
@@ -170,7 +200,7 @@ static int Uart_DEV2_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len) @@ -170,7 +200,7 @@ static int Uart_DEV2_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
170 memcpy(FileName, &getbuf[9], FileNameLen); 200 memcpy(FileName, &getbuf[9], FileNameLen);
171 JZSDK_LOG_INFO("保存的文件名为%s",FileName); 201 JZSDK_LOG_INFO("保存的文件名为%s",FileName);
172 202
173 - T_JZsdkReturnCode ret = JZsdk_Uart_SaveAudioFileStart(FileName); 203 + ret = JZsdk_Uart_SaveAudioFileStart(FileName);
174 if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS) 204 if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
175 { 205 {
176 JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence); 206 JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
@@ -178,7 +208,7 @@ static int Uart_DEV2_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len) @@ -178,7 +208,7 @@ static int Uart_DEV2_RecvDeal_SaveAudioFileTrans_start(char *getbuf, int len)
178 } 208 }
179 209
180 //3、调整接收模式为音频文件传输 210 //3、调整接收模式为音频文件传输
181 - JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION); 211 + JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION);
182 212
183 //4、回复操作成功 213 //4、回复操作成功
184 JZsdk_Uart_SendDeal_Reply_Sucesss(UART_DEV_2, FrameSequence); 214 JZsdk_Uart_SendDeal_Reply_Sucesss(UART_DEV_2, FrameSequence);
@@ -207,9 +237,20 @@ static int Uart_DEV2_RecvDeal_SaveAudioFileTrans_stop(char *getbuf) @@ -207,9 +237,20 @@ static int Uart_DEV2_RecvDeal_SaveAudioFileTrans_stop(char *getbuf)
207 //获取帧的序列号 237 //获取帧的序列号
208 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 238 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
209 239
  240 + if (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION)
  241 + {
  242 + //回复操作失败
  243 + JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
  244 + JZSDK_LOG_ERROR("关闭音频文件上传失败,音频文件上传未开始,无法关闭");
  245 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  246 + }
  247 +
210 //1、保存音频数据 248 //1、保存音频数据
211 JZsdk_Uart_SaveAudioFileStop(); 249 JZsdk_Uart_SaveAudioFileStop();
212 250
  251 + //3、调整接收模式为音频文件传输
  252 + JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP);
  253 +
213 //2、回复操作成功 254 //2、回复操作成功
214 JZsdk_Uart_SendDeal_Reply_Sucesss(UART_DEV_2, FrameSequence); 255 JZsdk_Uart_SendDeal_Reply_Sucesss(UART_DEV_2, FrameSequence);
215 } 256 }
@@ -849,12 +890,21 @@ static int Uart_DEV2_RecvDeal_TTS_SetSpeed(char *getbuf) @@ -849,12 +890,21 @@ static int Uart_DEV2_RecvDeal_TTS_SetSpeed(char *getbuf)
849 // 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x03 0x00 0x00 0x23 开始TTS发送 890 // 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x03 0x00 0x00 0x23 开始TTS发送
850 // 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX TTS数据 891 // 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX 0xXX TTS数据
851 // 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x04 0x00 0x00 0x23 结束TTS发送 892 // 0x5A 0x5A 0x77 0x00 0x0c 0x00 0x00 0x57 0x04 0x00 0x00 0x23 结束TTS发送
852 -static int Uart_DEV2_RecvDeal_TTS_Trans_start(char *getbuf) 893 +static T_JZsdkReturnCode Uart_DEV2_RecvDeal_TTS_Trans_start(char *getbuf)
853 { 894 {
854 JZSDK_LOG_INFO("tts开始传输"); 895 JZSDK_LOG_INFO("tts开始传输");
855 //获取帧的序列号 896 //获取帧的序列号
856 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 897 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
857 898
  899 + T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
  900 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  901 + {
  902 + //回复操作失败
  903 + JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
  904 + JZSDK_LOG_ERROR("tts开始传输失败");
  905 + return ret;
  906 + }
  907 +
858 //1、重置缓冲区 908 //1、重置缓冲区
859 memset(TTS_Recv_buffer, 0, 1009); 909 memset(TTS_Recv_buffer, 0, 1009);
860 910
@@ -862,7 +912,7 @@ static int Uart_DEV2_RecvDeal_TTS_Trans_start(char *getbuf) @@ -862,7 +912,7 @@ static int Uart_DEV2_RecvDeal_TTS_Trans_start(char *getbuf)
862 TTS_Recv_buffer_length = 0; 912 TTS_Recv_buffer_length = 0;
863 913
864 //3、将接收模式设置为接收TTS数据模式 914 //3、将接收模式设置为接收TTS数据模式
865 - JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION); 915 + JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION);
866 916
867 //回复操作成功 917 //回复操作成功
868 JZsdk_Uart_SendDeal_Reply_Sucesss(UART_DEV_2, FrameSequence); 918 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) @@ -897,17 +947,32 @@ static int Uart_DEV2_RecvDeal_TTS_Trans_transmission(char *getdata, int len)
897 * 947 *
898 * 948 *
899 **********/ 949 **********/
900 -static int Uart_DEV2_RecvDeal_TTS_Trans_stop(char *getbuf) 950 +static T_JZsdkReturnCode Uart_DEV2_RecvDeal_TTS_Trans_stop(char *getbuf)
901 { 951 {
902 JZSDK_LOG_INFO("tts传输结束"); 952 JZSDK_LOG_INFO("tts传输结束");
903 //获取帧的序列号 953 //获取帧的序列号
904 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 954 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
905 955
  956 + if (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)
  957 + {
  958 + JZSDK_LOG_INFO("未刷新文本,TTS播放%s",TTS_Recv_buffer);
  959 +
  960 + //3、播放TTS
  961 + JZsdk_Uart_TTS_Play(UART_DEV_2, TTS_Recv_buffer, TTS_Recv_buffer_length);
  962 +
  963 + //回复操作成功
  964 + JZsdk_Uart_SendDeal_Reply_Sucesss(UART_DEV_2, FrameSequence);
  965 +
  966 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  967 + }
906 968
907 //1、打印一次TTS文本 969 //1、打印一次TTS文本
908 JZSDK_LOG_INFO("TTS播放%s",TTS_Recv_buffer); 970 JZSDK_LOG_INFO("TTS播放%s",TTS_Recv_buffer);
909 971
910 - //2、播放TTS 972 + //2、将接收模式设置为关闭接收TTS
  973 + JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP);
  974 +
  975 + //3、播放TTS
911 JZsdk_Uart_TTS_Play(UART_DEV_2, TTS_Recv_buffer, TTS_Recv_buffer_length); 976 JZsdk_Uart_TTS_Play(UART_DEV_2, TTS_Recv_buffer, TTS_Recv_buffer_length);
912 977
913 //回复操作成功 978 //回复操作成功
@@ -921,12 +986,21 @@ static int Uart_DEV2_RecvDeal_TTS_Trans_stop(char *getbuf) @@ -921,12 +986,21 @@ static int Uart_DEV2_RecvDeal_TTS_Trans_stop(char *getbuf)
921 * 986 *
922 * 987 *
923 **********/ 988 **********/
924 -static int Uart_DEV2_RecvDeal_OpusTrans_start(char *getbuf) 989 +static T_JZsdkReturnCode Uart_DEV2_RecvDeal_OpusTrans_start(char *getbuf)
925 { 990 {
926 JZSDK_LOG_INFO("打开opus传输\n"); 991 JZSDK_LOG_INFO("打开opus传输\n");
927 //获取帧的序列号 992 //获取帧的序列号
928 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 993 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
929 994
  995 + T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
  996 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  997 + {
  998 + //回复操作失败
  999 + JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
  1000 + JZSDK_LOG_ERROR("打开opus传输失败");
  1001 + return ret;
  1002 + }
  1003 +
930 //1、获取解码比特率 1004 //1、获取解码比特率
931 int decode_rate = getbuf[9] * 8000; 1005 int decode_rate = getbuf[9] * 8000;
932 if(decode_rate == 0) 1006 if(decode_rate == 0)
@@ -938,7 +1012,7 @@ static int Uart_DEV2_RecvDeal_OpusTrans_start(char *getbuf) @@ -938,7 +1012,7 @@ static int Uart_DEV2_RecvDeal_OpusTrans_start(char *getbuf)
938 JZsdk_Uart_SaveOpusStart(decode_rate); 1012 JZsdk_Uart_SaveOpusStart(decode_rate);
939 1013
940 //3、修改接收模式为传输opus 1014 //3、修改接收模式为传输opus
941 - JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION); 1015 + JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION);
942 1016
943 JZSDK_LOG_INFO("已完成打开opus传输处理\n"); 1017 JZSDK_LOG_INFO("已完成打开opus传输处理\n");
944 1018
@@ -959,7 +1033,7 @@ static int Uart_DEV2_RecvDeal_OpusTrans_transmission(char *SaveData, int size) @@ -959,7 +1033,7 @@ static int Uart_DEV2_RecvDeal_OpusTrans_transmission(char *SaveData, int size)
959 } 1033 }
960 /********* 1034 /*********
961 * 1035 *
962 - * opus传输 1036 + * opus结束传输
963 * 1037 *
964 * 1038 *
965 **********/ 1039 **********/
@@ -969,8 +1043,19 @@ static int Uart_DEV2_RecvDeal_OpusTrans_stop(char *getbuf) @@ -969,8 +1043,19 @@ static int Uart_DEV2_RecvDeal_OpusTrans_stop(char *getbuf)
969 //获取帧的序列号 1043 //获取帧的序列号
970 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1044 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
971 1045
  1046 + if (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION)
  1047 + {
  1048 + //回复操作失败
  1049 + JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
  1050 + JZSDK_LOG_ERROR("关闭opus结束传输失败,opus结束传输未开始,无法关闭");
  1051 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  1052 + }
  1053 +
  1054 +
972 JZsdk_Uart_SaveOpusStop(); 1055 JZsdk_Uart_SaveOpusStop();
973 1056
  1057 + JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP);
  1058 +
974 JZSDK_LOG_INFO("结束opus传输处理\n"); 1059 JZSDK_LOG_INFO("结束opus传输处理\n");
975 1060
976 //回复操作成功 1061 //回复操作成功
@@ -988,6 +1073,15 @@ static int Uart_DEV2_RecvDeal_OpusPlay(char *getbuf) @@ -988,6 +1073,15 @@ static int Uart_DEV2_RecvDeal_OpusPlay(char *getbuf)
988 //获取帧的序列号 1073 //获取帧的序列号
989 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1074 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
990 1075
  1076 + T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
  1077 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  1078 + {
  1079 + //回复操作失败
  1080 + JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
  1081 + JZSDK_LOG_ERROR("opus播放失败,存在传输模式打开中");
  1082 + return ret;
  1083 + }
  1084 +
991 JZsdk_Uart_Opus_PlayFixedFile(UART_DEV_2); 1085 JZsdk_Uart_Opus_PlayFixedFile(UART_DEV_2);
992 1086
993 //回复操作成功 1087 //回复操作成功
@@ -1002,14 +1096,23 @@ static int Uart_DEV2_RecvDeal_OpusPlay(char *getbuf) @@ -1002,14 +1096,23 @@ static int Uart_DEV2_RecvDeal_OpusPlay(char *getbuf)
1002 * 1096 *
1003 * 1097 *
1004 **********/ 1098 **********/
1005 -static int Uart_DEV2_RecvDeal_Opus_RealTimeVoice_start(char *getbuf) 1099 +static T_JZsdkReturnCode Uart_DEV2_RecvDeal_Opus_RealTimeVoice_start(char *getbuf)
1006 { 1100 {
1007 JZSDK_LOG_INFO("开启opus实时喊话功能\n"); 1101 JZSDK_LOG_INFO("开启opus实时喊话功能\n");
1008 //获取帧的序列号 1102 //获取帧的序列号
1009 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1103 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
1010 1104
  1105 + T_JZsdkReturnCode ret = JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide();
  1106 + if (ret != JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS)
  1107 + {
  1108 + //回复操作失败
  1109 + JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
  1110 + JZSDK_LOG_ERROR("开启opus实时喊话失败");
  1111 + return ret;
  1112 + }
  1113 +
1011 //1、修改接收模式 1114 //1、修改接收模式
1012 - JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION); 1115 + JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION);
1013 1116
1014 //2、获取码率倍率 默认8k*1倍 1117 //2、获取码率倍率 默认8k*1倍
1015 int RateMagnification = (int)getbuf[9]; 1118 int RateMagnification = (int)getbuf[9];
@@ -1055,8 +1158,16 @@ static int Uart_DEV2_RecvDeal_Opus_RealTimeVoice_stop(char *getbuf) @@ -1055,8 +1158,16 @@ static int Uart_DEV2_RecvDeal_Opus_RealTimeVoice_stop(char *getbuf)
1055 //获取帧的序列号 1158 //获取帧的序列号
1056 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1159 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
1057 1160
  1161 + if (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION)
  1162 + {
  1163 + //回复操作失败
  1164 + JZsdk_Uart_SendDeal_Reply_Failure(UART_DEV_2, FrameSequence);
  1165 + JZSDK_LOG_ERROR("关闭opus实时语音发送功能失败,opus实时语音发送功能未开始,无法关闭");
  1166 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  1167 + }
  1168 +
1058 //1、修改接收模式 1169 //1、修改接收模式
1059 - JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP); 1170 + JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP);
1060 1171
1061 //2、关闭实时语音模式 1172 //2、关闭实时语音模式
1062 JZsdk_Uart_RealTimeVoiceClose(); 1173 JZsdk_Uart_RealTimeVoiceClose();
@@ -1319,7 +1430,7 @@ static int Uart_DEV2_RecvDeal_SearchLight_SubscriptionControl(char *getbuf) @@ -1319,7 +1430,7 @@ static int Uart_DEV2_RecvDeal_SearchLight_SubscriptionControl(char *getbuf)
1319 **********/ 1430 **********/
1320 static int Uart_DEV2_RecvDeal_CheckStatus_SerialNumber(char *getbuf) 1431 static int Uart_DEV2_RecvDeal_CheckStatus_SerialNumber(char *getbuf)
1321 { 1432 {
1322 - JZSDK_LOG_INFO("消息订阅控制\n"); 1433 + JZSDK_LOG_INFO("查询产品序列号\n");
1323 //获取帧的序列号 1434 //获取帧的序列号
1324 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1435 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
1325 1436
@@ -1794,7 +1905,7 @@ static int Uart_DEV2_RecvDeal_GimbalLinkageControl(char *getbuf) @@ -1794,7 +1905,7 @@ static int Uart_DEV2_RecvDeal_GimbalLinkageControl(char *getbuf)
1794 **********/ 1905 **********/
1795 static int Uart_DEV2_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf) 1906 static int Uart_DEV2_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
1796 { 1907 {
1797 - JZSDK_LOG_INFO("收到查询是否开启云台联动\n"); 1908 + JZSDK_LOG_INFO("收到查询是否开启云台联动");
1798 1909
1799 //获取帧的序列号 1910 //获取帧的序列号
1800 int FrameSequence = JZsdk_Get_FrameSequence(getbuf); 1911 int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
@@ -1803,6 +1914,47 @@ static int Uart_DEV2_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf) @@ -1803,6 +1914,47 @@ static int Uart_DEV2_RecvDeal_Checkstatus_GimbalLinkage(char *getbuf)
1803 JZsdk_Uart_Checkstatus_GimbalLinkage(UART_DEV_2, FrameSequence); 1914 JZsdk_Uart_Checkstatus_GimbalLinkage(UART_DEV_2, FrameSequence);
1804 } 1915 }
1805 1916
  1917 +static int Uart_DEV2_RecvDeal_UartBitrateChange(char *getbuf)
  1918 +{
  1919 + JZSDK_LOG_INFO("收到串口比特率修改");
  1920 +
  1921 + //获取帧的序列号
  1922 + int FrameSequence = JZsdk_Get_FrameSequence(getbuf);
  1923 +
  1924 + //修改比特率
  1925 + int BitRateChoose = getbuf[10];
  1926 + int BitRate;
  1927 +
  1928 + switch (BitRateChoose)
  1929 + {
  1930 + case 1:
  1931 + BitRate = 115200;
  1932 + break;
  1933 +
  1934 + case 2:
  1935 + BitRate = 230400;
  1936 + break;
  1937 +
  1938 + case 3:
  1939 + BitRate = 460800;
  1940 + break;
  1941 +
  1942 + case 4:
  1943 + BitRate = 921600;
  1944 + break;
  1945 +
  1946 + case 5:
  1947 + BitRate = 1000000;
  1948 + break;
  1949 +
  1950 + default:
  1951 + BitRate = 115200;
  1952 + break;
  1953 + }
  1954 +
  1955 + JZsdk_Uart_BitRateChange(UART_DEV_2, BitRate);
  1956 +}
  1957 +
1806 /******************************************************************************************************** 1958 /********************************************************************************************************
1807 ********* ********| 1959 ********* ********|
1808 ********* ********| 1960 ********* ********|
@@ -2345,6 +2497,12 @@ int Uart_DEV2_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le @@ -2345,6 +2497,12 @@ int Uart_DEV2_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le
2345 return 0; 2497 return 0;
2346 break; 2498 break;
2347 2499
  2500 + //串口比特率修改
  2501 + case JZ_INSCODE_6AFRAME_UART_BITRATE_CHANGE:
  2502 + Uart_DEV2_RecvDeal_UartBitrateChange(getdata);
  2503 + return 0;
  2504 + break;
  2505 +
2348 /******************************************************************************************************************************* 2506 /*******************************************************************************************************************************
2349 * 2507 *
2350 * 6B类部分 2508 * 6B类部分
@@ -2408,182 +2566,6 @@ int Uart_DEV2_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le @@ -2408,182 +2566,6 @@ int Uart_DEV2_RecvDeal_RecvDeal(int Receive_mode, unsigned char *getdata, int le
2408 ********* ********| 2566 ********* ********|
2409 ********* ********| 2567 ********* ********|
2410 *********************************************************************************************************/ 2568 *********************************************************************************************************/
2411 -static int Uart_DEV2_RecvDeal_RecvTransmission_CharmDeal(char* getbuf, int len, int flag)  
2412 -{  
2413 - int data_len = 0; //剩余数据长度  
2414 -  
2415 - /******************************  
2416 - *  
2417 - * 如果当前为传输opus文件的状态  
2418 - *  
2419 - * ***************************/  
2420 - if (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION)  
2421 - {  
2422 - //如果 传过来的帧为关闭传输opus  
2423 - if (flag == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)  
2424 - {  
2425 - //返回 关闭传输opus帧  
2426 - return JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;  
2427 - }  
2428 -  
2429 - //要是回来的帧最后藏着结束帧  
2430 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)  
2431 - {  
2432 - //把前面的还有剩的数据处理掉  
2433 - data_len = len - 12;  
2434 - Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);  
2435 -  
2436 - //返回 关闭传输opus帧  
2437 - return JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;  
2438 - }  
2439 -  
2440 - //要是回来的帧最后藏着播放帧  
2441 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_PLAY)  
2442 - {  
2443 - //说明 还藏着结束帧  
2444 -  
2445 - //先把前面的还有剩的数据处理掉  
2446 - data_len = len - 24;  
2447 - Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);  
2448 -  
2449 - //处理结束帧  
2450 - if (JZsdk_FrameComparsion(getbuf + len - 24, 12) == JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP)  
2451 - {  
2452 - UART_DEV2_Receive_mode = JZ_INSCODE_5AFRAME_OPUS_TRANS_STOP;  
2453 - Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, len);  
2454 - }  
2455 -  
2456 - //返回播放帧  
2457 - return JZ_INSCODE_5AFRAME_OPUS_PLAY;  
2458 - }  
2459 -  
2460 - //都没有 继续传输状态  
2461 - return JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION;  
2462 - }  
2463 -  
2464 - /******************************  
2465 - *  
2466 - * 如果当前为传输opus实时语音的状态  
2467 - *  
2468 - * ***************************/  
2469 - //如果 如果处于传输实时语音模式 且 传过来的关闭语音帧  
2470 - if (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION)  
2471 - {  
2472 - //如果 传过来的帧为关闭实时语音  
2473 - if (flag == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP)  
2474 - {  
2475 - //返回 关闭实时语音  
2476 - return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP;  
2477 - }  
2478 -  
2479 - //要是回来的帧最后藏着结束帧  
2480 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP)  
2481 - {  
2482 - //把前面的还有剩的数据处理掉  
2483 - data_len = len - 12;  
2484 - Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);  
2485 -  
2486 - //返回 关闭实时语音  
2487 - return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_STOP;  
2488 - }  
2489 -  
2490 - //都没有 继续传输状态  
2491 - return JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION;  
2492 - }  
2493 -  
2494 - /******************************  
2495 - *  
2496 - * 如果当前为传输mp2实时语音的状态  
2497 - *  
2498 - * ***************************/  
2499 - //如果 如果处于传输实时语音模式 且 传过来的关闭语音帧  
2500 - if (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION)  
2501 - {  
2502 - //如果 传过来的帧为关闭实时语音  
2503 - if (flag == JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP)  
2504 - {  
2505 - //返回 关闭实时语音  
2506 - return JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP;  
2507 - }  
2508 -  
2509 - //要是回来的帧最后藏着结束帧  
2510 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP)  
2511 - {  
2512 - //把前面的还有剩的数据处理掉  
2513 - data_len = len - 12;  
2514 - Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);  
2515 -  
2516 - //返回 关闭实时语音  
2517 - return JZ_INSCODE_5AFRAME_REALTIMEMP2_STOP;  
2518 - }  
2519 -  
2520 - //都没有 继续传输状态  
2521 - return JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION;  
2522 - }  
2523 -  
2524 - /******************************  
2525 - *  
2526 - * 如果当前为传输音频文件的状态  
2527 - *  
2528 - * ***************************/  
2529 - //如果 如果处于传输实时语音模式 且 传过来的关闭语音帧  
2530 - if (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION)  
2531 - {  
2532 - //如果 传过来的帧为关闭实时语音  
2533 - if (flag == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP)  
2534 - {  
2535 - //返回 关闭实时语音  
2536 - return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP;  
2537 - }  
2538 -  
2539 - //要是回来的帧最后藏着结束帧  
2540 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP)  
2541 - {  
2542 - //把前面的还有剩的数据处理掉  
2543 - data_len = len - 12;  
2544 - Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);  
2545 -  
2546 - //返回 关闭实时语音  
2547 - return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_STOP;  
2548 - }  
2549 -  
2550 - //都没有 继续传输状态  
2551 - return JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION;  
2552 - }  
2553 -  
2554 - /******************************  
2555 - *  
2556 - * 如果当前为传输TTS的状态  
2557 - *  
2558 - * ***************************/  
2559 - //如果 如果处于传输TTS模式 且 传过来的关闭TTS帧  
2560 - if (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)  
2561 - {  
2562 - //如果 传过来的帧为关闭TTS  
2563 - if (flag == JZ_INSCODE_5AFRAME_TTS_TRANS_STOP)  
2564 - {  
2565 - //返回 关闭TTS  
2566 - return JZ_INSCODE_5AFRAME_TTS_TRANS_STOP;  
2567 - }  
2568 -  
2569 - //要是回来的帧最后藏着结束帧  
2570 - if ( JZsdk_FrameComparsion(getbuf + len - 12, 12) == JZ_INSCODE_5AFRAME_TTS_TRANS_STOP)  
2571 - {  
2572 - //把前面的还有剩的数据处理掉  
2573 - data_len = len - 12;  
2574 - Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, data_len);  
2575 -  
2576 - //返回 关闭TTS  
2577 - return JZ_INSCODE_5AFRAME_TTS_TRANS_STOP;  
2578 - }  
2579 -  
2580 - //都没有 继续传输状态  
2581 - return JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION;  
2582 - }  
2583 -  
2584 - // 以上的帧都不是  
2585 - return JZ_ERROR_SYSTEM_FRAME_ERROR;  
2586 -}  
2587 2569
2588 2570
2589 /******************************************************************************************************** 2571 /********************************************************************************************************
@@ -2602,42 +2584,41 @@ static int Uart_DEV2_RecvDeal_RecvTransmission_CharmDeal(char* getbuf, int len, @@ -2602,42 +2584,41 @@ static int Uart_DEV2_RecvDeal_RecvTransmission_CharmDeal(char* getbuf, int len,
2602 2584
2603 int JZsdk_Uart_RecvDeal_CharmDeal_Uart_DEV2(unsigned char *getbuf, int len) 2585 int JZsdk_Uart_RecvDeal_CharmDeal_Uart_DEV2(unsigned char *getbuf, int len)
2604 { 2586 {
2605 - //1、不进行切割处理 2587 + //已经进行了切割预处理
2606 2588
2607 - //2、进行指令帧对比,确认该帧的功能 2589 + //1、进行指令帧对比,确认该帧的功能
2608 int flag = JZsdk_FrameComparsion(getbuf, len); 2590 int flag = JZsdk_FrameComparsion(getbuf, len);
2609 2591
2610 - //3、进行回复帧对比,确认该帧的功能  
2611 -  
2612 - //4、如果传过来的是正常帧 且不处于传输过程,接收模式改变  
2613 - if ((flag != JZ_ERROR_SYSTEM_FRAME_ERROR )  
2614 - && (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式 2592 + //2、如果传过来的是正常帧
  2593 + if (flag != JZ_ERROR_SYSTEM_FRAME_ERROR )
  2594 + {
  2595 + Uart_DEV2_RecvDeal_RecvDeal(flag, getbuf, len);
  2596 + //如果不处于5大传输模式
  2597 + if ((UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
2615 && (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式 2598 && (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
2616 && (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式 2599 && (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
2617 && (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式 2600 && (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
2618 - && (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式  
2619 - {  
2620 - UART_DEV2_Receive_mode = flag;  
2621 - }  
2622 - //否则进入 传输过程 处理模式  
2623 - else  
2624 - {  
2625 - flag = Uart_DEV2_RecvDeal_RecvTransmission_CharmDeal(getbuf, len, flag);  
2626 - if (flag != JZ_ERROR_SYSTEM_FRAME_ERROR) 2601 + && (UART_DEV2_Receive_mode != JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式)
2627 { 2602 {
  2603 + //刷新模式
2628 UART_DEV2_Receive_mode = flag; 2604 UART_DEV2_Receive_mode = flag;
2629 } 2605 }
2630 - }  
2631 2606
2632 - //两次判断 flag的值都是JZ_ERROR_SYSTEM_FRAME_ERROR 说明真的不是帧  
2633 - if (flag == JZ_ERROR_SYSTEM_FRAME_ERROR)  
2634 - {  
2635 - UART_DEV2_Receive_mode = JZ_ERROR_SYSTEM_FRAME_ERROR;  
2636 } 2607 }
2637 2608
2638 - //4、根据2 放入接收处理函数 2609 + //否则 如果处于传输传输过程 处理模式 正常录入数据
  2610 + else if (flag == JZ_ERROR_SYSTEM_FRAME_ERROR
  2611 + && ((UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
  2612 + || (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
  2613 + || (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
  2614 + || (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
  2615 + || (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION))) //TTS传输模式)
  2616 + {
2639 Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, len); 2617 Uart_DEV2_RecvDeal_RecvDeal(UART_DEV2_Receive_mode, getbuf, len);
  2618 + }
2640 2619
  2620 + //否则直接丢弃
  2621 + return -1;
2641 } 2622 }
2642 2623
2643 /******************* 2624 /*******************
@@ -2646,9 +2627,28 @@ int JZsdk_Uart_RecvDeal_CharmDeal_Uart_DEV2(unsigned char *getbuf, int len) @@ -2646,9 +2627,28 @@ int JZsdk_Uart_RecvDeal_CharmDeal_Uart_DEV2(unsigned char *getbuf, int len)
2646 * ps : 仅在开启语音传送和 文件传输时会启用该函数 2627 * ps : 仅在开启语音传送和 文件传输时会启用该函数
2647 * 2628 *
2648 * ****************/ 2629 * ****************/
2649 -int JZsdk_Uart_RecvDeal_Set_UART_DEV2_Receive_mode(int value) 2630 +int JZsdk_Uart_RecvDeal_Set_UART_DEV2_ReceiveMode(int value)
2650 { 2631 {
2651 JZSDK_LOG_INFO("串口设备2号,二次修改接收模式%x\n",value); 2632 JZSDK_LOG_INFO("串口设备2号,二次修改接收模式%x\n",value);
2652 UART_DEV2_Receive_mode = value; 2633 UART_DEV2_Receive_mode = value;
2653 return 0; 2634 return 0;
2654 } 2635 }
  2636 +
  2637 +/*
  2638 +
  2639 +
  2640 +
  2641 +*/
  2642 +static T_JZsdkReturnCode JZsdk_Uart_RecvDeal_UART_DEV2_TransmodeDecide()
  2643 +{
  2644 + if ((UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_REALTIMEMP2_TRANSMISSION ) //语音传输模式
  2645 + || (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_AUDIOFILE_TRANS_TRANSMISSION) //音频文件传输模式
  2646 + || (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_TRANS_TRANSMISSION) //opus传输模式
  2647 + || (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_OPUS_REALTIMEVOICE_TRANSMISSION) //opus实时语音传输模式
  2648 + || (UART_DEV2_Receive_mode == JZ_INSCODE_5AFRAME_TTS_TRANS_TRANSMISSION)) //TTS传输模式)
  2649 + {
  2650 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  2651 + }
  2652 +
  2653 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  2654 +}
@@ -8,13 +8,31 @@ @@ -8,13 +8,31 @@
8 #include "Jzsdk_Base/JZsdk_FrameComparsion/JZsdk_FrameComparsion.h" 8 #include "Jzsdk_Base/JZsdk_FrameComparsion/JZsdk_FrameComparsion.h"
9 9
10 //发送任务 10 //发送任务
11 -static int JZsdk_Uart_SendDeal_SendOreder(int UartPort ,char *sendbuf, int len) 11 +static int JZsdk_Uart_SendDeal_SendOrder(int UartPort ,char *sendbuf, int len)
12 { 12 {
13 JZsdk_Uart_UartSend(UartPort, sendbuf, len); 13 JZsdk_Uart_UartSend(UartPort, sendbuf, len);
14 } 14 }
15 15
  16 +//发送自由帧
  17 +int JZsdk_Uart_SendDeal_Send_CustomOrder(int UartPort, char *sendbuf, int len)
  18 +{
  19 + JZsdk_Uart_UartSend(UartPort, sendbuf, len);
  20 +}
16 21
17 //发送连接帧 22 //发送连接帧
  23 +int JZsdk_Uart_SendDeal_Send_ConnectFrame(int Uartport)
  24 +{
  25 + char sendbuf[256];
  26 + int send_buf_len;
  27 +
  28 + //1、获取帧样板
  29 + JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_ASKFORCONNECT , sendbuf, &send_buf_len);
  30 +
  31 + //2、发送帧
  32 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
  33 +}
  34 +
  35 +//发送回复连接帧
18 int JZsdk_Uart_SendDeal_Send_Connect(int Uartport ,int Version_flag) 36 int JZsdk_Uart_SendDeal_Send_Connect(int Uartport ,int Version_flag)
19 { 37 {
20 char sendbuf[256]; 38 char sendbuf[256];
@@ -27,7 +45,7 @@ int JZsdk_Uart_SendDeal_Send_Connect(int Uartport ,int Version_flag) @@ -27,7 +45,7 @@ int JZsdk_Uart_SendDeal_Send_Connect(int Uartport ,int Version_flag)
27 sendbuf[9] = Version_flag; 45 sendbuf[9] = Version_flag;
28 46
29 //3、发送帧 47 //3、发送帧
30 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 48 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
31 } 49 }
32 50
33 //发送成功帧 51 //发送成功帧
@@ -43,7 +61,7 @@ int JZsdk_Uart_SendDeal_Reply_Sucesss(int Uartport ,int FrameSequence) @@ -43,7 +61,7 @@ int JZsdk_Uart_SendDeal_Reply_Sucesss(int Uartport ,int FrameSequence)
43 sendbuf[6] = FrameSequence; //帧序列 61 sendbuf[6] = FrameSequence; //帧序列
44 62
45 //3、发送帧 63 //3、发送帧
46 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 64 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
47 } 65 }
48 66
49 //发送失败帧 67 //发送失败帧
@@ -59,7 +77,7 @@ int JZsdk_Uart_SendDeal_Reply_Failure(int Uartport ,int FrameSequence) @@ -59,7 +77,7 @@ int JZsdk_Uart_SendDeal_Reply_Failure(int Uartport ,int FrameSequence)
59 sendbuf[6] = FrameSequence; //帧序列 77 sendbuf[6] = FrameSequence; //帧序列
60 78
61 //3、发送帧 79 //3、发送帧
62 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 80 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
63 } 81 }
64 82
65 //发送当前从设备名 83 //发送当前从设备名
@@ -76,7 +94,7 @@ int JZsdk_Uart_SendDeal_Reply_SecondaryDeviceName(int Uartport , int device_name @@ -76,7 +94,7 @@ int JZsdk_Uart_SendDeal_Reply_SecondaryDeviceName(int Uartport , int device_name
76 sendbuf[10] = device_name; 94 sendbuf[10] = device_name;
77 95
78 //3、发送帧 96 //3、发送帧
79 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 97 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
80 } 98 }
81 99
82 100
@@ -93,7 +111,7 @@ int JZsdk_Uart_SendDeal_QuerySecondaryDeviceName(int Uartport ,int FrameSequence @@ -93,7 +111,7 @@ int JZsdk_Uart_SendDeal_QuerySecondaryDeviceName(int Uartport ,int FrameSequence
93 sendbuf[6] = FrameSequence; //帧序列 111 sendbuf[6] = FrameSequence; //帧序列
94 112
95 //3、发送帧 113 //3、发送帧
96 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 114 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
97 } 115 }
98 116
99 //发送当前设备序列号 117 //发送当前设备序列号
@@ -113,12 +131,14 @@ int JZsdk_Uart_SendDeal_SerialNumber(int UartPort, int FrameSequence, char *Seri @@ -113,12 +131,14 @@ int JZsdk_Uart_SendDeal_SerialNumber(int UartPort, int FrameSequence, char *Seri
113 sendbuf[9+i] = SerialNumber[i]; 131 sendbuf[9+i] = SerialNumber[i];
114 } 132 }
115 133
116 - sendbuf[21] = 0x00;  
117 - sendbuf[22] = 0x23; 134 + sendbuf[23] = 0x00;
  135 + sendbuf[24] = 0x23;
118 sendbuf[4] = 0x17; 136 sendbuf[4] = 0x17;
119 137
  138 + send_buf_len = 25;
  139 +
120 //3、发送帧 140 //3、发送帧
121 - JZsdk_Uart_SendDeal_SendOreder(UartPort ,sendbuf, send_buf_len); 141 + JZsdk_Uart_SendDeal_SendOrder(UartPort ,sendbuf, send_buf_len);
122 } 142 }
123 143
124 144
@@ -142,7 +162,7 @@ int JZsdk_Uart_SendDeal_Reply_Musiclist(int Uartport ,char *music_name, int musi @@ -142,7 +162,7 @@ int JZsdk_Uart_SendDeal_Reply_Musiclist(int Uartport ,char *music_name, int musi
142 sendbuf[4] = len & 0xff; 162 sendbuf[4] = len & 0xff;
143 163
144 //3、发送帧 164 //3、发送帧
145 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, len); 165 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, len);
146 } 166 }
147 167
148 //发送歌曲列表开始帧 168 //发送歌曲列表开始帧
@@ -159,7 +179,7 @@ int JZsdk_Uart_SendDeal_Reply_Musiclist_start(int Uartport ,int num) @@ -159,7 +179,7 @@ int JZsdk_Uart_SendDeal_Reply_Musiclist_start(int Uartport ,int num)
159 sendbuf[9] = num; 179 sendbuf[9] = num;
160 180
161 //3、发送帧 181 //3、发送帧
162 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 182 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
163 183
164 } 184 }
165 185
@@ -177,7 +197,7 @@ int JZsdk_Uart_SendDeal_Reply_Musiclist_end(int Uartport) @@ -177,7 +197,7 @@ int JZsdk_Uart_SendDeal_Reply_Musiclist_end(int Uartport)
177 //2、写入数据 197 //2、写入数据
178 198
179 //3、发送帧 199 //3、发送帧
180 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 200 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
181 } 201 }
182 202
183 //发送播放状态结束帧 203 //发送播放状态结束帧
@@ -193,7 +213,7 @@ int JZsdk_Uart_SendDeal_Send_PlayStatus_end(int Uartport) @@ -193,7 +213,7 @@ int JZsdk_Uart_SendDeal_Send_PlayStatus_end(int Uartport)
193 //2、写入数据 213 //2、写入数据
194 214
195 //3、发送帧 215 //3、发送帧
196 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 216 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
197 } 217 }
198 218
199 //发送播放状态帧 219 //发送播放状态帧
@@ -226,7 +246,7 @@ int JZsdk_Uart_SendDeal_Send_PlayStatus(int Uartport ,int num) @@ -226,7 +246,7 @@ int JZsdk_Uart_SendDeal_Send_PlayStatus(int Uartport ,int num)
226 sendbuf[9] = (char)num; 246 sendbuf[9] = (char)num;
227 247
228 //3、发送帧 248 //3、发送帧
229 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 249 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
230 } 250 }
231 251
232 //回复当前播放的歌曲名字 252 //回复当前播放的歌曲名字
@@ -250,7 +270,7 @@ int JZsdk_Uart_SendDeal_Reply_MusicName(int Uartport ,char *music_name, int musi @@ -250,7 +270,7 @@ int JZsdk_Uart_SendDeal_Reply_MusicName(int Uartport ,char *music_name, int musi
250 sendbuf[4] = len & 0xff; 270 sendbuf[4] = len & 0xff;
251 271
252 //3、发送帧 272 //3、发送帧
253 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, len); 273 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, len);
254 } 274 }
255 275
256 //回复当前音量 276 //回复当前音量
@@ -267,7 +287,7 @@ int JZsdk_Uart_SendDeal_Reply_Volume(int Uartport ,int num) @@ -267,7 +287,7 @@ int JZsdk_Uart_SendDeal_Reply_Volume(int Uartport ,int num)
267 sendbuf[9] = (char)num; 287 sendbuf[9] = (char)num;
268 288
269 //3、发送帧 289 //3、发送帧
270 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 290 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
271 291
272 } 292 }
273 293
@@ -290,7 +310,7 @@ int JZsdk_Uart_SendDeal_Reply_SoftVersion(int Uartport ,char majorVersion, char @@ -290,7 +310,7 @@ int JZsdk_Uart_SendDeal_Reply_SoftVersion(int Uartport ,char majorVersion, char
290 sendbuf[12] = debugVersion; 310 sendbuf[12] = debugVersion;
291 311
292 //3、发送帧 312 //3、发送帧
293 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 313 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
294 } 314 }
295 315
296 //发送循环状态 316 //发送循环状态
@@ -308,7 +328,7 @@ int JZsdk_Uart_SendDeal_Reply_LoopPlayStatus(int Uartport ,int status) @@ -308,7 +328,7 @@ int JZsdk_Uart_SendDeal_Reply_LoopPlayStatus(int Uartport ,int status)
308 sendbuf[9] = status; 328 sendbuf[9] = status;
309 329
310 //3、发送帧 330 //3、发送帧
311 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 331 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
312 332
313 } 333 }
314 334
@@ -327,7 +347,7 @@ int JZsdk_Uart_SendDeal_Reply_TTS_tone(int Uartport ,int tone) @@ -327,7 +347,7 @@ int JZsdk_Uart_SendDeal_Reply_TTS_tone(int Uartport ,int tone)
327 sendbuf[9] = tone; 347 sendbuf[9] = tone;
328 348
329 //3、发送帧 349 //3、发送帧
330 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 350 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
331 } 351 }
332 352
333 //发送语速 353 //发送语速
@@ -345,7 +365,7 @@ int JZsdk_Uart_SendDeal_Reply_TTS_speed(int Uartport ,int speed) @@ -345,7 +365,7 @@ int JZsdk_Uart_SendDeal_Reply_TTS_speed(int Uartport ,int speed)
345 sendbuf[9] = speed; 365 sendbuf[9] = speed;
346 366
347 //3、发送帧 367 //3、发送帧
348 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 368 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
349 } 369 }
350 370
351 /**************************************************************************************************************************************************** 371 /****************************************************************************************************************************************************
@@ -377,13 +397,13 @@ int JZsdk_Uart_SendDeal_Reply_GimbalPitchAngle(int Uartport ,int angle) @@ -377,13 +397,13 @@ int JZsdk_Uart_SendDeal_Reply_GimbalPitchAngle(int Uartport ,int angle)
377 sendbuf[11] = (char)(angle & 255); 397 sendbuf[11] = (char)(angle & 255);
378 398
379 //3、发送帧 399 //3、发送帧
380 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 400 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
381 } 401 }
382 402
383 //设置当前云台角度 403 //设置当前云台角度
384 int JZsdk_Uart_SendDeal_Set_GimbalPitchAngle(int Uartport ,int angle) 404 int JZsdk_Uart_SendDeal_Set_GimbalPitchAngle(int Uartport ,int angle)
385 { 405 {
386 - printf("发送设置云台角度帧\n"); 406 + printf("发送设置云台角度帧 %d\n",angle);
387 char sendbuf[256]; 407 char sendbuf[256];
388 int send_buf_len; 408 int send_buf_len;
389 409
@@ -405,7 +425,7 @@ int JZsdk_Uart_SendDeal_Set_GimbalPitchAngle(int Uartport ,int angle) @@ -405,7 +425,7 @@ int JZsdk_Uart_SendDeal_Set_GimbalPitchAngle(int Uartport ,int angle)
405 sendbuf[11] = (angle & 0xff); 425 sendbuf[11] = (angle & 0xff);
406 426
407 //3、发送帧 427 //3、发送帧
408 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 428 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
409 } 429 }
410 430
411 //查询云台角度 431 //查询云台角度
@@ -422,7 +442,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_GimbalAngle(int Uartport ,int FrameSequence) @@ -422,7 +442,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_GimbalAngle(int Uartport ,int FrameSequence)
422 sendbuf[6] = FrameSequence; 442 sendbuf[6] = FrameSequence;
423 443
424 //3、发送帧 444 //3、发送帧
425 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 445 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
426 } 446 }
427 447
428 //微调云台pitch 448 //微调云台pitch
@@ -450,7 +470,7 @@ int JZsdk_Uart_SendDeal_Set_GimbalFineTuningPitch(int Uartport, int PitchFineTun @@ -450,7 +470,7 @@ int JZsdk_Uart_SendDeal_Set_GimbalFineTuningPitch(int Uartport, int PitchFineTun
450 sendbuf[11] = (PitchFineTuning & 0xff); 470 sendbuf[11] = (PitchFineTuning & 0xff);
451 471
452 //3、发送帧 472 //3、发送帧
453 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 473 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
454 } 474 }
455 475
456 //查询云台角度微调值 476 //查询云台角度微调值
@@ -467,7 +487,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_GimbalFineTuningPitch(int Uartport, int Fram @@ -467,7 +487,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_GimbalFineTuningPitch(int Uartport, int Fram
467 sendbuf[6] = FrameSequence; //帧序列 487 sendbuf[6] = FrameSequence; //帧序列
468 488
469 //3、发送帧 489 //3、发送帧
470 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 490 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
471 } 491 }
472 492
473 //回复云台pitch微调值 493 //回复云台pitch微调值
@@ -495,7 +515,7 @@ int JZsdk_Uart_SendDeal_Reply_GimbalFineTuningPitch(int Uartport, int FrameSeque @@ -495,7 +515,7 @@ int JZsdk_Uart_SendDeal_Reply_GimbalFineTuningPitch(int Uartport, int FrameSeque
495 sendbuf[11] = (FineTunigPitch & 0xff); 515 sendbuf[11] = (FineTunigPitch & 0xff);
496 516
497 //3、发送帧 517 //3、发送帧
498 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 518 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
499 } 519 }
500 520
501 //设置云台联动 521 //设置云台联动
@@ -513,7 +533,7 @@ int JZsdk_Uart_SendDeal_Set_GimbalLinkageControl(int Uartport,int FrameSequence, @@ -513,7 +533,7 @@ int JZsdk_Uart_SendDeal_Set_GimbalLinkageControl(int Uartport,int FrameSequence,
513 sendbuf[10] = value; 533 sendbuf[10] = value;
514 534
515 //3、发送帧 535 //3、发送帧
516 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 536 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
517 } 537 }
518 538
519 //查询云台联动值 539 //查询云台联动值
@@ -530,7 +550,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_GimbalLinkage(int Uartport,int FrameSequence @@ -530,7 +550,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_GimbalLinkage(int Uartport,int FrameSequence
530 sendbuf[6] = FrameSequence; //帧序列 550 sendbuf[6] = FrameSequence; //帧序列
531 551
532 //3、发送帧 552 //3、发送帧
533 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 553 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
534 } 554 }
535 555
536 //发送云台联动值 556 //发送云台联动值
@@ -548,7 +568,7 @@ int JZsdk_Uart_SendDeal_GimbalLinkageControl(int Uartport,int FrameSequence,int @@ -548,7 +568,7 @@ int JZsdk_Uart_SendDeal_GimbalLinkageControl(int Uartport,int FrameSequence,int
548 sendbuf[10] = value; 568 sendbuf[10] = value;
549 569
550 //3、发送帧 570 //3、发送帧
551 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 571 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
552 } 572 }
553 573
554 //发送云台最大最小值帧 574 //发送云台最大最小值帧
@@ -566,7 +586,7 @@ int JZsdk_Uart_SendDeal_SetGimbalRange(int Uartport,int FrameSequence,int value) @@ -566,7 +586,7 @@ int JZsdk_Uart_SendDeal_SetGimbalRange(int Uartport,int FrameSequence,int value)
566 sendbuf[10] = value; 586 sendbuf[10] = value;
567 587
568 //3、发送帧 588 //3、发送帧
569 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 589 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
570 } 590 }
571 591
572 /**************************************************************************************************************************************************** 592 /****************************************************************************************************************************************************
@@ -590,7 +610,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLightFrequency(int Uartport ,int Frequency) @@ -590,7 +610,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLightFrequency(int Uartport ,int Frequency)
590 sendbuf[10] = Frequency; 610 sendbuf[10] = Frequency;
591 611
592 //3、发送帧 612 //3、发送帧
593 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 613 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
594 } 614 }
595 615
596 //设置探照灯控制 616 //设置探照灯控制
@@ -608,7 +628,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Control(int Uartport,int mode) @@ -608,7 +628,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Control(int Uartport,int mode)
608 sendbuf[10] = mode; 628 sendbuf[10] = mode;
609 629
610 //3、发送帧 630 //3、发送帧
611 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 631 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
612 } 632 }
613 633
614 //设置探照灯亮度 634 //设置探照灯亮度
@@ -627,7 +647,7 @@ int JZsdk_Uart_SendDeal_SearchLight_SetLumen(int Uartport, int LeftLumen, int @@ -627,7 +647,7 @@ int JZsdk_Uart_SendDeal_SearchLight_SetLumen(int Uartport, int LeftLumen, int
627 sendbuf[10] = RightLumen; 647 sendbuf[10] = RightLumen;
628 648
629 //3、发送帧 649 //3、发送帧
630 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 650 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
631 } 651 }
632 652
633 //发送 653 //发送
@@ -644,7 +664,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLight_CheckStatus_Frequency(int Uartport) @@ -644,7 +664,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLight_CheckStatus_Frequency(int Uartport)
644 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_FREQUENCY, sendbuf, &send_buf_len); 664 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_FREQUENCY, sendbuf, &send_buf_len);
645 665
646 //2、发送帧 666 //2、发送帧
647 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 667 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
648 } 668 }
649 669
650 //查询探照灯亮度 670 //查询探照灯亮度
@@ -659,7 +679,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLight_CheckStatus_Lumen(int Uartport) @@ -659,7 +679,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLight_CheckStatus_Lumen(int Uartport)
659 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_LUMEN, sendbuf, &send_buf_len); 679 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_LUMEN, sendbuf, &send_buf_len);
660 680
661 //2、发送帧 681 //2、发送帧
662 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 682 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
663 } 683 }
664 684
665 //查询探照灯模式 685 //查询探照灯模式
@@ -674,7 +694,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLight_CheckStatus_Mode(int Uartport) @@ -674,7 +694,7 @@ int JZsdk_Uart_SendDeal_Set_SearchLight_CheckStatus_Mode(int Uartport)
674 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_MODE, sendbuf, &send_buf_len); 694 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_MODE, sendbuf, &send_buf_len);
675 695
676 //2、发送帧 696 //2、发送帧
677 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 697 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
678 } 698 }
679 699
680 //查询探照灯属性 700 //查询探照灯属性
@@ -689,7 +709,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_LightAttribute(int Uartport) @@ -689,7 +709,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_LightAttribute(int Uartport)
689 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_LIGHTATTRIBUTE, sendbuf, &send_buf_len); 709 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_LIGHTATTRIBUTE, sendbuf, &send_buf_len);
690 710
691 //2、发送帧 711 //2、发送帧
692 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 712 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
693 } 713 }
694 714
695 //查询探照灯温度 715 //查询探照灯温度
@@ -704,13 +724,13 @@ int JZsdk_Uart_SendDeal_CheckStatus_SearchLightTemperture(int Uartport) @@ -704,13 +724,13 @@ int JZsdk_Uart_SendDeal_CheckStatus_SearchLightTemperture(int Uartport)
704 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_TEMPERATURE, sendbuf, &send_buf_len); 724 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_SEARCHLIGHT_TEMPERATURE, sendbuf, &send_buf_len);
705 725
706 //2、发送帧 726 //2、发送帧
707 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 727 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
708 } 728 }
709 729
710 //开启消息订阅 730 //开启消息订阅
711 int JZsdk_Uart_SendDeal_MessageSubcription_Control(int Uartport, int value) 731 int JZsdk_Uart_SendDeal_MessageSubcription_Control(int Uartport, int value)
712 { 732 {
713 - printf("发送开启消息订阅\n"); 733 + printf("发送开启消息订阅%d\n",value);
714 734
715 char sendbuf[256]; 735 char sendbuf[256];
716 int send_buf_len; 736 int send_buf_len;
@@ -722,7 +742,7 @@ int JZsdk_Uart_SendDeal_MessageSubcription_Control(int Uartport, int value) @@ -722,7 +742,7 @@ int JZsdk_Uart_SendDeal_MessageSubcription_Control(int Uartport, int value)
722 sendbuf[10] = value; 742 sendbuf[10] = value;
723 743
724 //3、发送帧 744 //3、发送帧
725 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 745 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
726 } 746 }
727 747
728 /**************************************************************************************************************************************************** 748 /****************************************************************************************************************************************************
@@ -750,7 +770,7 @@ int JZsdk_Uart_SendDeal_Set_WarningLight_Status(int Uartport,int status, int mod @@ -750,7 +770,7 @@ int JZsdk_Uart_SendDeal_Set_WarningLight_Status(int Uartport,int status, int mod
750 sendbuf[10] = mode; 770 sendbuf[10] = mode;
751 771
752 //3、发送帧 772 //3、发送帧
753 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 773 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
754 } 774 }
755 775
756 /************* 776 /*************
@@ -773,7 +793,7 @@ int JZsdk_Uart_SendDeal_Set_WarningLight_Color(int Uartport,int color1, int colo @@ -773,7 +793,7 @@ int JZsdk_Uart_SendDeal_Set_WarningLight_Color(int Uartport,int color1, int colo
773 sendbuf[10] = color2; 793 sendbuf[10] = color2;
774 794
775 //3、发送帧 795 //3、发送帧
776 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 796 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
777 } 797 }
778 798
779 //查询警灯状态 799 //查询警灯状态
@@ -788,7 +808,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_WarningLightStatus(int Uartport) @@ -788,7 +808,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_WarningLightStatus(int Uartport)
788 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_WARNINGLIGHT_STATUS, sendbuf, &send_buf_len); 808 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_WARNINGLIGHT_STATUS, sendbuf, &send_buf_len);
789 809
790 //2、发送帧 810 //2、发送帧
791 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 811 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
792 } 812 }
793 813
794 //查询警灯颜色 814 //查询警灯颜色
@@ -803,7 +823,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_WarningLightColor(int Uartport) @@ -803,7 +823,7 @@ int JZsdk_Uart_SendDeal_CheckStatus_WarningLightColor(int Uartport)
803 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_WARNINGLIGHT_COLOR, sendbuf, &send_buf_len); 823 JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_CHECKSTATUS_WARNINGLIGHT_COLOR, sendbuf, &send_buf_len);
804 824
805 //2、发送帧 825 //2、发送帧
806 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 826 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
807 } 827 }
808 828
809 /**************************************************************************************************************************************************** 829 /****************************************************************************************************************************************************
@@ -830,7 +850,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Frequency(int Uartport, int Frequency) @@ -830,7 +850,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Frequency(int Uartport, int Frequency)
830 sendbuf[10] = Frequency; 850 sendbuf[10] = Frequency;
831 851
832 //3、发送帧 852 //3、发送帧
833 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 853 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
834 } 854 }
835 855
836 /************* 856 /*************
@@ -852,7 +872,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Mode(int Uartport, int mode) @@ -852,7 +872,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Mode(int Uartport, int mode)
852 sendbuf[10] = mode; 872 sendbuf[10] = mode;
853 873
854 //3、发送帧 874 //3、发送帧
855 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 875 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
856 } 876 }
857 877
858 /************* 878 /*************
@@ -875,7 +895,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Lumen(int Uartport,int LeftLumen, int RightL @@ -875,7 +895,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Lumen(int Uartport,int LeftLumen, int RightL
875 sendbuf[10] = RightLumen; 895 sendbuf[10] = RightLumen;
876 896
877 //3、发送帧 897 //3、发送帧
878 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 898 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
879 } 899 }
880 900
881 /************* 901 /*************
@@ -898,7 +918,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Temperature(int Uartport, int LeftTemperatur @@ -898,7 +918,7 @@ int JZsdk_Uart_SendDeal_SearchLight_Temperature(int Uartport, int LeftTemperatur
898 sendbuf[10] = RightTemperature; 918 sendbuf[10] = RightTemperature;
899 919
900 //3、发送帧 920 //3、发送帧
901 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 921 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
902 } 922 }
903 923
904 924
@@ -922,7 +942,7 @@ int JZsdk_Uart_SendDeal_WarningLight_Status(int Uartport, int status, int mode) @@ -922,7 +942,7 @@ int JZsdk_Uart_SendDeal_WarningLight_Status(int Uartport, int status, int mode)
922 sendbuf[10] = mode; 942 sendbuf[10] = mode;
923 943
924 //3、发送帧 944 //3、发送帧
925 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); } 945 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len); }
926 946
927 /************* 947 /*************
928 * 948 *
@@ -944,7 +964,7 @@ int JZsdk_Uart_SendDeal_WarningLight_Color(int Uartport, int color1, int color2) @@ -944,7 +964,7 @@ int JZsdk_Uart_SendDeal_WarningLight_Color(int Uartport, int color1, int color2)
944 sendbuf[10] = color2; 964 sendbuf[10] = color2;
945 965
946 //3、发送帧 966 //3、发送帧
947 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 967 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
948 } 968 }
949 969
950 /************* 970 /*************
@@ -966,5 +986,5 @@ int JZsdk_Uart_SendDeal_OutputPowerStatus(int Uartport, int FrameSequence, int s @@ -966,5 +986,5 @@ int JZsdk_Uart_SendDeal_OutputPowerStatus(int Uartport, int FrameSequence, int s
966 sendbuf[9] = status; 986 sendbuf[9] = status;
967 987
968 //3、发送帧 988 //3、发送帧
969 - JZsdk_Uart_SendDeal_SendOreder(Uartport ,sendbuf, send_buf_len); 989 + JZsdk_Uart_SendDeal_SendOrder(Uartport ,sendbuf, send_buf_len);
970 } 990 }
@@ -22,6 +22,8 @@ extern "C" { @@ -22,6 +22,8 @@ extern "C" {
22 22
23 /* Exported types ------------------------------------------------------------*/ 23 /* Exported types ------------------------------------------------------------*/
24 int JZsdk_Uart_SendDeal_Send_Connect(int Uartport ,int Version_flag); 24 int JZsdk_Uart_SendDeal_Send_Connect(int Uartport ,int Version_flag);
  25 +int JZsdk_Uart_SendDeal_Send_ConnectFrame(int Uartport);
  26 +int JZsdk_Uart_SendDeal_Send_CustomOrder(int UartPort, char *sendbuf, int len);
25 27
26 int JZsdk_Uart_SendDeal_Reply_SecondaryDeviceName(int Uartport , int device_name, int FrameSequence); 28 int JZsdk_Uart_SendDeal_Reply_SecondaryDeviceName(int Uartport , int device_name, int FrameSequence);
27 int JZsdk_Uart_SendDeal_QuerySecondaryDeviceName(int Uartport ,int FrameSequence); 29 int JZsdk_Uart_SendDeal_QuerySecondaryDeviceName(int Uartport ,int FrameSequence);
@@ -10,11 +10,13 @@ @@ -10,11 +10,13 @@
10 #include "Uart_Config.h" 10 #include "Uart_Config.h"
11 #include "JZsdk_Uart_Recv/JZsdk_Uart_RecvDeal.h" 11 #include "JZsdk_Uart_Recv/JZsdk_Uart_RecvDeal.h"
12 #include "JZsdkLib.h" 12 #include "JZsdkLib.h"
  13 +#include "JZsdk_Uart_Input.h"
13 14
14 // 串口参数结构体 15 // 串口参数结构体
15 typedef struct 16 typedef struct
16 { 17 {
17 int UartFd; // 串口识别符 18 int UartFd; // 串口识别符
  19 + int UartDevName; //串口名
18 char Message[1024]; // 传递的字符串 20 char Message[1024]; // 传递的字符串
19 int MessageLength; // 字符串的长度 21 int MessageLength; // 字符串的长度
20 int ResLen; //剩余长度 22 int ResLen; //剩余长度
@@ -22,10 +24,27 @@ typedef struct @@ -22,10 +24,27 @@ typedef struct
22 pthread_cond_t cond; // 条件变量 24 pthread_cond_t cond; // 条件变量
23 } s_SerialArgs; 25 } s_SerialArgs;
24 26
  27 +// 再注册串口
  28 +typedef struct
  29 +{
  30 + int UartFd; // 串口识别符
  31 + int UartDevName; //串口名
  32 + int BitRate; //波特率
  33 +} s_SerialInitArg;
  34 +
  35 +//不同串口的描述符
25 static int Uart_4G_fd; 36 static int Uart_4G_fd;
26 static int Uart_DEV1_fd; 37 static int Uart_DEV1_fd;
27 static int Uart_DEV2_fd; 38 static int Uart_DEV2_fd;
28 39
  40 +//用于判断关闭的是哪个串口
  41 +static int Uart_4G_Switch = JZ_FLAGCODE_OFF;
  42 +static int Uart_DEV1_Switch = JZ_FLAGCODE_OFF;
  43 +static int Uart_DEV2_Switch = JZ_FLAGCODE_OFF;
  44 +
  45 +static int Recv_Thread = JZ_FLAGCODE_OFF; //用于判断接收线程是否成功退出
  46 +static int Deal_Thread = JZ_FLAGCODE_OFF; //用于判断处理线程是否成功退出
  47 +
29 static void *UartDeal_rece(void *arg); 48 static void *UartDeal_rece(void *arg);
30 static void *UartDeal_deal(void *arg); 49 static void *UartDeal_deal(void *arg);
31 static int UartDeal_Recv_interface(int Uart_fd, unsigned char *getbuf, int getbufLen); 50 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) @@ -64,6 +83,7 @@ int JZsdk_Uart_UartDeal_Receive(int Uart_fd, int Uart_Dev_name)
64 83
65 s_SerialArgs *parameter = (s_SerialArgs *)malloc(sizeof(s_SerialArgs)); 84 s_SerialArgs *parameter = (s_SerialArgs *)malloc(sizeof(s_SerialArgs));
66 parameter->UartFd = Uart_fd; 85 parameter->UartFd = Uart_fd;
  86 + parameter->UartDevName = Uart_Dev_name;
67 parameter->MessageLength = 0; 87 parameter->MessageLength = 0;
68 memset(parameter->Message, 0, sizeof(parameter->Message)); 88 memset(parameter->Message, 0, sizeof(parameter->Message));
69 pthread_mutex_init(&parameter->mutex, NULL); 89 pthread_mutex_init(&parameter->mutex, NULL);
@@ -102,7 +122,7 @@ static void *UartDeal_rece(void *arg) @@ -102,7 +122,7 @@ static void *UartDeal_rece(void *arg)
102 { 122 {
103 123
104 s_SerialArgs *args = (s_SerialArgs *)arg; 124 s_SerialArgs *args = (s_SerialArgs *)arg;
105 - 125 + struct timeval timeout; // 超时时间
106 fd_set fs_read; 126 fd_set fs_read;
107 static int ResidualLength = 0; // 未处理数据长度 127 static int ResidualLength = 0; // 未处理数据长度
108 128
@@ -115,12 +135,34 @@ static void *UartDeal_rece(void *arg) @@ -115,12 +135,34 @@ static void *UartDeal_rece(void *arg)
115 args->ResLen = 0; 135 args->ResLen = 0;
116 args->MessageLength = 0; 136 args->MessageLength = 0;
117 137
118 - while (1) 138 + int *TheadSwtch = NULL;
  139 + if (args->UartDevName == UART_4G)
  140 + {
  141 + TheadSwtch = &Uart_4G_Switch;
  142 + Uart_4G_Switch = JZ_FLAGCODE_ON;
  143 + }
  144 + else if (args->UartDevName == UART_DEV_1)
  145 + {
  146 + TheadSwtch = &Uart_DEV1_Switch;
  147 + Uart_DEV1_Switch = JZ_FLAGCODE_ON;
  148 + }
  149 + else if (args->UartDevName == UART_DEV_2)
  150 + {
  151 + TheadSwtch = &Uart_DEV2_Switch;
  152 + Uart_DEV2_Switch = JZ_FLAGCODE_ON;
  153 + }
  154 +
  155 + while (*TheadSwtch)
119 { 156 {
  157 + FD_ZERO(&fs_read);
  158 + FD_SET(Uart_fd,&fs_read);
  159 +
  160 + timeout.tv_sec = 0; // 秒数设置为0
  161 + timeout.tv_usec = 100000; // 微秒数设置为100000(100毫秒)
120 162
121 // 检查fs_read套节字是否有数据 163 // 检查fs_read套节字是否有数据
122 - select(Uart_fd + 1, &fs_read, NULL, NULL, NULL);  
123 - delayMs(1); // 加多了可能导致实时播放难恢复,以及声音间隔 3ms32字节 会向上约1个3ms opus一帧80字节 164 + select(Uart_fd + 1, &fs_read, NULL, NULL, &timeout);
  165 + delayMs(3); // 加多了可能导致实时播放难恢复,以及声音间隔 3ms32字节 会向上约1个3ms opus一帧80字节
124 166
125 if (FD_ISSET(Uart_fd, &fs_read)) 167 if (FD_ISSET(Uart_fd, &fs_read))
126 { 168 {
@@ -131,13 +173,27 @@ static void *UartDeal_rece(void *arg) @@ -131,13 +173,27 @@ static void *UartDeal_rece(void *arg)
131 // 1、读取串口内容 ret 接收长度 getbuf 获取的字符 173 // 1、读取串口内容 ret 接收长度 getbuf 获取的字符
132 ResidualLength = args->MessageLength; 174 ResidualLength = args->MessageLength;
133 args->MessageLength = read(Uart_fd, &(args->Message[args->MessageLength]), (sizeof(args->Message) - ResidualLength)) + ResidualLength; 175 args->MessageLength = read(Uart_fd, &(args->Message[args->MessageLength]), (sizeof(args->Message) - ResidualLength)) + ResidualLength;
134 - //JZSDK_LOG_INFO("从串口读取到,长度%d",(args->MessageLength-ResidualLength)); 176 +
  177 + // JZSDK_LOG_INFO("从串口读取到,长度%d",(args->MessageLength-ResidualLength));
  178 +
  179 + // for (int i = 0; i < (args->MessageLength-ResidualLength); i++)
  180 + // {
  181 + // JZSDK_LOG_OUTPUTHEX("%s",&args->Message[i+ResidualLength]);
  182 + // }
135 183
136 // 通知线程 184 // 通知线程
137 pthread_cond_signal(&args->cond); 185 pthread_cond_signal(&args->cond);
138 pthread_mutex_unlock(&args->mutex); // 解锁 186 pthread_mutex_unlock(&args->mutex); // 解锁
139 } 187 }
  188 +
140 } 189 }
  190 +
  191 + //注销相关
  192 + Recv_Thread = JZ_FLAGCODE_OFF;
  193 + // 通知线程
  194 + pthread_cond_signal(&args->cond);
  195 + pthread_mutex_unlock(&args->mutex); // 解锁
  196 + JZSDK_LOG_WARN("串口接收线程被关闭");
141 } 197 }
142 198
143 /*** 199 /***
@@ -152,7 +208,24 @@ static void *UartDeal_deal(void *arg) @@ -152,7 +208,24 @@ static void *UartDeal_deal(void *arg)
152 208
153 static int ResidualLength = 0; // 未处理数据长度 209 static int ResidualLength = 0; // 未处理数据长度
154 210
155 - while (1) 211 + int *TheadSwtch = NULL;
  212 + if (args->UartDevName == UART_4G)
  213 + {
  214 + TheadSwtch = &Uart_4G_Switch;
  215 + Uart_4G_Switch = JZ_FLAGCODE_ON;
  216 + }
  217 + else if (args->UartDevName == UART_DEV_1)
  218 + {
  219 + TheadSwtch = &Uart_DEV1_Switch;
  220 + Uart_DEV1_Switch = JZ_FLAGCODE_ON;
  221 + }
  222 + else if (args->UartDevName == UART_DEV_2)
  223 + {
  224 + TheadSwtch = &Uart_DEV2_Switch;
  225 + Uart_DEV2_Switch = JZ_FLAGCODE_ON;
  226 + }
  227 +
  228 + while (*TheadSwtch)
156 { 229 {
157 230
158 // 加锁 231 // 加锁
@@ -202,11 +275,15 @@ static void *UartDeal_deal(void *arg) @@ -202,11 +275,15 @@ static void *UartDeal_deal(void *arg)
202 275
203 pthread_mutex_unlock(&args->mutex); // 解锁 276 pthread_mutex_unlock(&args->mutex); // 解锁
204 } 277 }
  278 +
  279 + Deal_Thread = JZ_FLAGCODE_OFF;
  280 + free(args); //释放掉处理结构体
  281 + JZSDK_LOG_WARN("串口处理线程被关闭");
205 } 282 }
206 283
207 /* 284 /*
208 285
209 - 数据排出函数s 286 + 数据排出函数
210 287
211 */ 288 */
212 static int UartDeal_Recv_Ouput(int Uart_fd, unsigned char *getbuf, int ReadLen) 289 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) @@ -454,3 +531,111 @@ int JZsdk_Uart_UartSend(int UartPort, unsigned char *send, int num)
454 return 0; 531 return 0;
455 } 532 }
456 } 533 }
  534 +
  535 +
  536 +/****************
  537 + *
  538 + * 串口识别符关闭
  539 + *
  540 + * ****************/
  541 +int JZsdk_Uart_CloseUartFd(int UartPort)
  542 +{
  543 + if (UartPort == UART_4G)
  544 + {
  545 + JZSDK_LOG_INFO("关闭4g串口识别符\n");
  546 + close(Uart_4G_fd);
  547 + return 0;
  548 + }
  549 + else if (UartPort == UART_DEV_1)
  550 + {
  551 + JZSDK_LOG_INFO("关闭串口1识别符\n");
  552 + close(Uart_DEV1_fd);
  553 + return 0;
  554 + }
  555 + else if (UartPort == UART_DEV_2)
  556 + {
  557 + JZSDK_LOG_INFO("关闭串口2识别符\n");
  558 + close(Uart_DEV1_fd);
  559 + return 0;
  560 + }
  561 +}
  562 +
  563 +
  564 +
  565 +
  566 +static void *CloseUart(void *arg)
  567 +{
  568 + s_SerialInitArg *args = (s_SerialInitArg *)arg;
  569 + int UartPort = args->UartDevName;
  570 + int BitRate = args->BitRate;
  571 +
  572 + Recv_Thread = JZ_FLAGCODE_ON;
  573 + Deal_Thread = JZ_FLAGCODE_ON;
  574 +
  575 + if (UartPort == UART_4G)
  576 + {
  577 + JZSDK_LOG_INFO("关闭4g线程\n");
  578 + Uart_4G_Switch = JZ_FLAGCODE_OFF;
  579 + }
  580 + else if (UartPort == UART_DEV_1)
  581 + {
  582 + JZSDK_LOG_INFO("关闭串口1线程\n");
  583 + Uart_DEV1_Switch = JZ_FLAGCODE_OFF;
  584 + }
  585 + else if (UartPort == UART_DEV_2)
  586 + {
  587 + JZSDK_LOG_INFO("关闭串口2线程\n");
  588 + Uart_DEV2_Switch = JZ_FLAGCODE_OFF;
  589 + }
  590 + else
  591 + {
  592 + return 0;
  593 + }
  594 +
  595 + while ( (Recv_Thread != JZ_FLAGCODE_OFF) && (Deal_Thread != JZ_FLAGCODE_OFF))
  596 + {
  597 + delayMs(1);
  598 + }
  599 +
  600 + delayMs(100);
  601 +
  602 + //保证全部注销后
  603 + JZSDK_LOG_INFO("串口注销完毕");
  604 +
  605 + //创建新的
  606 + JZsdk_Uart_SecondInit(UartPort, BitRate);
  607 +
  608 + free(args);
  609 +}
  610 +
  611 +/****************
  612 + *
  613 + * 线程关闭, 并创建一个新的串口
  614 + *
  615 + * ****************/
  616 +int JZsdk_Uart_CloseUartThead(int UartPort, int BitRate)
  617 +{
  618 +
  619 + //将串口描述符关闭
  620 + JZsdk_Uart_CloseUartFd(UartPort);
  621 +
  622 + s_SerialInitArg *parameter = (s_SerialInitArg *)malloc(sizeof(s_SerialInitArg));
  623 + parameter->UartDevName = UartPort;
  624 + parameter->BitRate = BitRate;
  625 +
  626 +
  627 + // 创建关闭串口的线程
  628 + pthread_t CloseThread;
  629 + pthread_attr_t task_attribute; // 线程属性
  630 + pthread_attr_setdetachstate(&task_attribute, PTHREAD_CREATE_DETACHED); // 设置线程分离属性
  631 +
  632 + pthread_attr_init(&task_attribute);
  633 +
  634 +
  635 + // 创建串口数据处理线程
  636 + if (pthread_create(&CloseThread, &task_attribute, CloseUart, parameter) != 0)
  637 + {
  638 + JZSDK_LOG_ERROR("Failed to create receive thread");
  639 + return 1;
  640 + }
  641 +}
@@ -24,6 +24,8 @@ extern "C" { @@ -24,6 +24,8 @@ extern "C" {
24 /* Exported functions --------------------------------------------------------*/ 24 /* Exported functions --------------------------------------------------------*/
25 int JZsdk_Uart_UartSend(int UartPort ,unsigned char *send, int num); 25 int JZsdk_Uart_UartSend(int UartPort ,unsigned char *send, int num);
26 int JZsdk_Uart_UartDeal_Receive(int Uart_fd, int Uart_Dev_name); 26 int JZsdk_Uart_UartDeal_Receive(int Uart_fd, int Uart_Dev_name);
  27 +int JZsdk_Uart_CloseUartFd(int UartPort);
  28 +int JZsdk_Uart_CloseUartThead(int UartPort, int BitRate);
27 29
28 30
29 #ifdef __cplusplus 31 #ifdef __cplusplus
@@ -93,5 +93,7 @@ int UartConnection_UartEnabled(char *UartDev, int BitRate) @@ -93,5 +93,7 @@ int UartConnection_UartEnabled(char *UartDev, int BitRate)
93 tcflush(UartReceive_fd,TCIOFLUSH); //刷清输入、输出队列 93 tcflush(UartReceive_fd,TCIOFLUSH); //刷清输入、输出队列
94 tcsetattr(UartReceive_fd,TCSAFLUSH,&options); //串口设置使能 94 tcsetattr(UartReceive_fd,TCSAFLUSH,&options); //串口设置使能
95 95
  96 + JZSDK_LOG_INFO("使能串口 波特率%d成功",BitRate);
  97 +
96 return UartReceive_fd; 98 return UartReceive_fd;
97 } 99 }
@@ -8,15 +8,27 @@ @@ -8,15 +8,27 @@
8 #include "Gimbal_InAndOut.h" 8 #include "Gimbal_InAndOut.h"
9 #include "JZsdkLib.h" 9 #include "JZsdkLib.h"
10 10
  11 +#include "Psdk_UI_io.h"
11 12
  13 +//数值角度记录
  14 +#if DEVICE_VERSION == TF_A1
  15 + static int Gimbal_PitchAngle = 0;
  16 + static int Gimbal_YawAngle = 0;
  17 +#else
  18 + static int Gimbal_PitchAngle = 0;
  19 + static int Gimbal_YawAngle = 0;
  20 +#endif
12 21
13 -//角度记录  
14 -static int Gimbal_PitchAngle = 0;  
15 -static int Gimbal_YawAngle = 0;  
16 22
  23 +//微调角度
17 static int Gimbal_PitchFineTuning = 0; 24 static int Gimbal_PitchFineTuning = 0;
18 static int Gimbal_YawFineTuning = 0; 25 static int Gimbal_YawFineTuning = 0;
19 26
  27 +//飞机自身角度
  28 +static int Gimbal_UavSelfPitch = 0;
  29 +
  30 +//实际角度 (数值角度+飞机自身角度+微调角度)
  31 +static int Gimbal_RealPitchAngle = 0;
20 32
21 static int Gimbal_LinkageNum; 33 static int Gimbal_LinkageNum;
22 34
@@ -48,6 +60,10 @@ int Gimbal_Init() @@ -48,6 +60,10 @@ int Gimbal_Init()
48 { 60 {
49 Gimbal_V3S_H1T_init_motor(); 61 Gimbal_V3S_H1T_init_motor();
50 } 62 }
  63 + else if (DEVICE_VERSION == TF_A1)
  64 + {
  65 + Gimbal_V3S_TFA1_init_motor();
  66 + }
51 67
52 68
53 else 69 else
@@ -132,6 +148,43 @@ T_JZsdkReturnCode Gimbal_Set_PitchAngle(int angle) @@ -132,6 +148,43 @@ T_JZsdkReturnCode Gimbal_Set_PitchAngle(int angle)
132 148
133 return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS; 149 return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
134 } 150 }
  151 + else if (DEVICE_VERSION == TF_A1)
  152 + {
  153 + //1、判断输入范围是否正确
  154 + if ((angle < -900) || (angle > 0))
  155 + {
  156 + printf("TFA1的云台俯仰输入值范围出错:%d\n", angle);
  157 + return JZ_ERRORCODE_GIMBAL_INVALID_PITCH;
  158 + }
  159 +
  160 + //2、记录全局云台值
  161 + Gimbal_PitchAngle = angle;
  162 +
  163 + //3、叠加飞机角度和微调角度
  164 + Gimbal_RealPitchAngle = angle - Gimbal_UavSelfPitch + Get_V3S_TFA1_motor_precise_adjustment_pitch();
  165 +
  166 + //5、修正angle值
  167 + if (Gimbal_RealPitchAngle < -900)
  168 + {
  169 + angle = -900;
  170 + }
  171 + else if (Gimbal_RealPitchAngle > 0)
  172 + {
  173 + angle = 0;
  174 + }
  175 + else
  176 + {
  177 + angle = Gimbal_RealPitchAngle;
  178 + }
  179 +
  180 + //6、发送到V3S_TFA1控制云台函数
  181 + Gimbal_V3S_TFA1_set_angle(angle);
  182 +
  183 + //7、发送角度到飞机
  184 + Gimbal_ReplyPitchToUAV(Gimbal_PitchAngle);
  185 +
  186 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  187 + }
135 else if (DEVICE_VERSION == JZ_H1T) 188 else if (DEVICE_VERSION == JZ_H1T)
136 { 189 {
137 //1、判断输入范围是否正确 190 //1、判断输入范围是否正确
@@ -156,11 +209,9 @@ T_JZsdkReturnCode Gimbal_Set_PitchAngle(int angle) @@ -156,11 +209,9 @@ T_JZsdkReturnCode Gimbal_Set_PitchAngle(int angle)
156 //设置云台航向角度 209 //设置云台航向角度
157 int Gimbal_Set_YawAngle(int angle) 210 int Gimbal_Set_YawAngle(int angle)
158 { 211 {
159 - if (DEVICE_VERSION == JZ_H150S || DEVICE_VERSION == JZ_H150T)  
160 - {  
161 - printf("H150s没有航向角度\n"); 212 +
  213 + printf("没有航向角度\n");
162 return -1; 214 return -1;
163 - }  
164 215
165 } 216 }
166 217
@@ -180,6 +231,11 @@ T_JZsdkReturnCode Gimbal_SetGimbalRange(int value) @@ -180,6 +231,11 @@ T_JZsdkReturnCode Gimbal_SetGimbalRange(int value)
180 return V3S_U3_SetGimbalRange(value); 231 return V3S_U3_SetGimbalRange(value);
181 } 232 }
182 233
  234 + if (DEVICE_VERSION == TF_A1)
  235 + {
  236 + return V3S_TFA1_SetGimbalRange(value);
  237 + }
  238 +
183 if (DEVICE_VERSION == JZ_H1T) 239 if (DEVICE_VERSION == JZ_H1T)
184 { 240 {
185 /* code */ 241 /* code */
@@ -218,6 +274,18 @@ T_JZsdkReturnCode Gimbal_CheckStatus_GimbalFineTuning(int *FineTunigPitch, int * @@ -218,6 +274,18 @@ T_JZsdkReturnCode Gimbal_CheckStatus_GimbalFineTuning(int *FineTunigPitch, int *
218 return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS; 274 return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
219 } 275 }
220 276
  277 + if (DEVICE_VERSION == TF_A1)
  278 + {
  279 + //1、获取微调值
  280 + Gimbal_V3S_TFA1_CheckStatus_GimbalFineTuning(&Gimbal_PitchFineTuning);
  281 +
  282 + //2、回复微调值
  283 + *FineTunigPitch = Gimbal_PitchFineTuning;
  284 + *FineTunigYaw = Gimbal_YawFineTuning;
  285 +
  286 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  287 + }
  288 +
221 if (DEVICE_VERSION == JZ_H1T) 289 if (DEVICE_VERSION == JZ_H1T)
222 { 290 {
223 //1、刷新微调值 291 //1、刷新微调值
@@ -245,7 +313,6 @@ T_JZsdkReturnCode Gimbal_Obtain_GimbalFineTuning(int pitch) @@ -245,7 +313,6 @@ T_JZsdkReturnCode Gimbal_Obtain_GimbalFineTuning(int pitch)
245 //无操作 313 //无操作
246 } 314 }
247 315
248 -  
249 if (DEVICE_VERSION == JZ_U3) 316 if (DEVICE_VERSION == JZ_U3)
250 { 317 {
251 //无操作 318 //无操作
@@ -264,25 +331,39 @@ T_JZsdkReturnCode Gimbal_Obtain_GimbalFineTuning(int pitch) @@ -264,25 +331,39 @@ T_JZsdkReturnCode Gimbal_Obtain_GimbalFineTuning(int pitch)
264 T_JZsdkReturnCode Gimbal_Set_PitchFineTuning(int DeviceName ,int pitch) 331 T_JZsdkReturnCode Gimbal_Set_PitchFineTuning(int DeviceName ,int pitch)
265 { 332 {
266 printf("设置云台pitch云台微调值\n"); 333 printf("设置云台pitch云台微调值\n");
  334 + T_JZsdkReturnCode ret;
267 335
268 //原值+修改值 336 //原值+修改值
269 Gimbal_PitchFineTuning = Gimbal_PitchFineTuning + pitch; 337 Gimbal_PitchFineTuning = Gimbal_PitchFineTuning + pitch;
270 338
271 if (DEVICE_VERSION == JZ_H150S || DEVICE_VERSION == JZ_H150T) 339 if (DEVICE_VERSION == JZ_H150S || DEVICE_VERSION == JZ_H150T)
272 { 340 {
273 - return Gimbal_H3_H150ST_set_PitchFineTuning(pitch); 341 + ret = Gimbal_H3_H150ST_set_PitchFineTuning(pitch);
274 } 342 }
275 343
  344 + else if (DEVICE_VERSION == JZ_U3)
  345 + {
  346 + ret = Gimbal_V3S_U3_set_PitchFineTuning(pitch);
  347 + }
276 348
277 - if (DEVICE_VERSION == JZ_U3) 349 + else if (DEVICE_VERSION == TF_A1)
278 { 350 {
279 - return Gimbal_V3S_U3_set_PitchFineTuning(pitch); 351 + ret = Gimbal_V3S_TFA1_set_PitchFineTuning(pitch);
280 } 352 }
281 353
282 - if (DEVICE_VERSION == JZ_H1T) 354 + else if (DEVICE_VERSION == JZ_H1T)
283 { 355 {
284 - return Gimbal_V3S_H1T_set_PitchFineTuning(pitch); 356 + ret = Gimbal_V3S_H1T_set_PitchFineTuning(pitch);
285 } 357 }
  358 + else
  359 + {
  360 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  361 + }
  362 +
  363 + //微调后重设角度
  364 + Gimbal_Set_PitchAngle(Gimbal_PitchAngle);
  365 +
  366 + return ret;
286 } 367 }
287 368
288 //设置云台联动 369 //设置云台联动
@@ -371,7 +452,7 @@ T_JZsdkReturnCode Gimbal_Obtain_GimbalLinkage(int GimbalLinkage) @@ -371,7 +452,7 @@ T_JZsdkReturnCode Gimbal_Obtain_GimbalLinkage(int GimbalLinkage)
371 } 452 }
372 453
373 454
374 -//获取探警灯状态 455 +//获取数值角度
375 T_JZsdkReturnCode Gimbal_Get_Angle(int *PitchAngle, int *YawAngle) 456 T_JZsdkReturnCode Gimbal_Get_Angle(int *PitchAngle, int *YawAngle)
376 { 457 {
377 *PitchAngle = Gimbal_PitchAngle; 458 *PitchAngle = Gimbal_PitchAngle;
@@ -409,7 +490,122 @@ T_JZsdkReturnCode Gimbal_Get_PitchFineTuning() @@ -409,7 +490,122 @@ T_JZsdkReturnCode Gimbal_Get_PitchFineTuning()
409 return Gimbal_PitchFineTuning; 490 return Gimbal_PitchFineTuning;
410 } 491 }
411 492
  493 +//获得云台值
412 T_JZsdkReturnCode Gimbal_Obtain_Gimbal_Pitch(int Pitch) 494 T_JZsdkReturnCode Gimbal_Obtain_Gimbal_Pitch(int Pitch)
413 { 495 {
  496 +
  497 +//目前只有A1修改了真实角度值
  498 + if (DEVICE_VERSION == TF_A1)
  499 + {
  500 + //如果接受到的实际角度 - 飞机角度 + 微调角度 > 900 就不处理,避免角度左脚踩右脚上天
  501 + if ( (Pitch - Gimbal_UavSelfPitch + Get_V3S_TFA1_motor_precise_adjustment_pitch()) >900)
  502 + {
  503 + //Gimbal_PitchAngle不变
  504 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  505 + }
  506 + else
  507 + {
  508 + Gimbal_PitchAngle = (Pitch + Gimbal_UavSelfPitch - Get_V3S_TFA1_motor_precise_adjustment_pitch());
  509 + }
  510 + }
  511 + {
414 Gimbal_PitchAngle = Pitch; 512 Gimbal_PitchAngle = Pitch;
  513 + }
  514 +}
  515 +
  516 +/**************************************************************
  517 + *
  518 + *
  519 + * 飞机特殊控制云台方法
  520 + *
  521 + *
  522 +***************************************************************/
  523 +//1、飞机自身角度控制云台
  524 +T_JZsdkReturnCode Gimbal_PitchSelfangleMode(int Pitch)
  525 +{
  526 + if (Gimbal_UavSelfPitch == Pitch)
  527 + {
  528 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  529 + }
  530 +
  531 + Gimbal_UavSelfPitch = Pitch;
  532 +
  533 + //设置云台角度
  534 + Gimbal_Set_PitchAngle(Gimbal_PitchAngle);
  535 +
  536 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  537 +
  538 +}
  539 +
  540 +//2、滑动条控制云台
  541 +T_JZsdkReturnCode Gimbal_PitchScaleMode(int value)
  542 +{
  543 + int angle;
  544 + if (DEVICE_VERSION == TF_A1)
  545 + {
  546 + //0~100 转化为 -900~0
  547 + angle = value*9 -900;
  548 + }
  549 + else
  550 + {
  551 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  552 + }
  553 +
  554 + Gimbal_Set_PitchAngle(angle);
  555 +
  556 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  557 +}
  558 +
  559 +//3、拨轮控制云台
  560 +T_JZsdkReturnCode Gimbal_PitchRotationMode(int value)
  561 +{
  562 + int angle;
  563 +
  564 + if (DEVICE_VERSION == TF_A1)
  565 + {
  566 + angle = Gimbal_PitchAngle + value;
  567 + if (angle > 0)
  568 + {
  569 + angle = 0;
  570 + }
  571 + else if (angle < -900)
  572 + {
  573 + angle = -900;
  574 + }
  575 +
  576 + if (angle == Gimbal_PitchAngle)
  577 + {
  578 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  579 + }
  580 +
  581 + }
  582 + else
  583 + {
  584 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  585 + }
  586 +
  587 + Gimbal_Set_PitchAngle(angle);
  588 +
  589 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  590 +}
  591 +
  592 +//回复角度到飞机
  593 +T_JZsdkReturnCode Gimbal_ReplyPitchToUAV(int angle)
  594 +{
  595 + int value;
  596 +
  597 + if (DEVICE_VERSION == TF_A1)
  598 + {
  599 + //-900~0 转回 0~100
  600 + value = (angle+ 900)/9;
  601 + }
  602 + else
  603 + {
  604 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  605 + }
  606 +
  607 + JZsdk_Psdk_Ui_io_Gimbal_PitchPrint(value);
  608 +
  609 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  610 +
415 } 611 }
@@ -38,6 +38,11 @@ T_JZsdkReturnCode Gimbal_CheckStatus_GimbalLinkage(int *value); @@ -38,6 +38,11 @@ T_JZsdkReturnCode Gimbal_CheckStatus_GimbalLinkage(int *value);
38 T_JZsdkReturnCode Gimbal_Obtain_GimbalLinkage(int GimbalLinkage); 38 T_JZsdkReturnCode Gimbal_Obtain_GimbalLinkage(int GimbalLinkage);
39 T_JZsdkReturnCode Gimbal_CheckStatus_Angle(int *PitchAngle, int *YawAngle); 39 T_JZsdkReturnCode Gimbal_CheckStatus_Angle(int *PitchAngle, int *YawAngle);
40 40
  41 +T_JZsdkReturnCode Gimbal_PitchSelfangleMode(int Pitch);
  42 +T_JZsdkReturnCode Gimbal_PitchScaleMode(int value);
  43 +T_JZsdkReturnCode Gimbal_PitchRotationMode(int value);
  44 +T_JZsdkReturnCode Gimbal_ReplyPitchToUAV(int angle);
  45 +
41 #ifdef __cplusplus 46 #ifdef __cplusplus
42 } 47 }
43 #endif 48 #endif
  1 +#include <stdio.h>
  2 +#include <string.h>
  3 +#include <pthread.h>
  4 +#include <stdlib.h>
  5 +
  6 +#include <fcntl.h>
  7 +#include <unistd.h>
  8 +#include <termios.h>
  9 +#include <sys/time.h>
  10 +
  11 +static void *UartDeal_rece(void *arg);
  12 +static void *UartDeal_send(void *arg);
  13 +static int Gimbal_Uart_fd = 0;
  14 +
  15 +/******************************************************************
  16 +
  17 + 创建一个接收Gimbal的接收线程
  18 +
  19 +******************************************************************/
  20 +int Gimbal_UartDeal_Receive(int Uart_fd)
  21 +{
  22 + int ret = 0;
  23 + pthread_t Uart_rece_task;
  24 + Gimbal_Uart_fd = Uart_fd;
  25 +
  26 + pthread_attr_t task_attribute; //线程属性
  27 + pthread_attr_init(&task_attribute); //初始化线程属性
  28 + pthread_attr_setdetachstate(&task_attribute, PTHREAD_CREATE_DETACHED); //设置线程属性
  29 +
  30 + ret = pthread_create(&Uart_rece_task,&task_attribute,UartDeal_rece,NULL); //串口接收线程
  31 + if(ret != 0)
  32 + {
  33 + printf("创建展架串口接收线程失败!\n");
  34 + }
  35 + else{
  36 + printf("创建展架串口接收线程成功!\n");
  37 + }
  38 +}
  39 +
  40 +static void *UartDeal_rece(void *arg)
  41 +{
  42 + char getbuf[1024];
  43 +
  44 + int ret = 0;
  45 + fd_set fs_read;
  46 + struct timeval tv_timeout;
  47 +
  48 + //FD_ZERO 将指定的文件描述符集清空,在对文件描述符集合进行设置前,必须对其进行初始化
  49 + //如果不清空,由于在系统分配内存空间后,通常并不作清空处理,所以结果是不可知的。
  50 + FD_ZERO(&fs_read);
  51 +
  52 + //FD_SET 用于在文件描述符集合中增加一个新的文件描述符。
  53 + FD_SET(Gimbal_Uart_fd, &fs_read);
  54 +
  55 + //115200 / char 8 位 = 14400 个char数据
  56 + tv_timeout.tv_sec = 6000;//(10*20/115200+2);
  57 + tv_timeout.tv_usec = 0;
  58 +
  59 + //2、正常接收
  60 + while(1)
  61 + {
  62 + //检查fs_read套节字是否有数据
  63 + select(Gimbal_Uart_fd+1, &fs_read, NULL, NULL, &tv_timeout);
  64 + usleep(10000);
  65 +
  66 + //FD_ISSET 用于测试指定的文件描述符是否在该集合中。
  67 + //Gimbal_Uart_fd 是否在fsread中
  68 + if (FD_ISSET(Gimbal_Uart_fd, &fs_read))
  69 + {
  70 + //1、读取串口内容 ret 接收长度 getbuf 获取的字符
  71 + memset(getbuf,0,sizeof(getbuf)); //清空接收数组
  72 + ret = read(Gimbal_Uart_fd,getbuf,sizeof(getbuf));
  73 +
  74 + //printf("Gimbalret: %d Gimbalgetbuf: %s\n", ret, getbuf);
  75 + // for (int i = 0; i < ret; i++)
  76 + // {
  77 + // printf("%x ",getbuf[i]);
  78 + // }
  79 + // printf("\n");
  80 +
  81 + //Comm_4G_RecvCharmDeal(getbuf, ret);
  82 + }
  83 + }
  84 +
  85 +}
  86 +
  87 +
  88 +/****************
  89 + *
  90 + *
  91 + * 发送函数
  92 + *
  93 + * ****************/
  94 +int Gimbal_UartSend(unsigned char *send, int num)
  95 +{
  96 +
  97 + write(Gimbal_Uart_fd,send, num);
  98 + return 0;
  99 +}
  1 +/**
  2 + ********************************************************************
  3 + * @file Gimbal_UartDeal.h
  4 + * Gimbal_UartDeal的头文件
  5 + *
  6 + *********************************************************************
  7 + */
  8 +
  9 +/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
  10 +#ifndef GIMBAL_UART_DEAL_H
  11 +#define GIMBAL_UART_DEAL_H
  12 +
  13 +/* Includes ------------------------------------------------------------------*/
  14 +
  15 +#ifdef __cplusplus
  16 +extern "C" {
  17 +#endif
  18 +
  19 +/* Exported constants --------------------------------------------------------*/
  20 +/* 常亮定义*/
  21 +
  22 +/* Exported types ------------------------------------------------------------*/
  23 +
  24 +/* Exported functions --------------------------------------------------------*/
  25 +int Gimbal_UartDeal_Receive(int Uart_fd);
  26 +int Gimbal_UartSend(unsigned char *send, int num);
  27 +
  28 +#ifdef __cplusplus
  29 +}
  30 +#endif
  31 +
  32 +#endif
@@ -21,6 +21,7 @@ extern "C" { @@ -21,6 +21,7 @@ extern "C" {
21 #include "Gimbal_V3S_H10T/Gimbal_V3S_H10T.h" 21 #include "Gimbal_V3S_H10T/Gimbal_V3S_H10T.h"
22 #include "Gimbal_V3S_U3/Gimbal_V3S_U3.h" 22 #include "Gimbal_V3S_U3/Gimbal_V3S_U3.h"
23 #include "Gimbal_V3S_H1T/Gimbal_V3S_H1T.h" 23 #include "Gimbal_V3S_H1T/Gimbal_V3S_H1T.h"
  24 +#include "Gimbal_V3S_TFA1/Gimbal_V3S_TFA1.h"
24 25
25 /* Exported types ------------------------------------------------------------*/ 26 /* Exported types ------------------------------------------------------------*/
26 27
  1 +/* Includes ------------------------------------------------------------------*/
  2 +#include <stdio.h>
  3 +#include <pthread.h>
  4 +#include <stdlib.h>
  5 +
  6 +#include "../Ircut/H3_ircut/wiringPi/wiringPi.h"
  7 +#include "./Gimbal_V3S_TFA1.h"
  8 +#include "JZsdk_Uart_Input.h"
  9 +
  10 +#include "ircut.h"
  11 +#include "BaseConfig.h"
  12 +
  13 +/* Private constants ---------------------------------------------------------*/
  14 +#define MOTOR_FILE_PATH "/root/motor"
  15 +
  16 +#define V3S_TFA1_MOTOR_ADJUSTMENT 5 //云台微调值
  17 +
  18 +/* Private types -------------------------------------------------------------*/
  19 +
  20 +/* Private functions declaration ---------------------------------------------*/
  21 +
  22 +static int V3S_TFA1_motor_precise_adjustment_pitch =0;//默认微调值为0
  23 +
  24 +static void *Gimbal_V3S_TFA1_Motor_control(void *arg);
  25 +static int V3S_TFA1_Read_MotorAdjustmentPitch(void);
  26 +static void V3S_TFA1_Write_MotorAdjustmentPitch(int MotorAdjustmentPitch);
  27 +
  28 +void Gimbal_V3S_TFA1_init_motor(void)
  29 +{
  30 + V3S_TFA1_motor_precise_adjustment_pitch = V3S_TFA1_Read_MotorAdjustmentPitch();//获取微调角度-读文件获取
  31 + Gimbal_V3S_TFA1_set_angle(0);
  32 +}
  33 +
  34 +
  35 +static int Gimbal_TFA1_sendAngle(int angle)
  36 +{
  37 + if(angle >= 0 )
  38 + {
  39 + angle = 0;
  40 + }
  41 + else if(angle <= -900)
  42 + {
  43 + angle = -900;
  44 + }
  45 +
  46 + else if( (angle > -900) && (angle < 0) )
  47 + {
  48 + //angle不变
  49 + }
  50 +
  51 + //发送角度给串口2
  52 + JZsdk_Uart_Send_SetGimbalPitch(UART_DEV_2, angle);
  53 +}
  54 +
  55 +int Gimbal_V3S_TFA1_set_angle(int angle)
  56 +{
  57 + Gimbal_TFA1_sendAngle(angle);
  58 +
  59 + // pthread_t MOTOR_task;
  60 + // pthread_attr_t task_attribute; //线程属性
  61 + // pthread_attr_init(&task_attribute); //初始化线程属性
  62 + // pthread_attr_setdetachstate(&task_attribute, PTHREAD_CREATE_DETACHED); //设置线程属性
  63 +
  64 + // int *arg = (int*) malloc(sizeof(int)); // 分配动态内存
  65 +
  66 + // *arg = angle; // 将参数值保存到动态内存中
  67 +
  68 + // int angle_ret = pthread_create(&MOTOR_task,&task_attribute,Gimbal_V3S_TFA1_Motor_control,arg); //TTS mobie
  69 + // if(angle_ret != 0)
  70 + // {
  71 + // printf("创建motor线程失败!\n");
  72 + // return -1;
  73 + // }
  74 + // else
  75 + // {
  76 + // printf("创建motor线程成功\n");
  77 + // }
  78 +
  79 + // return 0;
  80 +}
  81 +
  82 +
  83 +//控制电机线程
  84 +static void *Gimbal_V3S_TFA1_Motor_control(void *arg)
  85 +{
  86 + //传入的角度 -900~0
  87 + int angle = *(int*)arg;
  88 +
  89 + //微调角度值 移动到上一步
  90 + //angle = angle + V3S_TFA1_motor_precise_adjustment_pitch;
  91 +
  92 + printf("V3S_TFA1_RealAngle:%d\n",angle);
  93 +
  94 + if(angle >= 0 )
  95 + {
  96 + angle = 0;
  97 + }
  98 + else if(angle <= -900)
  99 + {
  100 + angle = -900;
  101 + }
  102 +
  103 + else if( (angle > -900) && (angle < 0) )
  104 + {
  105 + //angle不变
  106 + }
  107 +
  108 + //发送角度给串口2
  109 + JZsdk_Uart_Send_SetGimbalPitch(UART_DEV_2, angle);
  110 +
  111 + free(arg); // 在线程函数中释放动态内存
  112 +}
  113 +
  114 +//云台微调
  115 +T_JZsdkReturnCode Gimbal_V3S_TFA1_set_PitchFineTuning(int Pitch)
  116 +{
  117 + //微调的角度值 提高Pitch
  118 + V3S_TFA1_motor_precise_adjustment_pitch += Pitch;
  119 +
  120 + //写入本地文件
  121 + V3S_TFA1_Write_MotorAdjustmentPitch(V3S_TFA1_motor_precise_adjustment_pitch);
  122 +
  123 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  124 +
  125 +}
  126 +
  127 +//从文件中读出电机微调值
  128 +static int V3S_TFA1_Read_MotorAdjustmentPitch(void)
  129 +{
  130 + FILE *motor_file;
  131 + int MotorAdjustmentPitch = 0;
  132 + motor_file = fopen(MOTOR_FILE_PATH, "rb+");
  133 + if (motor_file == NULL)
  134 + {
  135 + motor_file = fopen(MOTOR_FILE_PATH, "wb+");
  136 + if (motor_file == NULL)
  137 + {
  138 + return 0;
  139 + }
  140 + }
  141 + else
  142 + {
  143 + int ret = fseek(motor_file, 0, SEEK_SET);
  144 + if (ret != 0) {
  145 + printf("Seek log count file error, ret: %d.\r\n", ret);
  146 + }
  147 +
  148 + ret = fread((unsigned int *) &MotorAdjustmentPitch, 1, sizeof(unsigned int), motor_file);
  149 + if (ret != sizeof(unsigned int)) {
  150 + printf("Read motor weitiao error.\r\n");
  151 + }
  152 + else{
  153 + printf("Read motor weitiao=%d\n",MotorAdjustmentPitch);
  154 + }
  155 + }
  156 + fclose(motor_file);
  157 +
  158 + return MotorAdjustmentPitch;
  159 +}
  160 +
  161 +//写入电机微调值刀文件中
  162 +static void V3S_TFA1_Write_MotorAdjustmentPitch(int MotorAdjustmentPitch)
  163 +{
  164 + //写入文件
  165 + FILE *motor_file;
  166 + motor_file = fopen(MOTOR_FILE_PATH, "wb+");
  167 + int ret = fwrite((unsigned int *) &MotorAdjustmentPitch, 1, sizeof(unsigned int),motor_file);
  168 + if (ret != sizeof(unsigned int)) {
  169 + printf("Write motor weitiao error.\r\n");
  170 + }
  171 + else{
  172 + printf("Write motor weitiao=%d\n",MotorAdjustmentPitch);
  173 + }
  174 +
  175 + fclose(motor_file);
  176 +}
  177 +
  178 +int Gimbal_V3S_TFA1_CheckStatus_GimbalFineTuning(int *AdjustmentPitch)
  179 +{
  180 + *AdjustmentPitch = V3S_TFA1_motor_precise_adjustment_pitch;
  181 +}
  182 +
  183 +//TFA1范围
  184 +T_JZsdkReturnCode V3S_TFA1_SetGimbalRange(int Range)
  185 +{
  186 + if (Range == 0xFF)
  187 + {
  188 + printf("设置TFA1云台最大值\n");
  189 + JZsdk_Uart_Send_SetGimbalRange(UART_DEV_2, 0, Range);
  190 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  191 + }
  192 + else if (Range == 0x00)
  193 + {
  194 + printf("设置TFA1云台最小值\n");
  195 + JZsdk_Uart_Send_SetGimbalRange(UART_DEV_2, 0, Range);
  196 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  197 + }
  198 +
  199 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  200 +}
  201 +
  202 +int Get_V3S_TFA1_motor_precise_adjustment_pitch()
  203 +{
  204 + return V3S_TFA1_motor_precise_adjustment_pitch;
  205 +}
  1 +/**
  2 + ********************************************************************
  3 + * @file Gimbal_V3S_TFA1.h
  4 + * v3s板子的A1云台头文件
  5 + *
  6 + *********************************************************************
  7 + */
  8 +
  9 +/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
  10 +#ifndef GIMBAL_V3S_TFA1_H
  11 +#define GIMBAL_V3S_TFA1_H
  12 +
  13 +/* Includes ------------------------------------------------------------------*/
  14 +#include "JZsdk_Base/JZsdk_Code/JZsdk_Code.h"
  15 +
  16 +#ifdef __cplusplus
  17 +extern "C" {
  18 +#endif
  19 +
  20 +/* Exported constants --------------------------------------------------------*/
  21 +/* 常亮定义*/
  22 +
  23 +/* Exported types ------------------------------------------------------------*/
  24 +
  25 +/* Exported functions --------------------------------------------------------*/
  26 +void Gimbal_V3S_TFA1_init_motor(void);
  27 +int Gimbal_V3S_TFA1_set_angle(int angle);
  28 +T_JZsdkReturnCode V3S_TFA1_SetGimbalRange(int Range);
  29 +T_JZsdkReturnCode Gimbal_V3S_TFA1_set_PitchFineTuning(int Pitch);
  30 +int Gimbal_V3S_TFA1_CheckStatus_GimbalFineTuning(int *AdjustmentPitch);
  31 +int Get_V3S_TFA1_motor_precise_adjustment_pitch();
  32 +
  33 +
  34 +
  35 +#ifdef __cplusplus
  36 +}
  37 +#endif
  38 +
  39 +#endif
@@ -73,6 +73,9 @@ static int PowerContorl; @@ -73,6 +73,9 @@ static int PowerContorl;
73 #elif DEVICE_VERSION == JZ_U3 73 #elif DEVICE_VERSION == JZ_U3
74 #define AMPLIFIER_PIN PB 74 #define AMPLIFIER_PIN PB
75 #define AMPLIFIER_PIN_NUM 4 75 #define AMPLIFIER_PIN_NUM 4
  76 +#elif DEVICE_VERSION == TF_A1
  77 + #define AMPLIFIER_PIN PG
  78 + #define AMPLIFIER_PIN_NUM 5
76 #else 79 #else
77 #define AMPLIFIER_PIN PB 80 #define AMPLIFIER_PIN PB
78 #define AMPLIFIER_PIN_NUM 4 81 #define AMPLIFIER_PIN_NUM 4
@@ -9,7 +9,7 @@ static int OutPutPower = JZ_FLAGCODE_OFF; @@ -9,7 +9,7 @@ static int OutPutPower = JZ_FLAGCODE_OFF;
9 9
10 void Ircut_Init()//引脚初始化 10 void Ircut_Init()//引脚初始化
11 { 11 {
12 - if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T || DEVICE_VERSION == JZ_H10T || DEVICE_VERSION == JZ_U3) 12 + if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T || DEVICE_VERSION == JZ_H10T || DEVICE_VERSION == JZ_U3 || DEVICE_VERSION == TF_A1)
13 { 13 {
14 V3s_Ircut_Init(); 14 V3s_Ircut_Init();
15 } 15 }
@@ -38,7 +38,7 @@ int Ircut_uInit() @@ -38,7 +38,7 @@ int Ircut_uInit()
38 //功放开关 38 //功放开关
39 void set_amplifier(int amplifier_mode) 39 void set_amplifier(int amplifier_mode)
40 { 40 {
41 - if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T || DEVICE_VERSION == JZ_H10T || DEVICE_VERSION == JZ_U3) 41 + if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T || DEVICE_VERSION == JZ_H10T || DEVICE_VERSION == JZ_U3 || DEVICE_VERSION == TF_A1)
42 { 42 {
43 V3s_set_amplifier(amplifier_mode); 43 V3s_set_amplifier(amplifier_mode);
44 } 44 }
@@ -5,6 +5,9 @@ @@ -5,6 +5,9 @@
5 #include "Lighting_InAndOut.h" 5 #include "Lighting_InAndOut.h"
6 #include "./SearchLight/SearchLight_V3S/SearchLight_V3S.h" 6 #include "./SearchLight/SearchLight_V3S/SearchLight_V3S.h"
7 #include "./WarningLight/WarningLight_V3S/WarningLight_V3S.h" 7 #include "./WarningLight/WarningLight_V3S/WarningLight_V3S.h"
  8 +#include "SearchLight/SearchLightTemControl/SearchLightTemControl.h"
  9 +#include "UI_control.h"
  10 +#include "BaseConfig.h"
8 11
9 static int SearchLight_Frequency; //探照灯频率 12 static int SearchLight_Frequency; //探照灯频率
10 static int SearchLight_Mode; //探照灯模式 13 static int SearchLight_Mode; //探照灯模式
@@ -19,6 +22,14 @@ static int WarningLight_Mode; //警灯模式 @@ -19,6 +22,14 @@ static int WarningLight_Mode; //警灯模式
19 static int WarningLight_Color1; //警灯颜色1 22 static int WarningLight_Color1; //警灯颜色1
20 static int WarningLight_Color2; //警灯颜色2 23 static int WarningLight_Color2; //警灯颜色2
21 24
  25 +#define MAX(a,b) ( (a>b) ?a:b )
  26 +
  27 +T_JZsdkReturnCode Lighting_Init()
  28 +{
  29 + //温控初始化
  30 + JZsdk_SearchLightTemControl_Init();
  31 +}
  32 +
22 /******************************************************************************************************************************** 33 /********************************************************************************************************************************
23 * 34 *
24 * 探照灯 灯光属性 35 * 探照灯 灯光属性
@@ -63,7 +74,10 @@ T_JZsdkReturnCode Lighting_SearchLightControl(int mode) @@ -63,7 +74,10 @@ T_JZsdkReturnCode Lighting_SearchLightControl(int mode)
63 { 74 {
64 return SearchLight_V3S_H1T_SearchLightControl(mode); 75 return SearchLight_V3S_H1T_SearchLightControl(mode);
65 } 76 }
66 - 77 + else if (DEVICE_VERSION == TF_A1)
  78 + {
  79 + return SearchLight_V3S_TFA1_SearchLightControl(mode);
  80 + }
67 81
68 return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE; 82 return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
69 } 83 }
@@ -113,7 +127,10 @@ T_JZsdkReturnCode Lighting_Set_SearchLightLumen(int LeftLumen, int RightLumen) @@ -113,7 +127,10 @@ T_JZsdkReturnCode Lighting_Set_SearchLightLumen(int LeftLumen, int RightLumen)
113 { 127 {
114 return SearchLight_V3S_H1T_Set_SearchLightLumen(LeftLumen, RightLumen); 128 return SearchLight_V3S_H1T_Set_SearchLightLumen(LeftLumen, RightLumen);
115 } 129 }
116 - 130 + else if (DEVICE_VERSION == TF_A1)
  131 + {
  132 + return SearchLight_V3S_TFA1_Set_SearchLightLumen(LeftLumen, RightLumen);
  133 + }
117 134
118 return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE; 135 return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
119 } 136 }
@@ -164,7 +181,10 @@ T_JZsdkReturnCode Lighting_Set_SearchLightFrequency(int value) @@ -164,7 +181,10 @@ T_JZsdkReturnCode Lighting_Set_SearchLightFrequency(int value)
164 { 181 {
165 return SearchLight_V3S_H1T_Set_SearchLightFrequency(value); 182 return SearchLight_V3S_H1T_Set_SearchLightFrequency(value);
166 } 183 }
167 - 184 + else if (DEVICE_VERSION == TF_A1)
  185 + {
  186 + return SearchLight_V3S_TFA1_Set_SearchLightFrequency(value);
  187 + }
168 188
169 return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE; 189 return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
170 } 190 }
@@ -199,14 +219,92 @@ T_JZsdkReturnCode Lighting_CheckStatus_SearchLightFrequency() @@ -199,14 +219,92 @@ T_JZsdkReturnCode Lighting_CheckStatus_SearchLightFrequency()
199 * 探照灯 温度相关 219 * 探照灯 温度相关
200 * 220 *
201 ********************************************************************************************************************************/ 221 ********************************************************************************************************************************/
  222 +static int Light_Luminance_StepBack_Calculation(int temper, int liumin)
  223 +{
  224 +
  225 + //以下为假设值 未经实测
  226 + //以70度 为过热标准 91 为顶峰
  227 + //70度~ 73 度时 每次降低2亮度
  228 + //74~78时 每次降低3
  229 + //79~84时 每次降低5
  230 + //85~ 91时 每次降低8
  231 + //大于91时 每次降低12
  232 + //不过超过80后 灯那边会被强制关掉
  233 + int StepBackValue = 0;
  234 + if ( (temper >= 70 ) && (temper <= 73) )
  235 + {
  236 + StepBackValue = 1;
  237 + }
  238 + else if ( (temper >= 74 ) && (temper <= 78) )
  239 + {
  240 + StepBackValue = 2;
  241 + }
  242 + else if ( (temper >= 79 ) && (temper <= 84) )
  243 + {
  244 + StepBackValue = 4;
  245 + }
  246 + else if ( (temper >= 85 ) && (temper <= 91))
  247 + {
  248 + StepBackValue = 6;
  249 + }
  250 + else if ( (temper > 91 ))
  251 + {
  252 + StepBackValue = 8;
  253 + }
  254 + else
  255 + {
  256 + StepBackValue = 0;
  257 + }
  258 +
  259 + return (liumin - StepBackValue);
  260 +}
  261 +
202 //收到并修改探照灯的温度(中继修改) 262 //收到并修改探照灯的温度(中继修改)
203 T_JZsdkReturnCode Lighting_Obtain_SearchLightTemperature(int LeftTemperature, int RightTemperature) 263 T_JZsdkReturnCode Lighting_Obtain_SearchLightTemperature(int LeftTemperature, int RightTemperature)
204 { 264 {
205 - printf("%x探照灯温度改变左灯%d 右灯%d\n",DEVICE_VERSION, LeftTemperature ,RightTemperature); 265 + printf("设备0x1010%x探照灯温度改变左灯%d 右灯%d\n",DEVICE_VERSION, LeftTemperature ,RightTemperature);
206 266
207 SearchLight_LeftTemperature = LeftTemperature; 267 SearchLight_LeftTemperature = LeftTemperature;
208 SearchLight_RightTemperature = RightTemperature; 268 SearchLight_RightTemperature = RightTemperature;
209 269
  270 + int Max_tmeperature, Max_Liuminance;
  271 +
  272 + Max_tmeperature = MAX(LeftTemperature, RightTemperature);
  273 + Max_Liuminance = MAX(SearchLight_LeftLumen, SearchLight_RightLumen);
  274 +
  275 + int TempLumen;//临时亮度
  276 +
  277 + //如果是JZ u3
  278 + if (DEVICE_VERSION == JZ_U3)
  279 + {
  280 +
  281 + if (Max_tmeperature >= 70)
  282 + {
  283 + //温控开始
  284 + Max_Liuminance = Light_Luminance_StepBack_Calculation(Max_tmeperature, Max_Liuminance);
  285 +
  286 + //重设亮度
  287 + Lighting_Set_SearchLightLumen(Max_Liuminance, Max_Liuminance);
  288 +
  289 + }
  290 +
  291 +
  292 + }
  293 + if (DEVICE_VERSION == TF_A1)
  294 + {
  295 + //温控开始
  296 + TempLumen = JZsdk_SearchLightTemControl_Input(Max_tmeperature, Max_Liuminance);
  297 +
  298 + if (TempLumen != Max_Liuminance)
  299 + {
  300 + //重设亮度
  301 + //Lighting_Set_SearchLightLumen(TempLumen, TempLumen);
  302 + UIcontrol_Set_SearchLightLumen(NO_SPECIFIED, 0, TempLumen, TempLumen);
  303 + }
  304 + }
  305 +
  306 +
  307 +
210 return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS; 308 return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
211 } 309 }
212 310
@@ -244,13 +342,17 @@ T_JZsdkReturnCode Lighting_Set_WarningLight_Status(int status, int mode) @@ -244,13 +342,17 @@ T_JZsdkReturnCode Lighting_Set_WarningLight_Status(int status, int mode)
244 { 342 {
245 printf("设置0x%x:警灯状态\n",DEVICE_VERSION); 343 printf("设置0x%x:警灯状态\n",DEVICE_VERSION);
246 344
247 - if (DEVICE_VERSION == JZ_H1T)  
248 - {  
249 - return WarningLight_V3S_H1T_Set_WarningLight_Status(status, mode);  
250 - }  
251 345
  346 +#if DEVICE_VERSION == JZ_H1T
  347 + return WarningLight_V3S_H1T_Set_WarningLight_Status(status, mode);
252 348
  349 +#elif DEVICE_VERSION == TF_A1
  350 + return WarningLight_V3S_TFA1_Set_WarningLight_Status(status, mode);
  351 +#else
253 return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE; 352 return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  353 +#endif
  354 +
  355 +
254 } 356 }
255 357
256 //收到并修改警灯状态 358 //收到并修改警灯状态
@@ -302,10 +404,14 @@ T_JZsdkReturnCode Lighting_Set_WarningLight_Color(int color1, int color2) @@ -302,10 +404,14 @@ T_JZsdkReturnCode Lighting_Set_WarningLight_Color(int color1, int color2)
302 { 404 {
303 printf("设置0x%x:警灯颜色\n",DEVICE_VERSION); 405 printf("设置0x%x:警灯颜色\n",DEVICE_VERSION);
304 406
305 - if (DEVICE_VERSION == JZ_H1T)  
306 - { 407 +#if DEVICE_VERSION == JZ_H1T
307 return WarningLight_V3S_H1T_Set_WarningLight_Color(color1, color2); 408 return WarningLight_V3S_H1T_Set_WarningLight_Color(color1, color2);
308 - } 409 +
  410 +#elif DEVICE_VERSION == TF_A1
  411 + return WarningLight_V3S_TFA1_Set_WarningLight_Color(color1, color2);
  412 +#else
  413 + return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
  414 +#endif
309 415
310 416
311 return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE; 417 return JZ_ERROR_SYSTEM_MODULE_CODE_FAILURE;
@@ -23,6 +23,8 @@ extern "C" { @@ -23,6 +23,8 @@ extern "C" {
23 /* Exported types ------------------------------------------------------------*/ 23 /* Exported types ------------------------------------------------------------*/
24 24
25 /* Exported functions --------------------------------------------------------*/ 25 /* Exported functions --------------------------------------------------------*/
  26 +T_JZsdkReturnCode Lighting_Init();
  27 +
26 T_JZsdkReturnCode Lighting_CheckStatus_SearchLightLightAttribute(int *ValueFrequency, int *ValueMode, int *ValueLeftLumen, int *ValueRightLumen); 28 T_JZsdkReturnCode Lighting_CheckStatus_SearchLightLightAttribute(int *ValueFrequency, int *ValueMode, int *ValueLeftLumen, int *ValueRightLumen);
27 29
28 T_JZsdkReturnCode Lighting_SearchLightControl(int mode); 30 T_JZsdkReturnCode Lighting_SearchLightControl(int mode);
  1 +/****************************************************/
  2 +#include <stdio.h>
  3 +#include "version_choose.h"
  4 +
  5 +
  6 +typedef enum {
  7 + DEFAULT_STATUS = 0x0000, //默认状态
  8 + LUMEN_UP = 0x0001, //温度提高
  9 + LUMEN_DOWN =0x0002, //温度降低
  10 +
  11 +} JZ_TemControl_Code;
  12 +
  13 +// typedef enum {
  14 +// JZ_T30 = 0x0000,
  15 +// JZ_T60 = 0x0001,
  16 +// JZ_T90 = 0x0002,
  17 +// JZ_T60S = 0x0003,
  18 +// JZ_U3 = 0x0004,
  19 +// JZ_A1 = 0x0005,
  20 +// } JZ_DeviceModel_Code;
  21 +
  22 +static int InitialLumen = 0; //最初亮度
  23 +
  24 +
  25 +/***
  26 + *
  27 + * 控件修改时,给温控模块一个亮度初值
  28 + *
  29 + * ****/
  30 +int JZsdk_SearchLightSetInitialLumen(int value)
  31 +{
  32 + if (InitialLumen >= 100)
  33 + {
  34 + InitialLumen = 100;
  35 + }
  36 + else if (InitialLumen <= 0)
  37 + {
  38 + InitialLumen = 0;
  39 + }
  40 +
  41 + InitialLumen = value;
  42 +}
  43 +
  44 +/***
  45 + *
  46 + * 获取限制温度
  47 + *
  48 + * ****/
  49 +static int JZsdk_SearchLightGetLimitTemp(int DeviceMode)
  50 +{
  51 + switch (DeviceMode)
  52 + {
  53 + // case JZ_T30:
  54 + // return 65;
  55 + // break;
  56 +
  57 + // case JZ_T60:
  58 + // return 80;
  59 + // break;
  60 +
  61 + // case JZ_T90:
  62 + // return 70;
  63 + // break;
  64 +
  65 + // case JZ_T60S:
  66 + // return 65;
  67 + // break;
  68 +
  69 + case JZ_U3:
  70 + return 70;
  71 + break;
  72 +
  73 + case TF_A1:
  74 + return 70;
  75 + break;
  76 +
  77 + default:
  78 + break;
  79 + }
  80 +
  81 + return -1;
  82 +}
  83 +
  84 +/***
  85 + *
  86 + * 根据超出范围/ 小于范围 获取温控时间
  87 + * 如果要优化,可以改成余弦曲线
  88 + * ****/
  89 +static int JZsdk_SearchLightGetLumenControlTime(float value)
  90 +{
  91 + //如果范围在0.4度以内
  92 + if (value <= 0.4)
  93 + {
  94 + return 5000; //延时5000ms
  95 + }
  96 + //0.4~1.0
  97 + else if ( (value > 0.4) && (value <= 1.0))
  98 + {
  99 + return 4600;
  100 + }
  101 + //1.0~1.8
  102 + else if ( (value > 1.0) && (value <= 1.8))
  103 + {
  104 + return 4100;
  105 + }
  106 + //1.8~2.8
  107 + else if ( (value > 1.8) && (value <= 2.8))
  108 + {
  109 + return 3500;
  110 + }
  111 + //2.8~4.0
  112 + else if ( (value > 2.8) && (value <= 4.0))
  113 + {
  114 + return 2800;
  115 + }
  116 + //4.0~5.4
  117 + else if ( (value > 4.0) && (value <= 5.4))
  118 + {
  119 + return 2000;
  120 + }
  121 + //5.4~7.0
  122 + else if ( (value > 5.4) && (value <= 7.0))
  123 + {
  124 + return 1100;
  125 + }
  126 + //7.0~9.8
  127 + else if ( (value > 7.0) && (value <= 9.8))
  128 + {
  129 + return 200;
  130 + }
  131 + else
  132 + {
  133 + return 100;
  134 + }
  135 +}
  136 +
  137 +int JZsdk_SearchLightTemControl(float InputTemp, int InputLumen, int *OutputLumen, int *OutputDelay)
  138 +{
  139 + //初始化
  140 + *OutputLumen = 0;
  141 + *OutputDelay = 0;
  142 + int ControlFlag = DEFAULT_STATUS; //无变化为0, 升温为1,降温为2
  143 + float TempRange = 0; //温度范围
  144 + int LumenVariation = 0; //亮度变化值
  145 +
  146 + //1、获取限制温度
  147 + int LimitTemp = JZsdk_SearchLightGetLimitTemp(DEVICE_VERSION);
  148 + if (LimitTemp == -1)
  149 + {
  150 + //没有对应的限制温度,返回失败及亮度0
  151 + *OutputLumen = 0;
  152 + *OutputDelay = 0;
  153 + return -1;
  154 + }
  155 +
  156 + //2、判断是否要升高/降低温度 以及 获取差距范围
  157 + //如果输入的温度高于限制温度,说明要降亮度
  158 + if (InputTemp >= LimitTemp)
  159 + {
  160 + TempRange = InputTemp - LimitTemp;
  161 +
  162 + //控制标志位: 降低亮度
  163 + ControlFlag = LUMEN_DOWN;
  164 + }
  165 + //如果输出的温度 小于限制温度,则要判断输入亮度与亮度初值的关系
  166 + else if (InputTemp < LimitTemp)
  167 + {
  168 + //如果输入亮度小于初值亮度
  169 + if (InputLumen < InitialLumen)
  170 + {
  171 + TempRange = LimitTemp - InputTemp;
  172 +
  173 + //控制标志位:提高亮度
  174 + ControlFlag = LUMEN_UP;
  175 + }
  176 + //否则,不用进行处理
  177 + else
  178 + {
  179 + *OutputLumen = InputLumen;
  180 + *OutputDelay = 0;
  181 + ControlFlag = DEFAULT_STATUS;
  182 + return 0;
  183 + }
  184 + }
  185 +
  186 + //3、根据输入的温度范围 获取降低/升高 的时间间隔
  187 + *OutputDelay = JZsdk_SearchLightGetLumenControlTime(TempRange);
  188 +
  189 + //4、根据输入的温度范围 获取降低/升高 的亮度的步长 并 加上原亮度 得到新亮度
  190 + //暂时固定一度
  191 + if (ControlFlag == LUMEN_DOWN)
  192 + {
  193 + *OutputLumen = InputLumen - 1;
  194 +
  195 + //由于温度需要下降,说明初值亮度还是太高了
  196 + //将初值亮度降低2点
  197 + InitialLumen = InitialLumen-2;
  198 + }
  199 + else if (ControlFlag == LUMEN_UP)
  200 + {
  201 + *OutputLumen = InputLumen + 1;
  202 + }
  203 + else
  204 + {
  205 + //没有对应的标志位,温控失败
  206 + *OutputLumen = 0;
  207 + *OutputDelay = 0;
  208 + return -1;
  209 + }
  210 +
  211 + return 0;
  212 +}
  1 +/**
  2 + ********************************************************************
  3 + * @file JZ_SearchLightTemp_calculation.h
  4 + * JZ_SearchLightTemp_calculation.c的头文件
  5 + *
  6 + *
  7 + *********************************************************************
  8 + */
  9 +
  10 +/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
  11 +#ifndef JZ_SEARCHLIGHT_TEMP_CALCULATION_H
  12 +#define JZ_SEARCHLIGHT_TEMP_CALCULATION_H
  13 +
  14 +/* Includes ------------------------------------------------------------------*/
  15 +
  16 +int JZsdk_SearchLightSetInitialLumen(int value);
  17 +int JZsdk_SearchLightTemControl(float InputTemp, int InputLumen, int *OutputLumen, int *OutputDelay);
  18 +
  19 +
  20 +#endif
  1 +#include <stdio.h>
  2 +#include "Psdk_UI_io.h"
  3 +#include "JZsdk_Base/JZsdk_Code/JZsdk_InsCode.h"
  4 +#include "BaseConfig.h"
  5 +#include "Megaphone_InputAndOutput.h"
  6 +#include "JZsdkLib.h"
  7 +#include "UI_control.h"
  8 +#include <unistd.h>
  9 +#include <string.h>
  10 +#include <pthread.h>
  11 +
  12 +#include "./JZ_SearchLightTemp_calculation.h"
  13 +#include "./SearchLightTemControl.h"
  14 +
  15 +
  16 +static int g_InputTemp = 0;
  17 +static int g_InputLumen = 0;
  18 +static int g_OutputLumen = 0;
  19 +
  20 +//1、输入函数
  21 +T_JZsdkReturnCode JZsdk_SearchLightTemControl_Input(int InputTemp, int InputLumen)
  22 +{
  23 + //输入参数
  24 + g_InputTemp = InputTemp;
  25 + g_InputLumen = InputLumen;
  26 +
  27 + delayMs(1);
  28 +
  29 + return g_OutputLumen;
  30 +}
  31 +
  32 +//2、刷新亮度函数
  33 +T_JZsdkReturnCode JZsdk_SearchLightTemControl_FlushLumen(int InputLumen)
  34 +{
  35 + g_InputLumen = InputLumen;
  36 + JZsdk_SearchLightSetInitialLumen(g_InputLumen);
  37 +}
  38 +
  39 +//控温线程
  40 +static void *TempControl_Task(void *arg)
  41 +{
  42 + int DelayTime;
  43 +
  44 + while (1)
  45 + {
  46 + JZsdk_SearchLightTemControl( (float)g_InputTemp, g_InputLumen, &g_OutputLumen, &DelayTime);
  47 +
  48 + if (DelayTime > 0)
  49 + {
  50 + printf("触发温控延迟\n");
  51 + delayMs(DelayTime);
  52 + }
  53 + else
  54 + {
  55 + delayMs(1);
  56 + }
  57 +
  58 + DelayTime = 0;
  59 + }
  60 +}
  61 +//控件
  62 +
  63 +//控件控制初始化
  64 +T_JZsdkReturnCode JZsdk_SearchLightTemControl_Init()
  65 +{
  66 +
  67 + pthread_t WriteDataTask;
  68 + pthread_attr_t task_attribute; //线程属性
  69 + pthread_attr_init(&task_attribute); //初始化线程属性
  70 + pthread_attr_setdetachstate(&task_attribute, PTHREAD_CREATE_DETACHED); //设置线程分离属性
  71 + int opus_Protection = pthread_create(&WriteDataTask,&task_attribute,TempControl_Task,NULL); //线程
  72 + if(opus_Protection != 0)
  73 + {
  74 + JZSDK_LOG_ERROR("创建控件写入线程失败!");
  75 + return -1;
  76 + }
  77 +}
  1 +/**
  2 + ********************************************************************
  3 + * @file SearchLightTemControl.h
  4 + * SearchLightTemControl.c的头文件
  5 + *
  6 + *
  7 + *********************************************************************
  8 + */
  9 +
  10 +/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
  11 +#ifndef SEARCHLIGHT_TEM_CONTROL_H
  12 +#define SEARCHLIGHT_TEM_CONTROL_H
  13 +
  14 +/* Includes ------------------------------------------------------------------*/
  15 +#include "JZsdk_Base/JZsdk_Code/JZsdk_Code.h"
  16 +T_JZsdkReturnCode JZsdk_SearchLightTemControl_Input(int InputTemp, int InputLumen);
  17 +T_JZsdkReturnCode JZsdk_SearchLightTemControl_FlushLumen(int InputLumen);
  18 +T_JZsdkReturnCode JZsdk_SearchLightTemControl_Init();
  19 +
  20 +#endif
@@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
13 /* Includes ------------------------------------------------------------------*/ 13 /* Includes ------------------------------------------------------------------*/
14 #include "./SearchLight_V3S_U3/SearchLight_V3S_U3.h" 14 #include "./SearchLight_V3S_U3/SearchLight_V3S_U3.h"
15 #include "./SearchLight_V3S_H1T/SearchLight_V3S_H1T.h" 15 #include "./SearchLight_V3S_H1T/SearchLight_V3S_H1T.h"
  16 +#include "./SearchLight_V3S_TFA1/SearchLight_V3S_TFA1.h"
16 17
17 18
18 #ifdef __cplusplus 19 #ifdef __cplusplus
  1 +#include <stdio.h>
  2 +#include "./SearchLight_V3S_TFA1.h"
  3 +#include "JZsdk_Uart_Input.h"
  4 +#include "BaseConfig.h"
  5 +
  6 +
  7 +T_JZsdkReturnCode SearchLight_V3S_TFA1_Set_SearchLightFrequency(int value)
  8 +{
  9 + //向u3的单片机发送调节频率帧
  10 + JZsdk_Uart_Send_SearchLight_SetFrequency(UART_DEV_2, value);
  11 +
  12 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  13 +}
  14 +
  15 +T_JZsdkReturnCode SearchLight_V3S_TFA1_SearchLightControl(int mode)
  16 +{
  17 + //向u3的单片机发送探照灯控制帧
  18 + JZsdk_Uart_Send_SearchLight_Control(UART_DEV_2, mode);
  19 +
  20 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  21 +}
  22 +
  23 +T_JZsdkReturnCode SearchLight_V3S_TFA1_Set_SearchLightLumen(int LeftLumen, int RightLumen)
  24 +{
  25 + //向u3的单片机发送探照灯控制帧
  26 + JZsdk_Uart_Send_SearchLight_SetLumen(UART_DEV_2, LeftLumen, RightLumen);
  27 +
  28 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  29 +}
  1 +/**
  2 + ********************************************************************
  3 + * @file SearchLight_V3S_TFA1.h
  4 + * SearchLight_V3S_TFA1的头文件
  5 + *
  6 + *********************************************************************
  7 + */
  8 +
  9 +/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
  10 +#ifndef SEARCHLIGHT_V3S_TFA1_H
  11 +#define SEARCHLIGHT_V3S_TFA1_H
  12 +
  13 +/* Includes ------------------------------------------------------------------*/
  14 +#include "JZsdk_Base/JZsdk_Code/JZsdk_Code.h"
  15 +
  16 +#ifdef __cplusplus
  17 +extern "C" {
  18 +#endif
  19 +
  20 +/* Exported constants --------------------------------------------------------*/
  21 +/* 常亮定义*/
  22 +
  23 +
  24 +/* Exported types ------------------------------------------------------------*/
  25 +
  26 +/* Exported functions --------------------------------------------------------*/
  27 +T_JZsdkReturnCode SearchLight_V3S_TFA1_Set_SearchLightFrequency(int value);
  28 +T_JZsdkReturnCode SearchLight_V3S_TFA1_SearchLightControl(int mode);
  29 +T_JZsdkReturnCode SearchLight_V3S_TFA1_Set_SearchLightLumen(int LeftLumen, int RightLumen);
  30 +
  31 +
  32 +#ifdef __cplusplus
  33 +}
  34 +#endif
  35 +
  36 +#endif
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
12 12
13 /* Includes ------------------------------------------------------------------*/ 13 /* Includes ------------------------------------------------------------------*/
14 #include "./WarningLight_V3S_H1T/WarningLight_V3S_H1T.h" 14 #include "./WarningLight_V3S_H1T/WarningLight_V3S_H1T.h"
  15 +#include "./WarningLight_V3S_TFA1/WarningLight_V3S_TFA1.h"
15 16
16 17
17 #ifdef __cplusplus 18 #ifdef __cplusplus
  1 +#include <stdio.h>
  2 +#include "./WarningLight_V3S_TFA1.h"
  3 +#include "JZsdk_Uart_Input.h"
  4 +#include "BaseConfig.h"
  5 +
  6 +//设置警灯状态
  7 +T_JZsdkReturnCode WarningLight_V3S_TFA1_Set_WarningLight_Status(int status, int mode)
  8 +{
  9 + //向单片机发送警灯状态
  10 + JZsdk_Uart_Send_Set_WarningLight_Status(UART_DEV_2, status, mode);
  11 +
  12 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  13 +}
  14 +
  15 +//设置警灯颜色
  16 +T_JZsdkReturnCode WarningLight_V3S_TFA1_Set_WarningLight_Color(int color1, int color2)
  17 +{
  18 + JZsdk_Uart_Send_Set_WarningLight_Color(UART_DEV_2, color1, color2);
  19 +
  20 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  21 +}
  22 +
  23 +/*********
  24 + *
  25 + * 查询警灯状态
  26 + *
  27 +**********/
  28 +T_JZsdkReturnCode WarningLight_V3S_TFA1_CheckStatus_WarningLightStatus()
  29 +{
  30 + JZsdk_Uart_Send_CheckStatus_WarningLightStatus(UART_DEV_2);
  31 +
  32 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  33 +}
  34 +
  35 +/*********
  36 + *
  37 + * 查询警灯颜色
  38 + *
  39 +**********/
  40 +T_JZsdkReturnCode WarningLight_V3S_TFA1_CheckStatus_WarningLightColor()
  41 +{
  42 + JZsdk_Uart_Send_CheckStatus_WarningLightColor(UART_DEV_2);
  43 +
  44 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
  45 +}
  1 +/**
  2 + ********************************************************************
  3 + * @file WarningLight_V3S_TFA1.h
  4 + * WarningLight_V3S_TFA1的头文件
  5 + *
  6 + *********************************************************************
  7 + */
  8 +
  9 +/* Define to prevent recursive inclusion 避免重定义 -------------------------------------*/
  10 +#ifndef WARNINGLIGHT_V3S_TFA1_H
  11 +#define WARNINGLIGHT_V3S_TFA1_H
  12 +
  13 +/* Includes ------------------------------------------------------------------*/
  14 +#include "JZsdk_Base/JZsdk_Code/JZsdk_Code.h"
  15 +
  16 +#ifdef __cplusplus
  17 +extern "C" {
  18 +#endif
  19 +
  20 +/* Exported constants --------------------------------------------------------*/
  21 +/* 常亮定义*/
  22 +
  23 +
  24 +/* Exported types ------------------------------------------------------------*/
  25 +
  26 +/* Exported functions --------------------------------------------------------*/
  27 +T_JZsdkReturnCode WarningLight_V3S_TFA1_Set_WarningLight_Status(int status, int mode);
  28 +T_JZsdkReturnCode WarningLight_V3S_TFA1_Set_WarningLight_Color(int color1, int color2);
  29 +T_JZsdkReturnCode WarningLight_V3S_TFA1_CheckStatus_WarningLightStatus();
  30 +T_JZsdkReturnCode WarningLight_V3S_TFA1_CheckStatus_WarningLightColor();
  31 +
  32 +#ifdef __cplusplus
  33 +}
  34 +#endif
  35 +
  36 +#endif
@@ -43,7 +43,18 @@ int Megaphone_Init() @@ -43,7 +43,18 @@ int Megaphone_Init()
43 #if FIRMWARE_ORIGIN == DOMESTIC_VERSION //国内版才有方言 43 #if FIRMWARE_ORIGIN == DOMESTIC_VERSION //国内版才有方言
44 44
45 //播放喊话器启动中 45 //播放喊话器启动中
  46 +
  47 + if (APP_VERSION == APP_PSDK)
  48 + {
  49 + //播放喊话器启动中
  50 + //Megaphone_TTS_Play(strlen("喊话器启动中"),"喊话器启动中", 0);
  51 + }
  52 +
  53 + else if (APP_VERSION == APP_UART)
  54 + {
  55 + //播放喊话器启动中
46 Megaphone_TTS_Play(strlen("喊话器直连模式启动中"),"喊话器直连模式启动中", 0); 56 Megaphone_TTS_Play(strlen("喊话器直连模式启动中"),"喊话器直连模式启动中", 0);
  57 + }
47 58
48 #elif FIRMWARE_ORIGIN == OVERSEAS_VERSION //海外版才有其他国家的语音 59 #elif FIRMWARE_ORIGIN == OVERSEAS_VERSION //海外版才有其他国家的语音
49 60
@@ -227,22 +238,16 @@ T_JZsdkReturnCode Megaphone_audio_PlayPause() @@ -227,22 +238,16 @@ T_JZsdkReturnCode Megaphone_audio_PlayPause()
227 T_JZsdkReturnCode Megaphone_audio_PlayStop() 238 T_JZsdkReturnCode Megaphone_audio_PlayStop()
228 { 239 {
229 //1、关闭功放 240 //1、关闭功放
230 - printf("stop1\n");  
231 -  
232 Megaphone_set_amplifier(JZ_FLAGCODE_OFF); 241 Megaphone_set_amplifier(JZ_FLAGCODE_OFF);
233 - printf("stop2\n");  
234 242
235 //2、向音频库发送暂停音乐帧 243 //2、向音频库发送暂停音乐帧
236 Music_SendFrame_PauseMusic(); 244 Music_SendFrame_PauseMusic();
237 - printf("stop3\n");  
238 245
239 //3、关闭TTS播放 246 //3、关闭TTS播放
240 TTS_ttsPlayStop(); 247 TTS_ttsPlayStop();
241 - printf("stop4\n");  
242 248
243 //4、关闭opus播放 249 //4、关闭opus播放
244 Opus_OpusPlayStop(); 250 Opus_OpusPlayStop();
245 - printf("stop5\n");  
246 251
247 //5、返回成功 252 //5、返回成功
248 return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS; 253 return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@@ -266,6 +271,7 @@ T_JZsdkReturnCode Megaphone_audio_LastSong() @@ -266,6 +271,7 @@ T_JZsdkReturnCode Megaphone_audio_LastSong()
266 //2、获取上一首歌的名字与长度 271 //2、获取上一首歌的名字与长度
267 char MusicName[256]; 272 char MusicName[256];
268 int MusicNameLen; 273 int MusicNameLen;
  274 + memset(MusicName,0,sizeof(MusicName));
269 int ret = Music_Get_LastMusic(MusicName,&MusicNameLen); 275 int ret = Music_Get_LastMusic(MusicName,&MusicNameLen);
270 276
271 //3、播放上一首歌 277 //3、播放上一首歌
@@ -290,6 +296,7 @@ T_JZsdkReturnCode Megaphone_audio_NextSong() @@ -290,6 +296,7 @@ T_JZsdkReturnCode Megaphone_audio_NextSong()
290 //2、获取下一首歌的名字与长度 296 //2、获取下一首歌的名字与长度
291 char MusicName[256]; 297 char MusicName[256];
292 int MusicNameLen; 298 int MusicNameLen;
  299 + memset(MusicName,0,sizeof(MusicName));
293 int ret = Music_Get_NextMusic(MusicName,&MusicNameLen); 300 int ret = Music_Get_NextMusic(MusicName,&MusicNameLen);
294 301
295 //3、播放下一首歌 302 //3、播放下一首歌
@@ -362,7 +369,7 @@ static int Get_audio_status() @@ -362,7 +369,7 @@ static int Get_audio_status()
362 } 369 }
363 370
364 } 371 }
365 -static int Get_TTS_status() 372 +int Get_TTS_status()
366 { 373 {
367 //获取TTS的播放标志位 374 //获取TTS的播放标志位
368 int ret = TTS_Get_TTS_play_flag(); 375 int ret = TTS_Get_TTS_play_flag();
@@ -648,6 +655,8 @@ T_JZsdkReturnCode Megaphone_RealTimeVoice_Start(int decode_rate) @@ -648,6 +655,8 @@ T_JZsdkReturnCode Megaphone_RealTimeVoice_Start(int decode_rate)
648 655
649 //4、开始实施喊话 656 //4、开始实施喊话
650 Opus_RealTimeVoice_Start(decode_rate); 657 Opus_RealTimeVoice_Start(decode_rate);
  658 +
  659 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
651 } 660 }
652 661
653 /**** 662 /****
@@ -656,9 +665,11 @@ T_JZsdkReturnCode Megaphone_RealTimeVoice_Start(int decode_rate) @@ -656,9 +665,11 @@ T_JZsdkReturnCode Megaphone_RealTimeVoice_Start(int decode_rate)
656 * 22、写入数据进实时喊话的存储池 665 * 22、写入数据进实时喊话的存储池
657 * 666 *
658 * ***/ 667 * ***/
659 -int Megaphone_RealTimeVoice_Trans(char *data, int length) 668 +T_JZsdkReturnCode Megaphone_RealTimeVoice_Trans(char *data, int length)
660 { 669 {
661 Opus_RealTimeVoice_WriteDataToLoop(data, length); 670 Opus_RealTimeVoice_WriteDataToLoop(data, length);
  671 +
  672 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
662 } 673 }
663 674
664 /********* 675 /*********
@@ -667,7 +678,7 @@ int Megaphone_RealTimeVoice_Trans(char *data, int length) @@ -667,7 +678,7 @@ int Megaphone_RealTimeVoice_Trans(char *data, int length)
667 * 678 *
668 * 679 *
669 **********/ 680 **********/
670 -int Megaphone_RealTimeVoice_Close() 681 +T_JZsdkReturnCode Megaphone_RealTimeVoice_Close()
671 { 682 {
672 683
673 684
@@ -676,6 +687,8 @@ int Megaphone_RealTimeVoice_Close() @@ -676,6 +687,8 @@ int Megaphone_RealTimeVoice_Close()
676 687
677 //2、关闭功放 688 //2、关闭功放
678 Megaphone_set_amplifier(JZ_FLAGCODE_OFF); 689 Megaphone_set_amplifier(JZ_FLAGCODE_OFF);
  690 +
  691 + return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
679 } 692 }
680 693
681 694
@@ -789,7 +802,7 @@ T_JZsdkReturnCode Megaphone_Opus_PlayFixedFile() @@ -789,7 +802,7 @@ T_JZsdkReturnCode Megaphone_Opus_PlayFixedFile()
789 * 2、存储opus文件开始 802 * 2、存储opus文件开始
790 * 803 *
791 */ 804 */
792 -int Megaphone_SaveOpusStart(int decode_rate) 805 +T_JZsdkReturnCode Megaphone_SaveOpusStart(int decode_rate)
793 { 806 {
794 Opus_RecordVoice_SaveOpusStart(decode_rate); 807 Opus_RecordVoice_SaveOpusStart(decode_rate);
795 } 808 }
@@ -799,7 +812,7 @@ int Megaphone_SaveOpusStart(int decode_rate) @@ -799,7 +812,7 @@ int Megaphone_SaveOpusStart(int decode_rate)
799 * 3、存储opus文件中 812 * 3、存储opus文件中
800 * 813 *
801 */ 814 */
802 -int Megaphone_SaveOpusTrans(char *SaveData, int size) 815 +T_JZsdkReturnCode Megaphone_SaveOpusTrans(char *SaveData, int size)
803 { 816 {
804 Opus_RecordVoice_SaveOpusTrans(SaveData, size); 817 Opus_RecordVoice_SaveOpusTrans(SaveData, size);
805 } 818 }
@@ -809,7 +822,7 @@ int Megaphone_SaveOpusTrans(char *SaveData, int size) @@ -809,7 +822,7 @@ int Megaphone_SaveOpusTrans(char *SaveData, int size)
809 * 4、存储opus文件结束 822 * 4、存储opus文件结束
810 * 823 *
811 */ 824 */
812 -int Megaphone_SaveOpusStop() 825 +T_JZsdkReturnCode Megaphone_SaveOpusStop()
813 { 826 {
814 Opus_RecordVoice_SaveOpusStop(); 827 Opus_RecordVoice_SaveOpusStop();
815 } 828 }
@@ -50,9 +50,9 @@ T_JZsdkReturnCode Megaphone_Opus_PlayFixedFile(); @@ -50,9 +50,9 @@ T_JZsdkReturnCode Megaphone_Opus_PlayFixedFile();
50 int Megaphone_set_amplifier(int value); 50 int Megaphone_set_amplifier(int value);
51 51
52 52
53 -int Megaphone_SaveOpusStart(int decode_rate);  
54 -int Megaphone_SaveOpusTrans(char *SaveData, int size);  
55 -int Megaphone_SaveOpusStop(); 53 +T_JZsdkReturnCode Megaphone_SaveOpusStart(int decode_rate);
  54 +T_JZsdkReturnCode Megaphone_SaveOpusTrans(char *SaveData, int size);
  55 +T_JZsdkReturnCode Megaphone_SaveOpusStop();
56 56
57 int Megaphone_get_play_status(); 57 int Megaphone_get_play_status();
58 int Megaphone_get_play_FileName(char *music_name, int *music_name_len); 58 int Megaphone_get_play_FileName(char *music_name, int *music_name_len);
@@ -74,11 +74,13 @@ int Megaphone_SaveAudioFileStop(); @@ -74,11 +74,13 @@ int Megaphone_SaveAudioFileStop();
74 74
75 //获取实时喊话的状态 75 //获取实时喊话的状态
76 T_JZsdkReturnCode Megaphone_RealTimeVoice_GetStatusFlag(); 76 T_JZsdkReturnCode Megaphone_RealTimeVoice_GetStatusFlag();
  77 +int Get_TTS_status();
  78 +
77 79
78 //实时opus喊话 80 //实时opus喊话
79 T_JZsdkReturnCode Megaphone_RealTimeVoice_Start(int decode_rate); 81 T_JZsdkReturnCode Megaphone_RealTimeVoice_Start(int decode_rate);
80 -int Megaphone_RealTimeVoice_Trans(char *data, int length);  
81 -int Megaphone_RealTimeVoice_Close(); 82 +T_JZsdkReturnCode Megaphone_RealTimeVoice_Trans(char *data, int length);
  83 +T_JZsdkReturnCode Megaphone_RealTimeVoice_Close();
82 84
83 //实时MP2 85 //实时MP2
84 T_JZsdkReturnCode Megaphone_RealTimeMP2_start(); 86 T_JZsdkReturnCode Megaphone_RealTimeMP2_start();
@@ -52,6 +52,9 @@ @@ -52,6 +52,9 @@
52 #elif DEVICE_VERSION == JZ_U3 52 #elif DEVICE_VERSION == JZ_U3
53 #define MAX_VOLUME (100) 53 #define MAX_VOLUME (100)
54 #define MAX_TTS_VOLUME (100) 54 #define MAX_TTS_VOLUME (100)
  55 +#elif DEVICE_VERSION == TF_A1
  56 + #define MAX_VOLUME (75)
  57 + #define MAX_TTS_VOLUME (82)
55 #else 58 #else
56 #define MAX_VOLUME (75) 59 #define MAX_VOLUME (75)
57 #define MAX_TTS_VOLUME (75) 60 #define MAX_TTS_VOLUME (75)
@@ -72,6 +75,8 @@ static int MusicLoopPlayMode=0;//播放模式,MusicLoopPlayMode==1单曲循环 @@ -72,6 +75,8 @@ static int MusicLoopPlayMode=0;//播放模式,MusicLoopPlayMode==1单曲循环
72 static int music_nowtime=0; //当前音频播放时间 75 static int music_nowtime=0; //当前音频播放时间
73 static int music_time=0; //当前音频的总时间 76 static int music_time=0; //当前音频的总时间
74 77
  78 +int Intl_TTS_PlayFlag = 0;
  79 +
75 int now_volume=20;//默认音量10--》50+10/2==55 80 int now_volume=20;//默认音量10--》50+10/2==55
76 int set_volume_value=0;//音量值 81 int set_volume_value=0;//音量值
77 82
@@ -467,7 +472,7 @@ void *SET_volume(void *arg) @@ -467,7 +472,7 @@ void *SET_volume(void *arg)
467 { 472 {
468 snprintf(cmdBuffer,128, "amixer set -c 4 Master %d",set_volume_value); 473 snprintf(cmdBuffer,128, "amixer set -c 4 Master %d",set_volume_value);
469 } 474 }
470 - else if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T) 475 + else if (DEVICE_VERSION == JZ_H1E || DEVICE_VERSION == JZ_H1T || DEVICE_VERSION == TF_A1)
471 { 476 {
472 snprintf(cmdBuffer,128, "amixer set -c 0 Master %d",set_volume_value); 477 snprintf(cmdBuffer,128, "amixer set -c 0 Master %d",set_volume_value);
473 } 478 }
@@ -539,13 +544,41 @@ void returnframe(char* data, int datasize)//回调函数,监听播放状态 @@ -539,13 +544,41 @@ void returnframe(char* data, int datasize)//回调函数,监听播放状态
539 //循环模式打开 544 //循环模式打开
540 if (MusicLoopPlayMode == 1) 545 if (MusicLoopPlayMode == 1)
541 { 546 {
542 - delayMs(1000); 547 +
  548 + //如果没在播海外的tts
  549 + if (Intl_TTS_PlayFlag == 0)
  550 + {
  551 + //延时
  552 + for (int i = 0; (i < 1000) && (MusicLoopPlayMode == 1); i+=10)
  553 + {
  554 + delayMs(10);
  555 + }
  556 +
543 printf("循环播放%s %d",musiclist[music_num],musicname_len[music_num]); 557 printf("循环播放%s %d",musiclist[music_num],musicname_len[music_num]);
544 Music_SendFrame_PlayMusic(musiclist[music_num],musicname_len[music_num]); 558 Music_SendFrame_PlayMusic(musiclist[music_num],musicname_len[music_num]);
545 } 559 }
  560 + else if(Intl_TTS_PlayFlag==1)
  561 + {
  562 + //延时
  563 + for (int i = 0; (i < 1000) && (MusicLoopPlayMode == 1); i+=10)
  564 + {
  565 + delayMs(10);
  566 + }
  567 +
  568 + char tts_name[]="IntlTTS.wav";
  569 + Music_SendFrame_PlayMusic(tts_name,sizeof(tts_name));//再次播放
  570 + }
  571 +
  572 + }
546 //播放结束 573 //播放结束
547 else 574 else
548 { 575 {
  576 + if (Intl_TTS_PlayFlag == 1)
  577 + {
  578 + Intl_TTS_PlayFlag = 0;
  579 + }
  580 +
  581 +
549 //关闭播放 582 //关闭播放
550 Megaphone_audio_PlayStop(); 583 Megaphone_audio_PlayStop();
551 584
@@ -682,12 +715,12 @@ int Music_SendFrame_FramePlay(unsigned char* data, int DataSize) @@ -682,12 +715,12 @@ int Music_SendFrame_FramePlay(unsigned char* data, int DataSize)
682 * 715 *
683 * 获取音频列表信息 716 * 获取音频列表信息
684 * 717 *
685 - *  
686 * *****************/ 718 * *****************/
  719 +//3首歌版本
687 int Muisc_GetMusicListMessage(char *MusicListMessage) 720 int Muisc_GetMusicListMessage(char *MusicListMessage)
688 { 721 {
689 - //将5首歌曲写入显示信息  
690 - //播的前面两首 和 播的后面两首 722 + //将3首歌曲写入显示信息
  723 + //播的前面1首 和 播的后面1首
691 724
692 char old_TempMusicList[256]; 725 char old_TempMusicList[256];
693 char new_TempMusicList[256]; 726 char new_TempMusicList[256];
@@ -696,6 +729,9 @@ int Muisc_GetMusicListMessage(char *MusicListMessage) @@ -696,6 +729,9 @@ int Muisc_GetMusicListMessage(char *MusicListMessage)
696 729
697 //清空当前信息 730 //清空当前信息
698 memset(MusicListMessage,0,sizeof(MusicListMessage)); 731 memset(MusicListMessage,0,sizeof(MusicListMessage));
  732 + memset(old_TempMusicList,0,sizeof(old_TempMusicList));
  733 + memset(new_TempMusicList,0,sizeof(new_TempMusicList));
  734 + memset(TempMusicList,0,sizeof(TempMusicList));
699 735
700 //如果歌曲列表为空 736 //如果歌曲列表为空
701 if (music_sum == 0) 737 if (music_sum == 0)
@@ -710,8 +746,8 @@ int Muisc_GetMusicListMessage(char *MusicListMessage) @@ -710,8 +746,8 @@ int Muisc_GetMusicListMessage(char *MusicListMessage)
710 return 0; 746 return 0;
711 } 747 }
712 748
713 - //如果歌曲列表仅有1~4首歌  
714 - if ( (music_sum >= 1) && (music_sum <= 4) ) 749 + //如果歌曲列表仅有1~2首歌
  750 + if ( (music_sum >= 1) && (music_sum <= 2) )
715 { 751 {
716 for(i = 0;i<music_sum;i++) 752 for(i = 0;i<music_sum;i++)
717 { 753 {
@@ -732,31 +768,31 @@ int Muisc_GetMusicListMessage(char *MusicListMessage) @@ -732,31 +768,31 @@ int Muisc_GetMusicListMessage(char *MusicListMessage)
732 return 0; 768 return 0;
733 } 769 }
734 770
735 - //如果歌曲列表有大于等于5首歌时 771 + //如果歌曲列表有大于等于2首歌时
736 // 写入前两首歌曲 772 // 写入前两首歌曲
737 - for (i = 0; i < 2; i++) 773 + for (i = 0; i < 1; i++)
738 { 774 {
739 if (music_num - i - 1 >= 0) 775 if (music_num - i - 1 >= 0)
740 { 776 {
741 index = music_num - i -1; 777 index = music_num - i -1;
742 snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]); 778 snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
743 - } else 779 + }
  780 + else
744 { 781 {
745 index = music_sum + (music_num - i -1); 782 index = music_sum + (music_num - i -1);
746 snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]); 783 snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
747 } 784 }
748 785
749 snprintf(old_TempMusicList,255,"%s",TempMusicList); 786 snprintf(old_TempMusicList,255,"%s",TempMusicList);
750 - snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList); 787 + snprintf(TempMusicList,255,"%s%s",new_TempMusicList,old_TempMusicList);
751 } 788 }
752 -  
753 //写入当前歌 789 //写入当前歌
754 snprintf(new_TempMusicList,musicname_len[music_num]+8,"▶:%s\n",musiclist[music_num]); 790 snprintf(new_TempMusicList,musicname_len[music_num]+8,"▶:%s\n",musiclist[music_num]);
755 snprintf(old_TempMusicList,255,"%s",TempMusicList); 791 snprintf(old_TempMusicList,255,"%s",TempMusicList);
756 snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList); 792 snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList);
757 793
758 - // 写入后两首歌曲  
759 - for (i = 0; i < 2; i++) 794 + // 写入后1首歌曲
  795 + for (i = 0; i < 1; i++)
760 { 796 {
761 if (music_num + i + 1 < music_sum) 797 if (music_num + i + 1 < music_sum)
762 { 798 {
@@ -778,3 +814,102 @@ int Muisc_GetMusicListMessage(char *MusicListMessage) @@ -778,3 +814,102 @@ int Muisc_GetMusicListMessage(char *MusicListMessage)
778 814
779 return 0; 815 return 0;
780 } 816 }
  817 +
  818 +// 显示5首歌
  819 +// int Muisc_GetMusicListMessage(char *MusicListMessage)
  820 +// {
  821 +// //将5首歌曲写入显示信息
  822 +// //播的前面两首 和 播的后面两首
  823 +
  824 +// char old_TempMusicList[256];
  825 +// char new_TempMusicList[256];
  826 +// char TempMusicList[256];
  827 +// int i,index;
  828 +
  829 +// //清空当前信息
  830 +// memset(MusicListMessage,0,sizeof(MusicListMessage));
  831 +// memset(old_TempMusicList,0,sizeof(old_TempMusicList));
  832 +// memset(new_TempMusicList,0,sizeof(new_TempMusicList));
  833 +// memset(TempMusicList,0,sizeof(TempMusicList));
  834 +
  835 +// //如果歌曲列表为空
  836 +// if (music_sum == 0)
  837 +// {
  838 +// snprintf(new_TempMusicList,255,"当前歌曲列表为空\n",musiclist[music_num]);
  839 +// snprintf(old_TempMusicList,255,"%s",TempMusicList);
  840 +// snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList);
  841 +
  842 +// //将写好的歌曲放入返回的数组
  843 +// snprintf(MusicListMessage,255,"%s",TempMusicList);
  844 +
  845 +// return 0;
  846 +// }
  847 +
  848 +// //如果歌曲列表仅有1~4首歌
  849 +// if ( (music_sum >= 1) && (music_sum <= 4) )
  850 +// {
  851 +// for(i = 0;i<music_sum;i++)
  852 +// {
  853 +// if(i!=music_num)
  854 +// {
  855 +// snprintf(new_TempMusicList,255,"%s\n",musiclist[i]);
  856 +// }
  857 +// else{
  858 +// snprintf(new_TempMusicList,255,"▶:%s\n",musiclist[i]);
  859 +// }
  860 +// snprintf(old_TempMusicList,255,"%s",TempMusicList);
  861 +// snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList);
  862 +// }
  863 +
  864 +// //将写好的歌曲放入返回的数组
  865 +// snprintf(MusicListMessage,255,"%s",TempMusicList);
  866 +
  867 +// return 0;
  868 +// }
  869 +
  870 +// //如果歌曲列表有大于等于5首歌时
  871 +// // 写入前两首歌曲
  872 +// for (i = 0; i < 2; i++)
  873 +// {
  874 +// if (music_num - i - 1 >= 0)
  875 +// {
  876 +// index = music_num - i -1;
  877 +// snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
  878 +// }
  879 +// else
  880 +// {
  881 +// index = music_sum + (music_num - i -1);
  882 +// snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
  883 +// }
  884 +
  885 +// snprintf(old_TempMusicList,255,"%s",TempMusicList);
  886 +// snprintf(TempMusicList,255,"%s%s",new_TempMusicList,old_TempMusicList);
  887 +// }
  888 +// //写入当前歌
  889 +// snprintf(new_TempMusicList,musicname_len[music_num]+8,"▶:%s\n",musiclist[music_num]);
  890 +// snprintf(old_TempMusicList,255,"%s",TempMusicList);
  891 +// snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList);
  892 +
  893 +// // 写入后两首歌曲
  894 +// for (i = 0; i < 2; i++)
  895 +// {
  896 +// if (music_num + i + 1 < music_sum)
  897 +// {
  898 +// index = music_num + i + 1 ;
  899 +// snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
  900 +// }
  901 +// else
  902 +// {
  903 +// index = (music_num + i + 1) - music_sum;
  904 +// snprintf(new_TempMusicList, 255,"%s\n",musiclist[index]);
  905 +// }
  906 +
  907 +// snprintf(old_TempMusicList,255,"%s",TempMusicList);
  908 +// snprintf(TempMusicList,255,"%s%s",old_TempMusicList,new_TempMusicList);
  909 +// }
  910 +
  911 +// //将写好的歌曲放入返回的数组
  912 +// snprintf(MusicListMessage,255,"%s",TempMusicList);
  913 +
  914 +// return 0;
  915 +// }