From 26a3a95b25f10e92061d1cf1ef2b46503134718e Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期日, 01 十二月 2019 19:02:52 +0800
Subject: [PATCH] 40米不该、 软件修改

---
 源码/核心板/Src/application/dw_app.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 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 23b23c2..2a41c5b 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"
@@ -313,7 +313,7 @@
 uint16_t g_Resttimer;
 uint8_t result;
 u8 tag_succ_times=0;
-int32_t hex_dist;
+int32_t hex_dist,hex_dist2;
 u16 checksum;
 int8_t tag_delaytime;
 extern uint16_t sync_timer;
@@ -395,7 +395,7 @@
 			}
 			TIM3->CNT=tmp_time;
 		}
-			memcpy(&hex_dist, &rx_buffer[DIST_IDX], 4);
+			memcpy(&hex_dist2, &rx_buffer[DIST_IDX], 4);
 			memcpy(&tx_final_msg[ANCHOR_ID_IDX], &rx_buffer[ANCHOR_ID_IDX], 4);
 			/* Compute final message transmission time. See NOTE 9 below. */
 			final_tx_time = (resp_rx_ts + (RESP_RX_TO_FINAL_TX_DLY_UUS * UUS_TO_DWT_TIME)) >> 8;//计算final包发送时间,T5=T4+Treply2
@@ -430,7 +430,7 @@
 					memcpy(&usart_send[5],&dev_id,2);
 					memcpy(&usart_send[7],&rx_buffer[ANCHOR_ID_IDX],2);
 				
-					memcpy(&usart_send[9],&hex_dist,4);
+					memcpy(&usart_send[9],&hex_dist2,4);
 					usart_send[13] = battary;
 					usart_send[14] = button;
 					checksum = Checksum_u16(&usart_send[2],17);
@@ -479,7 +479,7 @@
 {
 	uint32_t frame_len;
 	uint32_t resp_tx_time;
-	
+	static u8 misdist_num;
 	/* Clear reception timeout to start next ranging process. */
 	dwt_setrxtimeout(0);//设定接收超时时间,0位没有超时时间
 
@@ -611,6 +611,9 @@
 					g_UWB_com_interval = 0;
 					dis_after_filter=dist_cm;
 					hex_dist = dist_cm+(int16_t)g_com_map[DIST_OFFSET];
+					if(hex_dist-anchor_dist_last_frm[tag_id_recv-TAG_ID_START]<1500||misdist_num>4)
+					{
+						misdist_num=0;
 					if(hex_dist<100000&&hex_dist>-1000)
 					{
 						if(tag_id_recv-TAG_ID_START<=TAG_NUM_IN_SYS)
@@ -643,9 +646,12 @@
 					Modbus_HoldReg[tag_id_recv*2+1]=anchor_dist_last_frm[tag_id_recv-TAG_ID_START];
 					//dis_after_filter = LP_Frac_Update(p_Dis_Filter, dist_cm);
 						}
+					}
 					}else{
-						LED0_BLINK;
-					}						
+						misdist_num++;
+					}
+				if(anchor_dist_last_frm[tag_id_recv-TAG_ID_START]>1000)
+				{anchor_dist_last_frm[tag_id_recv-TAG_ID_START]=anchor_dist_last_frm[tag_id_recv-TAG_ID_START];}
 				}
 			}else{
 				/* Clear RX error events in the DW1000 status register. */

--
Gitblit v1.9.3