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

过滤同类设备UDP广播; 检测结果按通道分别缓存上报(7.4.0.21)

1) ESP32_WROOM_32D.c: WIFI_recv_deal() 过滤同类设备广播 —— 解包成功后判断 命令==PC_CMD_SETIP 且数据以 Mini7 开头, 即本机 send_Devinf_pc 广播的设备信息(而非上位机下发的SETIP), 此时清接收缓冲并把 iProcLen 置0跳过后续PC命令处理, 避免局域网内同类设备互相干扰配网/IP设置。

2) 检测结果按通道缓存: state_mini.h 的 ProcessStateMachine_t 新增本通道 test_result_struct result 缓存(主/从各一份); rgb381.c 的 SystemResaultJudge() 内 result.* 全部改为 psm->result.*; state_mini.c 上报改用本通道 psm->result; onechip_devinf_define.h 删除全局 test_result_struct result。解决主从双通道共用一份结果互相覆盖, 导致上报的 card_num 错位、matchPid() 无法命中、某一路上报无法收尾反复重发的问题。

3) onechip_load_inf.h: 软件版本号 7.4.0.20 -> 7.4.0.21。

4) 同步 MDK 工程文件(uvoptx/startup lst)。
yidong пре 1 месец
родитељ
комит
82cc9c404e

+ 0 - 1
BoardInterface/onechip_devinf_define.h

@@ -186,6 +186,5 @@ ONECHIP_GLOBAL_DEF uint32_t  cmd_rx_header;
 ONECHIP_GLOBAL_DEF CmdMessage  uart0_massage;
 ONECHIP_GLOBAL_DEF uint8_t  uart0_data[CMD_BUF_SIZE];
 
-ONECHIP_GLOBAL_DEF test_result_struct result;
 #endif //__ONECHIP_BASIC_DEFINE_H_
 

+ 1 - 1
BoardInterface/onechip_load_inf.h

@@ -8,7 +8,7 @@
 #define SOFT_VERSION_1  7	//软件版本号
 #define SOFT_VERSION_2  4	//软件版本号
 #define SOFT_VERSION_3  0	//软件版本号
-#define SOFT_VERSION_4  20	//软件版本号
+#define SOFT_VERSION_4  21	//软件版本号
 
 
 

+ 9 - 0
DriverInterface/ESP32_WROOM_32D.c

