From acf666299579b508b6f3be4e4f83380d958e5c2f Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期四, 16 三月 2023 08:35:41 +0800
Subject: [PATCH] Merge branch '定位-自动时间片' of http://47.108.70.204:60062/r/XRange_Tag into 定位-自动时间片

---
 Src/application/dw_app.c |   50 +++++++++++++++++++++++++++-----------------------
 1 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c
index 92e8358..757921b 100644
--- a/Src/application/dw_app.c
+++ b/Src/application/dw_app.c
@@ -29,7 +29,7 @@
 #include <stdio.h>
 #include "beep.h"
 #include "modbus.h"
-
+#include "CRC.h"
 /*------------------------------------ Marcos ------------------------------------------*/
 /* Inter-ranging delay period, in milliseconds. */
 #define RNG_DELAY_MS 100
@@ -800,7 +800,7 @@
 uint16_t rec_ancpos;
 uint8_t dist_noutenough_count;
 uint8_t ancdist_hist[11];
-
+uint16_t calCRC;
 void NearPoll(void)
 {
 	
@@ -1098,29 +1098,33 @@
 			}	
 
 			if(para_update)
-			{
-			
-				pack_msgtype = rec_remotepara[0];
-				pack_index = rec_remotepara[1];
-				pack_length = rec_remotepara[2];
-				if(pack_msgtype==2)
-				{
-					if( pack_index == MOTOR_ONTIME_INDEX)
-					{
-                       // if(motor_keeptime==0)
-                            motor_keeptime = rec_remotepara[3];
-					}else{
-                        if(pack_index<200)
+			{   
+               
+                calCRC = CRC_Compute(rec_remotepara,5);
+                if(memcmp(&calCRC,&rec_remotepara[5],2)==0)
+                {
+                    pack_msgtype = rec_remotepara[0];
+                    pack_index = rec_remotepara[1];
+                    pack_length = rec_remotepara[2];
+                    if(pack_msgtype==2)
+                    {
+                        if( pack_index == MOTOR_ONTIME_INDEX)
                         {
-                            memcpy((uint8_t*)&g_com_map + pack_index, &rec_remotepara[3], pack_length);
-                            //返回一个error状态
-                            //SendComMap(pack_datalen,pack_index);
-                            save_com_map_to_flash();
-                            delay_ms(100);
-                            NVIC_SystemReset();
+                           // if(motor_keeptime==0)
+                                motor_keeptime = rec_remotepara[3];
+                        }else{
+                            if(pack_index<200)
+                            {
+                                memcpy((uint8_t*)&g_com_map + pack_index, &rec_remotepara[3], pack_length);
+                                //返回一个error状态
+                                //SendComMap(pack_datalen,pack_index);
+                                save_com_map_to_flash();
+                                delay_ms(100);
+                                NVIC_SystemReset();
+                            }
                         }
-					}
-				}
+                    }
+                }
 			}
             if(get_newdist>=2)
             {

--
Gitblit v1.9.3