#include "bsp_uart.h" #include "bsp_protocol.h" void send_to_uart_AABBCC(uint8_t index,uint8_t cmd,uint8_t* dat,uint8_t datLen) { uint8_t buf[255]; uint16_t Len = datLen+5; uint16_t L=0; uint8_t i; uint8_t ver = 0; if(Len>255) return; buf[L++] = 0xAA; ver += 0xAA; //帧头 buf[L++] = Len; ver += Len; //长度 buf[L++] = ~Len; ver += (~Len);//长度反码 buf[L++] = cmd; ver += cmd; //命令 for(i=0;i UPDATE_BASEINFO\n"); send_uart_data_UPDATE_BASEINFO();//发送设备基本信息 break; } //printf("AABBCC_callback -> UPDATE_BASEINFO\n"); break; default: break; } } unsigned char AABBCC_buff[50]; void AABBCC_REC(unsigned char data) { static char len=0; static char crc=0; if(((len==0)&&(data==0xAA)) || ( len==1) || ((len==2)&&(AABBCC_buff[1] + data==0xFF)) || ((len >2)&&(AABBCC_buff[1]-1 > len)) ) { AABBCC_buff[len++]=data; crc+=data; } else if((AABBCC_buff[1]-1 == len) && ( crc==data )) { AABBCC_buff[len]=data; AABBCC_callback(AABBCC_buff,len);//接收完成,回调事件函数 } else { len=0; crc=0; } } //。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。