@@ -563,6 +563,15 @@ void WIFI_recv_deal(void)
         if(NULL != p)
 		{
             int iProcLen = DecodeNew(&uart0_massage,uart0_data,g_wifi_rx_buf, &g_wifi_rx_head,g_wifi_rx_last,WIFI_RX_BUF_SIZE);
+            /* 过滤其他设备的UDP广播: 命令为PC_CMD_SETIP且数据以"Mini7"开头(本机send_Devinf_pc广播的设备信息),
+               说明是同类设备发出的广播而非上位机下发的SETIP,丢弃不做后续处理 */
+            if(iProcLen > 0 && PC_CMD_SETIP == uart0_massage.cmd &&
+               strncmp((const char *)uart0_data, "Mini7", 5) == 0)
+            {
+                Van_Device_Printf(VAN_LOG_WIFI, "\n[WiFi] filter peer device broadcast");
+                wifi_receive_clear();
+                iProcLen = 0;   /* 标记为已过滤,跳过后续PC命令处理 */
+            }
             if (iProcLen > 0)   {                        
                 sysinf.pc_channel_recv  = PC_CONNECT_TYPE_WIFI; 
                 sysinf.pc_link_timeout = 0;

+ 39 - 39
DriverInterface/rgb381.c

@@ -481,50 +481,50 @@ void SystemResaultJudge(uint8_t number)
 {
 	
 	int nc_index = 0;	//内参
-	uint8_t *p = &result.hole1_result;	//孔结果
 	ColorSensor *pGroup = (number == 0) ? CS : CS_Slave;
 	ProcessStateMachine_t *psm=(number == 0) ? &sysinf.psmMaster : &sysinf.psmSlave; 
-	result.Devicenum = 0;
+	uint8_t *p = &psm->result.hole1_result;	//孔结果
+	psm->result.Devicenum = 0;
 	if(number == 0){	
-		strcpy(result.card_num,psm->card_param_info.pid);
+		strcpy(psm->result.card_num,psm->card_param_info.pid);
 	
 	}else{	
-		strcpy(result.card_num,psm->card_param_info.pid);	
+		strcpy(psm->result.card_num,psm->card_param_info.pid);	
 	}
 	
-//	result.card_num = card_param_info.pid;
-
-	result.hole1_item = psm->card_param_info.hole_info[0].item;
-	result.hole2_item = psm->card_param_info.hole_info[1].item;
-	result.hole3_item = psm->card_param_info.hole_info[2].item;
-	result.hole4_item = psm->card_param_info.hole_info[3].item;
-	result.hole5_item = psm->card_param_info.hole_info[4].item;
-	result.hole6_item = psm->card_param_info.hole_info[5].item;
-	result.hole7_item = psm->card_param_info.hole_info[6].item;
-	result.hole8_item = psm->card_param_info.hole_info[7].item;
-	result.hole9_item = psm->card_param_info.hole_info[8].item;
-	result.hole10_item = psm->card_param_info.hole_info[9].item;
-
-	result.hole1_Tt[0] = (uint8_t)pGroup[0].Tt;
-	result.hole1_Tt[1] = (uint8_t)((pGroup[0].Tt-(uint8_t)pGroup[0].Tt)*100);
-	result.hole2_Tt[0] = (uint8_t)pGroup[1].Tt;
-	result.hole2_Tt[1] = (uint8_t)((pGroup[1].Tt-(uint8_t)pGroup[1].Tt)*100);
-	result.hole3_Tt[0] = (uint8_t)pGroup[2].Tt;
-	result.hole3_Tt[1] = (uint8_t)((pGroup[2].Tt-(uint8_t)pGroup[2].Tt)*100);
-	result.hole4_Tt[0] = (uint8_t)pGroup[3].Tt;
-	result.hole4_Tt[1] = (uint8_t)((pGroup[3].Tt-(uint8_t)pGroup[3].Tt)*100);
-	result.hole5_Tt[0] = (uint8_t)pGroup[4].Tt;
-	result.hole5_Tt[1] = (uint8_t)((pGroup[4].Tt-(uint8_t)pGroup[4].Tt)*100);
-	result.hole6_Tt[0] = (uint8_t)pGroup[5].Tt;
-	result.hole6_Tt[1] = (uint8_t)((pGroup[5].Tt-(uint8_t)pGroup[5].Tt)*100);
-	result.hole7_Tt[0] = (uint8_t)pGroup[6].Tt;
-	result.hole7_Tt[1] = (uint8_t)((pGroup[6].Tt-(uint8_t)pGroup[6].Tt)*100);
-	result.hole8_Tt[0] = (uint8_t)pGroup[7].Tt;
-	result.hole8_Tt[1] = (uint8_t)((pGroup[7].Tt-(uint8_t)pGroup[7].Tt)*100);
-	result.hole9_Tt[0] = (uint8_t)pGroup[8].Tt;
-	result.hole9_Tt[1] = (uint8_t)((pGroup[8].Tt-(uint8_t)pGroup[8].Tt)*100);
-	result.hole10_Tt[0] = (uint8_t)pGroup[9].Tt;
-	result.hole10_Tt[1] = (uint8_t)((pGroup[9].Tt-(uint8_t)pGroup[9].Tt)*100);
+//	psm->result.card_num = card_param_info.pid;
+
+	psm->result.hole1_item = psm->card_param_info.hole_info[0].item;
+	psm->result.hole2_item = psm->card_param_info.hole_info[1].item;
+	psm->result.hole3_item = psm->card_param_info.hole_info[2].item;
+	psm->result.hole4_item = psm->card_param_info.hole_info[3].item;
+	psm->result.hole5_item = psm->card_param_info.hole_info[4].item;
+	psm->result.hole6_item = psm->card_param_info.hole_info[5].item;
+	psm->result.hole7_item = psm->card_param_info.hole_info[6].item;
+	psm->result.hole8_item = psm->card_param_info.hole_info[7].item;
+	psm->result.hole9_item = psm->card_param_info.hole_info[8].item;
+	psm->result.hole10_item = psm->card_param_info.hole_info[9].item;
+
+	psm->result.hole1_Tt[0] = (uint8_t)pGroup[0].Tt;
+	psm->result.hole1_Tt[1] = (uint8_t)((pGroup[0].Tt-(uint8_t)pGroup[0].Tt)*100);
+	psm->result.hole2_Tt[0] = (uint8_t)pGroup[1].Tt;
+	psm->result.hole2_Tt[1] = (uint8_t)((pGroup[1].Tt-(uint8_t)pGroup[1].Tt)*100);
+	psm->result.hole3_Tt[0] = (uint8_t)pGroup[2].Tt;
+	psm->result.hole3_Tt[1] = (uint8_t)((pGroup[2].Tt-(uint8_t)pGroup[2].Tt)*100);
+	psm->result.hole4_Tt[0] = (uint8_t)pGroup[3].Tt;
+	psm->result.hole4_Tt[1] = (uint8_t)((pGroup[3].Tt-(uint8_t)pGroup[3].Tt)*100);
+	psm->result.hole5_Tt[0] = (uint8_t)pGroup[4].Tt;
+	psm->result.hole5_Tt[1] = (uint8_t)((pGroup[4].Tt-(uint8_t)pGroup[4].Tt)*100);
+	psm->result.hole6_Tt[0] = (uint8_t)pGroup[5].Tt;
+	psm->result.hole6_Tt[1] = (uint8_t)((pGroup[5].Tt-(uint8_t)pGroup[5].Tt)*100);
+	psm->result.hole7_Tt[0] = (uint8_t)pGroup[6].Tt;
+	psm->result.hole7_Tt[1] = (uint8_t)((pGroup[6].Tt-(uint8_t)pGroup[6].Tt)*100);
+	psm->result.hole8_Tt[0] = (uint8_t)pGroup[7].Tt;
+	psm->result.hole8_Tt[1] = (uint8_t)((pGroup[7].Tt-(uint8_t)pGroup[7].Tt)*100);
+	psm->result.hole9_Tt[0] = (uint8_t)pGroup[8].Tt;
+	psm->result.hole9_Tt[1] = (uint8_t)((pGroup[8].Tt-(uint8_t)pGroup[8].Tt)*100);
+	psm->result.hole10_Tt[0] = (uint8_t)pGroup[9].Tt;
+	psm->result.hole10_Tt[1] = (uint8_t)((pGroup[9].Tt-(uint8_t)pGroup[9].Tt)*100);
 
 	//判断孔结果
 	for (int i = 0; i < CS_MAX; i++)
@@ -553,7 +553,7 @@ void SystemResaultJudge(uint8_t number)
 	}
 	
 	//判断最终检测结果
-	p = &result.hole1_item_result;	//检测结果
+	p = &psm->result.hole1_item_result;	//检测结果
 	if(pGroup[nc_index].Result == ResultPositive)	//内参结果为阳
 	{
 		for (int i = 0; i < CS_MAX; i++)
@@ -586,7 +586,7 @@ void SystemResaultJudge(uint8_t number)
 	}
 
 	//内参自身检测结果,等于孔结果
-	p = &result.hole1_item_result;	//检测结果
+	p = &psm->result.hole1_item_result;	//检测结果
 	p += 5*nc_index;
 	*p = pGroup[nc_index].Result;
 

+ 1 - 1
DriverInterface/state_mini.c

@@ -171,7 +171,7 @@ void updateData(ProcessStateMachine_t *psm)
 			if(psm->updateresult){	
                 psm->cursendok = 0;
                 psm->sendTime = 3;
-				data_send_to_pc(PC_CMD_REPORT_RESULT, (char *)&result, sizeof(test_result_struct));              				
+				data_send_to_pc(PC_CMD_REPORT_RESULT, (char *)&psm->result, sizeof(test_result_struct));              				
 			}			
 		}
 	}

