From 3ddda900487f55bec506562fffd9f38e419a3ecd Mon Sep 17 00:00:00 2001
From: chen <15335560115@163.com>
Date: 星期六, 12 七月 2025 16:34:10 +0800
Subject: [PATCH] 成功调好485串口接和收逻辑,usb串口用于查看log输出和上位机配置,需要注意在打印彻底完成后进行切换

---
 keil/include/drivers/serial_at_cmd_app.c |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/keil/include/drivers/serial_at_cmd_app.c b/keil/include/drivers/serial_at_cmd_app.c
index be1ba0c..60f1ee5 100644
--- a/keil/include/drivers/serial_at_cmd_app.c
+++ b/keil/include/drivers/serial_at_cmd_app.c
@@ -81,7 +81,27 @@
     sum = ~sum;
     return sum;
 }
-
+void SendComMap0(uint8_t data_length, uint8_t index)//表示成功读取的回应包
+{
+    static uint8_t send_frame[EUART0_RX_BUF_SIZE];
+    uint16_t checksum = 0;
+    send_frame[0] = 0x55;
+    send_frame[1] = 0xAA;
+    send_frame[2] = 0x03;
+    send_frame[3] = data_length+5;
+    send_frame[4] = CMD_REPLY;
+    send_frame[5] = index;
+    send_frame[6] = data_length;
+    memcpy(&send_frame[7], &g_com_map[index], data_length);
+    for(int i = 0; i<(data_length+5); i++)
+    {
+        checksum += send_frame[2+i];
+    }
+    checksum = Checksum_u16(&send_frame[2],5+data_length);
+    memcpy(&send_frame[7+data_length],&checksum,2);
+		
+    uart_send(UART_ID0, send_frame,data_length+9, NULL);
+}
 void SendComMap(uint8_t data_length, uint8_t index)//表示成功读取的回应包
 {
     static uint8_t send_frame[EUART0_RX_BUF_SIZE];
@@ -275,8 +295,8 @@
 static uint8_t send_frame[256];  // 用于计算校验和的帧
 static uint8_t frame_index = 0;  // 帧缓冲区索引
 static uint8_t pack_datalen = 0;
-    
-	LOG_INFO(TRACE_MODULE_APP,"收到 %#x\r\n",data);
+    LOG_INFO(TRACE_MODULE_APP,"收到数据%c\r\n",data);
+	//LOG_INFO(TRACE_MODULE_APP,"收到 %#x\r\n",data);
     switch(usart0_receive_state) {
         case Usart0ReceiveWaitHead0:
             if(data == 0x55) {
@@ -471,7 +491,7 @@
                 case CMD_READ:
                     //read包中data字节,即mUsartReceivePack[0]表示数据长度;
                     //从g_com_data结构体中的第index位置读取长度为mUsartReceivePack[0]的字节,发送出来
-                    SendComMap(pack_datalen,pack_index>>1);
+                    SendComMap0(pack_datalen,pack_index>>1);
                     break;
                 default:
                     break;

--
Gitblit v1.9.3