From 27ef584b1870ce42d7ea5dc5a1cf67a1f642d434 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期五, 15 四月 2022 16:01:13 +0800 Subject: [PATCH] 增加调试信息输出 --- 源码/核心板/Src/application/serial_at_cmd_app.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 42 insertions(+), 4 deletions(-) diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c" index 2993869..4addd96 100644 --- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c" +++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/serial_at_cmd_app.c" @@ -7,6 +7,7 @@ #define MSG_RW 3 #define MSG_WTAG 6 +#define MSG_USERDATA 0x11 #define CMD_READ 1 #define CMD_WRITE 2 @@ -25,7 +26,7 @@ }UsartRecvPackState; uint8_t mUsartReceivePack[100] = {0}; -uint8_t send_frame[200]; +uint8_t send_frame[200],uartrec_userdata[USERDATA_MAXLEN]; void SendConfigConfirm(uint8_t pack_msgtype,uint8_t pack_length) { uint16_t checksum = 0; @@ -61,8 +62,23 @@ UART_PushFrame(send_frame, data_length+9); } +void SendDbgMsg(char* buffer, uint8_t data_length) +{ + uint16_t checksum = 0; + send_frame[0] = 0x55; + send_frame[1] = 0xAA; + send_frame[2] = 0x12; + send_frame[3] = data_length+3; + memcpy(&send_frame[4],buffer,data_length); + send_frame[4+data_length] = 0; + checksum = Checksum_u16(&send_frame[2],3+data_length); + memcpy(&send_frame[5+data_length],&checksum,2); + + UART_PushFrame(send_frame, data_length+7); + +} u8 remotetag_para[30]; -u8 remotesend_state=0; +u8 remotesend_state=0,usartrec_userdatalen; u16 rec_checksum; void UsartParseDataHandler(uint8_t data) { @@ -94,13 +110,25 @@ { case CMD_WRITE: //从mUsartReceivePack中读取pack_length长度的字节,放到全局变量中 - memcpy((uint8_t*)&g_com_map + pack_index, mUsartReceivePack, pack_datalen); + if(pack_index<0xf0&&pack_index!=0x14) + // if(pack_index>100) + { + memcpy((uint8_t*)&g_com_map + pack_index, mUsartReceivePack, pack_datalen); //返回一个error状态 //SendComMap(pack_datalen,pack_index); save_com_map_to_flash(); SendConfigConfirm(pack_msgtype,pack_length); delay_ms(500); - SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader + SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader + + }else{ + memcpy((uint8_t*)&g_com_map + pack_index, mUsartReceivePack, pack_datalen); + //返回一个error状态 + //SendComMap(pack_datalen,pack_index); + //save_com_map_to_flash(); + SendConfigConfirm(pack_msgtype,pack_length); + + } break; case CMD_READ: //read包中data字节,即mUsartReceivePack[0]表示数据长度; @@ -117,6 +145,16 @@ remotesend_state=1; memcpy(remotetag_para,mUsartReceivePack,REMOTEPARA_LEN); break; + case MSG_USERDATA: + if(pack_datalen<20) + { + uartrec_userdata[0] = pack_index; + uartrec_userdata[1] = pack_datalen; + memcpy((uint8_t*)&uartrec_userdata[2], &mUsartReceivePack, pack_cmd-2); + usartrec_userdatalen=pack_cmd; + userdata_timer = 0; + } + break; } } -- Gitblit v1.9.3