+ 1 - 0
DriverInterface/state_mini.h

@@ -233,6 +233,7 @@ typedef struct ProcessStateMachine
 	void * card_port;	
     unsigned int samp_flag;
     unsigned int error_delay;
+    test_result_struct result;   //本通道结果缓存(主/从各一份),避免上报时被另一通道覆盖
 } ProcessStateMachine_t;
 
 void resend_error_update(void);

+ 3 - 35
MDK-ARM/mini7_V2.uvoptx

@@ -75,7 +75,7 @@
       <OPTFL>
         <tvExp>1</tvExp>
         <tvExpOptDlg>0</tvExpOptDlg>
-        <IsCurrentTarget>0</IsCurrentTarget>
+        <IsCurrentTarget>1</IsCurrentTarget>
       </OPTFL>
       <CpuCode>18</CpuCode>
       <DebugOpt>
@@ -429,7 +429,7 @@
       <OPTFL>
         <tvExp>1</tvExp>
         <tvExpOptDlg>0</tvExpOptDlg>
-        <IsCurrentTarget>1</IsCurrentTarget>
+        <IsCurrentTarget>0</IsCurrentTarget>
       </OPTFL>
       <CpuCode>18</CpuCode>
       <DebugOpt>
@@ -506,40 +506,8 @@
         <Bp>
           <Number>0</Number>
           <Type>0</Type>
