From ab16ddec95bf2abfed4a7b19ef59444b1a75f126 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期三, 04 一月 2023 11:26:46 +0800
Subject: [PATCH] 1.自动时间片标签,修改升级触发逻辑,修改参数增加校验

---
 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