Преглед изворни кода

采集液位参数时,感知到与其传感器通讯错误会有对应信息给出; 传感器无回应和回应乱码,也有区别,对应在A2报文的相关字段。 在屏幕的调试文本上,也会有提示。

xuy пре 2 година
родитељ
комит
c00d8ea1bb
3 измењених фајлова са 31 додато и 3 уклоњено
  1. 1 1
      Src/KeySlave485.c
  2. 9 1
      Src/TerminalSlave485_jt808.c
  3. 21 1
      Src/freertos.c

+ 1 - 1
Src/KeySlave485.c

@@ -37,7 +37,7 @@ uint8_t product_code[20] = "JL-SIMS-CJ-V2.1";				 //
 uint8_t product_ID[20] = "20210730001";						 //产品ID
 
 char Version_software[30] = "KZB09A0_20220210_Temp1";
-uint32_t Version_Soft[8] = {2,3,3,12,1,2,2,20230202};
+uint32_t Version_Soft[8] = {2,3,3,12,1,2,2,20230307};
 
 uint8_t flag_exitReset = 0;	 //终止复位命令
 uint8_t flag_Uart4_Busy = 0; //表明打印机占用了总线,暂停语音播报

+ 9 - 1
Src/TerminalSlave485_jt808.c

@@ -80,6 +80,7 @@ extern uint8_t  Cang06_IO[64];
 extern uint8_t  Cang07_IO[64];
 extern uint8_t  Cang08_IO[64];
 extern uint32_t overflow_cnt;
+extern int LiquidSenSorStatus;
 /* Private function prototypes----------------------------------------------------------------*/
 int jt808_Build_0x02_TimeCmd(uint8_t *pBuf);
 int jt808_Build_0x01_flowID(uint8_t *pBuf, uint32_t flow_id);
@@ -278,7 +279,14 @@ int jt808_Build_0x73_liquid_air_high(uint8_t *pBuf)
 	int j;
 	
 	pBuf[idx++] = 0x73;
-	pBuf[idx++] = 1;
+	
+	do {
+	    uint8_t st = 1;
+	    if (LiquidSenSorStatus == 500) {st = 0x81;}
+	    else if (LiquidSenSorStatus == 501) {st = 0x82;}
+	    pBuf[idx++] = st; 					//数据状态:0x01正常; 0x81未收到数据; 0x02乱码
+	}while(0);
+	
 	for (j = 0; j < StoreNumber; ++j)
 	{
 		uni_float uni_0x93;

+ 21 - 1
Src/freertos.c

@@ -495,6 +495,7 @@ uint8_t TimeBuf[7]  = {0x20,0x21,0x12,0x29,0x13,0x28,0x55};
 float e2;
 float laterval;
 uni_YeweiToPlatForm uni_YeweiToPlatFormt;
+int LiquidSenSorStatus;
 /* USER CODE END Header_Task_Usart_GetAllSensorData */
 void Task_Usart2_Collector(void const *argument)
 {
@@ -503,6 +504,8 @@ void Task_Usart2_Collector(void const *argument)
 	int count=0;
 	int retry;
 	float flo_Data=0;
+	int got_crc_error = 0;
+	int got_no_answer = 0;
 	/* Infinite loop */
 	int i001 = 0;
 	tmrForRemoteCali=SPAN_RemoteCali_INTERVAL;
@@ -534,6 +537,8 @@ void Task_Usart2_Collector(void const *argument)
 					ModbusCRC_Check = (ModbusCRC_Check << 8) | USART2_RX_BUF[USART2_RX_BUF[2] + 3];
 					if (ModbusCRC == ModbusCRC_Check)
 					{
+                        got_no_answer = 0;
+                        got_crc_error = 0;
 						uni_YeweiToPlatFormt.farray[0] = USART2_RX_BUF[4];
 						uni_YeweiToPlatFormt.farray[1] = USART2_RX_BUF[3];
 						uni_YeweiToPlatFormt.farray[2] = USART2_RX_BUF[6];
@@ -577,10 +582,22 @@ void Task_Usart2_Collector(void const *argument)
 							}
 						}
 						flo_Data = uni_YeweiToPlatFormt.flo_Data;
+					}else {
+					    got_crc_error++;
 					}
 				}
+			}else{
+			    got_no_answer++;
 			}
 		}
+		
+		if (got_no_answer > 150) {
+		    LiquidSenSorStatus = 500;
+		}else if (got_crc_error > 150) {
+		    LiquidSenSorStatus = 501;
+		}else{
+            LiquidSenSorStatus = 0;
+		}
 
 #if 0
 		//HAL_GPIO_TogglePin(GPIOC, DWI_Pin); //¸´Î»¿´ÃŹ·sp706
@@ -2503,7 +2520,10 @@ void DisplayRunInfo(uint32_t FunDebugCode000)
             break;
             
             default:
-                Len001RunInfo = sprintf((char *)bufText01Password, "  code=%5d\r\n",FunDebugCode000);
+                if (LiquidSenSorStatus>0)
+                    Len001RunInfo = sprintf((char *)bufText01Password, "  Ecode=%5d\r\n",LiquidSenSorStatus);
+                else
+                    Len001RunInfo = sprintf((char *)bufText01Password, "  code=%5d\r\n",FunDebugCode000);
             break;
             }