-          <LineNumber>862</LineNumber>
-          <EnabledFlag>1</EnabledFlag>
-          <Address>134281088</Address>
-          <ByteObject>0</ByteObject>
-          <HtxType>0</HtxType>
-          <ManyObjects>0</ManyObjects>
-          <SizeOfObject>0</SizeOfObject>
-          <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\DriverInterface\ESP32_WROOM_32D.c</Filename>
-          <ExecCommand></ExecCommand>
-          <Expression>\\mini7_V2\../DriverInterface/ESP32_WROOM_32D.c\862</Expression>
-        </Bp>
-        <Bp>
-          <Number>1</Number>
-          <Type>0</Type>
           <LineNumber>217</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>134261532</Address>
-          <ByteObject>0</ByteObject>
-          <HtxType>0</HtxType>
-          <ManyObjects>0</ManyObjects>
-          <SizeOfObject>0</SizeOfObject>
-          <BreakByAccess>0</BreakByAccess>
-          <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\DriverInterface\state_mini.c</Filename>
-          <ExecCommand></ExecCommand>
-          <Expression>\\mini7_V2\../DriverInterface/state_mini.c\217</Expression>
-        </Bp>
-        <Bp>
-          <Number>2</Number>
-          <Type>0</Type>
-          <LineNumber>303</LineNumber>
-          <EnabledFlag>1</EnabledFlag>
           <Address>0</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
@@ -547,7 +515,7 @@
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
           <BreakIfRCount>0</BreakIfRCount>
-          <Filename>..\DriverInterface\usr_motor.c</Filename>
+          <Filename>..\DriverInterface\state_mini.c</Filename>
           <ExecCommand></ExecCommand>
           <Expression></Expression>
         </Bp>

+ 5 - 5
MDK-ARM/startup_stm32f103xe.lst

@@ -544,11 +544,11 @@ ARM Macro Assembler    Page 9
               00000000 
 Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M3 --apcs=interw
 ork --depend=mini7_v2\startup_stm32f103xe.d -omini7_v2\startup_stm32f103xe.o -I
-.\RTE\_mini7_V2_debug -IF:\Keil_v5\ARM\PACK\ARM\CMSIS\5.4.0\CMSIS\Core\Include 
--IF:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.4.0\Device\Include --predefine="__MI
-CROLIB SETA 1" --predefine="__UVISION_VERSION SETA 526" --predefine="_RTE_ SETA
- 1" --predefine="STM32F10X_HD SETA 1" --list=startup_stm32f103xe.lst startup_st
-m32f103xe.s
+.\RTE\_mini7_V2 -IF:\Keil_v5\ARM\PACK\ARM\CMSIS\5.4.0\CMSIS\Core\Include -IF:\K
+eil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.4.0\Device\Include --predefine="__MICROLIB
+ SETA 1" --predefine="__UVISION_VERSION SETA 526" --predefine="_RTE_ SETA 1" --
+predefine="STM32F10X_HD SETA 1" --list=startup_stm32f103xe.lst startup_stm32f10
+3xe.s