From e0c70da5ce5b2504d2ac4cce68376d1ab5cdf208 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期五, 21 五月 2021 17:01:25 +0800 Subject: [PATCH] 标签输出坐标,测试完成 --- 源码/核心板/Src/application/serial_at_cmd_app.c | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 42 insertions(+), 9 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 ed74945..d5fd00c 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" @@ -8,11 +8,13 @@ #define MSG_RW 3 #define MSG_WTAG 6 #define MSG_PWTAG 8 +#define MSG_REGTAGRESPONSE 0x0b +#define MSG_TAGPOS 0x0D #define CMD_READ 1 #define CMD_WRITE 2 #define CMD_REPLY 3 -#define EUART_RX_BUF_SIZE 100 + struct pwtag_structure pwtag; typedef enum{ UsartReceiveWaitHead0, UsartReceiveWaitHead1, @@ -25,10 +27,24 @@ UsartReceiveWaitChecksum }UsartRecvPackState; uint8_t mUsartReceivePack[100] = {0}; +uint8_t send_frame[200]; +void SendConfigConfirm(uint8_t pack_msgtype,uint8_t pack_length) +{ + uint16_t checksum = 0; + send_frame[0] = 0x55; + send_frame[1] = 0xAA; + send_frame[2] = 0x09; + send_frame[3] = 8; + send_frame[4] = pack_msgtype; + send_frame[5] = pack_length; + checksum = Checksum_u16(&send_frame[2],8); + memcpy(&send_frame[10],&checksum,2); + + UART_PushFrame(send_frame, 12); +} void SendComMap(uint8_t data_length, uint8_t index) { - static uint8_t send_frame[EUART_RX_BUF_SIZE]; uint16_t checksum = 0; send_frame[0] = 0x55; send_frame[1] = 0xAA; @@ -38,10 +54,7 @@ send_frame[5] = index; send_frame[6] = data_length; memcpy(&send_frame[7], &g_com_map[index>>1], 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); @@ -49,7 +62,10 @@ } u8 remotetag_para[30],remotetag_paralen; u8 remotesend_state=0; +extern u16 taglist_pos; uint16_t configremotetagID; +struct regtag_structure regtag_map; +struct tagpos_structure tagpos[50]; void UsartParseDataHandler(uint8_t data) { static UsartRecvPackState usart_receive_state = UsartReceiveWaitHead0; @@ -70,7 +86,7 @@ if(((data + checksum)&0xff) == 0xFF) //校验通过 { switch(pack_msgtype) - { + {uint16_t serial_tag_id_recv; case MSG_RW: pack_cmd = mUsartReceivePack[0]; pack_index = mUsartReceivePack[1]; @@ -95,7 +111,7 @@ break; } break; - case MSG_WTAG: + case MSG_WTAG: //修改标签参数 remotesend_state=1; memcpy(&configremotetagID,&mUsartReceivePack[0],2); //configremotetagID = pack_cmd|pack_index<<8; @@ -103,7 +119,7 @@ remotetag_paralen = mUsartReceivePack[4]+3; memcpy(&remotetag_para[1],&mUsartReceivePack[3],remotetag_paralen); break; - case MSG_PWTAG: + case MSG_PWTAG: //批量修改标签参数 pwtag.groupnum = mUsartReceivePack[0]; pwtag.index = mUsartReceivePack[1]; pwtag.remain_time = 5; @@ -113,7 +129,24 @@ memcpy(&pwtag.group_interval[i],&mUsartReceivePack[i*6+6],2); } break; + case MSG_REGTAGRESPONSE: + regtag_map.index++; + if(regtag_map.index==MAX_REGTAGNUM) + {regtag_map.index = 0;} + regtag_map.remain_time[regtag_map.index]=5; + memcpy(®tag_map.tagid[regtag_map.index],&mUsartReceivePack[0],2); + memcpy(®tag_map.tag_frequency[regtag_map.index],&mUsartReceivePack[2],2); + memcpy(®tag_map.tag_slotpos[regtag_map.index],&mUsartReceivePack[4],2); + break; + case MSG_TAGPOS: + memcpy(&serial_tag_id_recv,&mUsartReceivePack[0],2); + taglist_pos=CmpTagInList(serial_tag_id_recv); + tagpos[taglist_pos].tagid = serial_tag_id_recv; + memcpy(&tagpos[taglist_pos].baoxu,&mUsartReceivePack[2],2); + memcpy(&tagpos[taglist_pos].pos,&mUsartReceivePack[4],12); + break; } + SendConfigConfirm(pack_msgtype,pack_length); } usart_receive_state = UsartReceiveWaitHead0; pack_index = 0; -- Gitblit v1.9.3