大神们 发送AT命令的时候+++可以收到回复ok 但是发送AT+PID? 这种 就不行 帮帮看看
static at_cmd s_zigbee_init_cmd [] = {
{"+++","OK",3, 2},
{"+++","OK",3, 2},
{"+++","OK",3, 2},
{"+++","OK",3, 2},
{"AT+PRF=0","OK",8,2},
{"AT+VER","OK",6, 2},
};
void zigbee_task(void *p_arg)
{
zigbee_msg_st ltv_Msg;
unsigned char lcv_BuffIndex;
unsigned char *lcp_RecvPtr;
unsigned char *lcp_SendPtr;
unsigned char i;
uint8_t atcmdindex = 0;
/*zigbee初始化*/
zigbee_usart1_init();
/*创建消息队列*/
gtv_ZigbeeTaskMsgQueueHandle = xQueueCreate(10, sizeof(zigbee_msg_st));
configASSERT(gtv_ZigbeeTaskMsgQueueHandle != NULL);
while(1) {
lcv_BuffIndex = bsp_get_usart1_send_buff_index();
if(lcv_BuffIndex) {
lcp_SendPtr = gcav_Usart1DmaTxBuffer[1];
} else {
lcp_SendPtr = gcav_Usart1DmaTxBuffer[0];
}
for(i=0; i<s_zigbee_init_cmd[atcmdindex].mcv_AtCmdLen; i++) {
/**拷贝数据**/
lcp_SendPtr = s_zigbee_init_cmd[atcmdindex].mcv_AtCmdBuff;
}
/**发送函数**/
usart1_send_buffer(NULL,s_zigbee_init_cmd[atcmdindex].mcv_AtCmdLen);
/*等待串口消息*/
xQueueReceive(gtv_ZigbeeTaskMsgQueueHandle, &ltv_Msg, portMAX_DELAY);
if(ltv_Msg.mcv_RxIndex) {
lcp_RecvPtr = gcav_Usart1DmaRxBuffer[1];
} else {
lcp_RecvPtr = gcav_Usart1DmaRxBuffer[0];
}
do {
if((lcp_RecvPtr[0] == 0x0D) && (lcp_RecvPtr[1] == 0x0A)) {
lcp_RecvPtr = &lcp_RecvPtr[2];
} else {
break;
}
} while(1);
/*接收和结构体比较*/
for(i=0; i<s_zigbee_init_cmd[atcmdindex].mcv_RecvLen; i++) {
if(lcp_RecvPtr != s_zigbee_init_cmd[atcmdindex].mcv_RespBuff) {
break;
}
}
if(i >= s_zigbee_init_cmd[atcmdindex].mcv_RecvLen) {
if(atcmdindex+1 < sizeof(s_zigbee_init_cmd)/sizeof(at_cmd)) {
atcmdindex++;
} else {
atcmdindex = 0;//重新发送
}
} else {
}
}
} |