From cbd0311ac2020ce18a87d6044bb7f23926cb826e Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期四, 12 五月 2022 09:03:20 +0800
Subject: [PATCH] V1.63 大车标签测距基站数量少于2就重启

---
 源码/核心板/Src/application/dw_app.c |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
index fefaae1..67acfdd 100644
--- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
+++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c"
@@ -314,7 +314,7 @@
 return max_slotpos-1;
 }
 u8 test=0;
-u8 anclost_times=0;
+u8 anclost_times=0,usartoutput_count,usartoutput_notenough=0;
 u8 exsistbase_list[MAX_NEARBASE_NUM],report_num,get_newbase=0,rec_extratag_battary;
 u16 temp_sync_timer1,temp_sync_timer2,rec_extratag_id;
 int32_t rec_extratag_dist;
@@ -330,6 +330,7 @@
     dwt_setrxaftertxdelay(POLL_TX_TO_RESP_RX_DLY_UUS);			//设置发送后开启接收,并设定延迟时间
     dwt_setrxtimeout(RESP_RX_TIMEOUT_UUS);		
 	tag_succ_times = 0;
+    usartoutput_count = 0;
 	GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_SET);
 	if(next_nearbase_num>=MAX_NEARBASE_NUM)
 	{
@@ -492,6 +493,7 @@
 										checksum = Checksum_u16(&usart_send[2],17);
 										memcpy(&usart_send[19],&checksum,2);
 										UART_PushFrame(usart_send,21);
+                                        usartoutput_count++;
 										#endif
 									}
 									if(rec_extratag_dist!=0x1ffff&&rec_extratag_dist!=0&&rx_buffer[GROUP_ID_IDX]!=supergroupid)
@@ -563,6 +565,7 @@
 										checksum = Checksum_u16(&usart_send[2],17);
 										memcpy(&usart_send[19],&checksum,2);
 										UART_PushFrame(usart_send,21);
+                                        usartoutput_count++;
 										#endif
 
 									//dwt_setdelayedtrxtime(final_tx_time);//设置final包发送时间T5
@@ -699,6 +702,15 @@
 //			}else{
 //				anclost_times=0;
 //			}
+        if(usartoutput_count>=2)
+        {
+            usartoutput_notenough = 0;
+        }else{
+            if(usartoutput_notenough++>10)
+            {
+                SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader   
+            }
+        }
 dwt_forcetrxoff();
 	dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR| SYS_STATUS_TXFRS |SYS_STATUS_RXFCG);
 }
@@ -954,13 +966,13 @@
       tx_nearresp_msg[GROUP_ID_IDX] = group_id;
 			tx_nearresp_msg[MAINBASE_INDEX]=flag_syncbase;
 			tx_nearresp_msg[MESSAGE_TYPE_IDX]=NEAR_RESPONSE;
-			tx_nearresp_msg[MOTORSTATE_INDEX]=(remotesend_state<<4)|motorstate;
-			if(remotesend_state)
-			{
-			 	memcpy(&tx_nearresp_msg[REMOTEPARA_INDEX],remotetag_para,REMOTEPARA_LEN);
-				dwt_writetxdata(22+REMOTEPARA_LEN, tx_nearresp_msg, 0);//写入发送数据
-				dwt_writetxfctrl(22+REMOTEPARA_LEN, 0);//设定发送长度		
-			}else{
+			tx_nearresp_msg[MOTORSTATE_INDEX]=0;//(remotesend_state<<4)|motorstate;
+//			if(remotesend_state)
+//			{
+//			 	memcpy(&tx_nearresp_msg[REMOTEPARA_INDEX],remotetag_para,REMOTEPARA_LEN);
+//				dwt_writetxdata(22+REMOTEPARA_LEN, tx_nearresp_msg, 0);//写入发送数据
+//				dwt_writetxfctrl(22+REMOTEPARA_LEN, 0);//设定发送长度		
+//			}else{
 				if(taglist_pos==1)
 				{
 					memcpy(&tx_nearresp_msg[EXTRA_TAGID_INDEX], &tagid_list[0], 2);
@@ -973,7 +985,7 @@
 				}					
 				dwt_writetxdata(28, tx_nearresp_msg, 0);//写入发送数据
 				dwt_writetxfctrl(28, 0);//设定发送长度
-			}
+	//		}
 			result = dwt_starttx(DWT_START_TX_DELAYED | DWT_RESPONSE_EXPECTED);//延迟发送,等待接收
 
 			

--
Gitblit v1.9.3