Prechádzať zdrojové kódy

【V3.1.0.42】Uart优化测试

CHENJIE-PC\QiXiang_CHENJIE 3 rokov pred
rodič
commit
da7fe607c9
2 zmenil súbory, kde vykonal 12 pridanie a 18 odobranie
  1. 2 2
      inc/AppConfig.h
  2. 10 16
      src/AppTaskUart.c

+ 2 - 2
inc/AppConfig.h

@@ -2,7 +2,7 @@
  * @Author       : ChenJie
  * @Date         : 2021-10-14 09:27:15
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-11-15 11:56:13
+ * @LastEditTime : 2021-11-15 15:05:49
  * @Description  : App Config H file 配置文件,可以针对不同参数进行更改
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\inc\AppConfig.h
  */
@@ -14,7 +14,7 @@
 #define DATA_MODULE_TYPE (1)           //1表示NB模块,2表示4G cat1
 #define EOLSTATE (0)                   //1表示下线检测跳过,使用默认值,0表示使用下线检测
 #define DEFAULT_SN "RLTEST00000000001" //默认上传的SN编码
-#define APPSWVERSION 0x03010029        //数据模块软件版本号
+#define APPSWVERSION 0x0301002A        //数据模块软件版本号
 #define RELAYCONFIG 1                  //继电器配置
 #define TCP_ADD "iotp.fast-fun.cn"     //数据上传的地址
 #define TCP_PORT 8712                  //数据上传的端口

+ 10 - 16
src/AppTaskUart.c

@@ -2,7 +2,7 @@
  * @Author       : ChenJie
  * @Date         : 2021-10-14 09:27:15
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-11-15 11:52:28
+ * @LastEditTime : 2021-11-15 15:05:06
  * @Description  : file content
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\src\AppTaskUart.c
  */
@@ -154,22 +154,16 @@ static void UartTask(void *arg)
 				PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
 				break;
 			}
-			else if (Uart_Recv_LEN == 1) //接收的数据校验不过
-			{
-				UartRecvFlag = 0;
-				//UartRecvFlagCounter++;
-			}
-			else //没有接收到数据
+			else //没有接收到数据或数据有误
 			{
 				UartRecvFlag = 0;
 				UartRecvFlagCounter++;
 			}
-			if (UartRecvFlagCounter >= 15)
+			if (UartRecvFlagCounter >= 10)
 			{
 				UartRecvFlagCounter = 0;
-				uartBattInfoDecode(UartAnswerData.data);
 				UartErrorFlag = 1;
-				PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_INTI);
+				uartBattInfoDecode(UartAnswerData.data);
 				break;
 			}
 			break;
@@ -451,13 +445,13 @@ UINT8 UartAppTrasmit(UINT8 *pSend, UINT32 sendLen, UINT8 *pRead, UINT32 readLen,
 			CRC_chk_buffer = crc_chk(pRead, UartData.len - 2);
 			if (*(pRead + 0) != 0x01 || CRC_Rece_buffer != CRC_chk_buffer)
 			{
-				hal_uart_hardware_config_t hwConfig = {
-					ARM_POWER_FULL,
-					ARM_USART_MODE_ASYNCHRONOUS | ARM_USART_DATA_BITS_8 |
-						ARM_USART_PARITY_NONE | ARM_USART_STOP_BITS_1 |
-						ARM_USART_FLOW_CONTROL_NONE,
-					9600U};
+				hal_uart_hardware_config_t hwConfig = {ARM_POWER_FULL,
+													   ARM_USART_MODE_ASYNCHRONOUS | ARM_USART_DATA_BITS_8 |
+														   ARM_USART_PARITY_NONE | ARM_USART_STOP_BITS_1 |
+														   ARM_USART_FLOW_CONTROL_NONE,
+													   9600U};
 				HAL_UART_ResetUartSetting(PORT_USART_1, &hwConfig, TRUE);
+				osDelay(500);
 				memset(pRead, 0x00, readLen);
 				return 1;
 			}