From 40bbf9d0543ea590085134160fb98aef8190eb59 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期三, 01 二月 2023 16:26:00 +0800
Subject: [PATCH] 测试标签远程读取参数功能正常,写入参数还不行

---
 Src/application/dw_app.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c
index cbf97ef..560a5e4 100644
--- a/Src/application/dw_app.c
+++ b/Src/application/dw_app.c
@@ -305,7 +305,7 @@
 	uint32_t frame_len;
 	uint32_t final_tx_time;
 	u32 start_poll;
-	u8 i,j,getsync_flag=0,timeout;
+	u8 i,j,getsync_flag=0,timeout,flag_ancreadpara=0;
     dwt_setrxaftertxdelay(POLL_TX_TO_RESP_RX_DLY_UUS);			//设置发送后开启接收,并设定延迟时间
     dwt_setrxtimeout(10000);		
 	tag_succ_times = 0;
@@ -358,6 +358,16 @@
 								
 								dwt_forcetrxoff();
 								flag_rxon=0;
+                                if(flag_ancreadpara)
+                                {
+                                    u16 calCRC;
+                                  tx_near_msg[MESSAGE_TYPE_IDX] = NEAR_PRAAREPLY;  
+                                  memcpy(&tx_near_msg[MESSAGE_PARAREPLY_IDX],g_com_map,SENDANCPARA_LEN);
+                                  calCRC = CRC_Compute((uint8_t*)g_com_map,SENDANCPARA_LEN);
+                                  memcpy(&tx_near_msg[MESSAGE_PARAREPLY_IDX+SENDANCPARA_LEN],&calCRC,2);
+                                  dwt_writetxdata(14+SENDANCPARA_LEN, tx_near_msg, 0);//将发送数据写入DW1000
+                                  dwt_writetxfctrl(14+SENDANCPARA_LEN, 0);//设定发送数据长度
+                                }
 								dwt_setdelayedtrxtime(final_tx_time);
 								result=dwt_starttx(DWT_START_TX_DELAYED);//设定为延迟发送	
 								flag_finalsend=0;
@@ -385,11 +395,15 @@
 								resp_rx_ts = get_rx_timestamp_u64();										//获得RESPONSE接收时间T4	
 								recbase_num++;
 								memcpy(&rec_nearbaseid,&rx_buffer[ANCHOR_ID_IDX],2);
-                                rec_remotepara_state=rx_buffer[MOTORSTATE_INDEX]>>4;
-                                if(rec_remotepara_state==1)
+                                rec_remotepara_state = rx_buffer[MOTORSTATE_INDEX]>>4;
+                                if(rec_remotepara_state != 0)
                                 {   
-                                    para_update = 1;
-                                    memcpy(rec_remotepara,&rx_buffer[REMOTEPARA_INDEX],para_len);
+                                    para_update = rec_remotepara_state;
+                                    memcpy(rec_remotepara,&rx_buffer[REMOTEPARA_INDEX],7);
+                                    if(para_update==2)
+                                    {
+                                        flag_ancreadpara = 1;                                     
+                                    }
                                 }
 								if(last_nearbase_num==0)
 								{
@@ -485,7 +499,8 @@
 									{
 											motor_state=rx_buffer[MOTORSTATE_INDEX];
 									}
-									final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos)*4], resp_rx_ts);								
+									final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos)*4], resp_rx_ts);		
+               
 									dwt_writetxdata(28+nearbase_num*4, tx_near_msg, 0);//将发送数据写入DW1000
 									dwt_writetxfctrl(28+nearbase_num*4, 0);//设定发送数据长度
 								
@@ -575,7 +590,7 @@
 			}
 	dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR| SYS_STATUS_TXFRS |SYS_STATUS_RXFCG);
 //HAL_GPIO_WritePin(LED0_GPIO, GPIO_PIN_9, GPIO_PIN_RESET);
-if(para_update)
+if(para_update==1)
     {   
         uint16_t calCRC;
         calCRC = CRC_Compute(rec_remotepara,5);

--
Gitblit v1.9.3