|
@ -1,4 +1,16 @@ |
|
|
#include "atcmd.h" |
|
|
#include "atcmd.h" |
|
|
|
|
|
#include "zport.h" |
|
|
|
|
|
|
|
|
|
|
|
#define at_processer_rx_buf_size 128 |
|
|
|
|
|
#define at_processer_tx_buf_size 128 |
|
|
|
|
|
|
|
|
|
|
|
// 接收到了多少数据 |
|
|
|
|
|
volatile uint16_t s_at_cmd_uart_rx_off = 0; |
|
|
|
|
|
// 当前是否正在处理接收到的数据 |
|
|
|
|
|
volatile bool s_at_cmd_uart_rx_buf_is_processing = false; |
|
|
|
|
|
|
|
|
|
|
|
static uint8_t at_rx_buf[at_processer_rx_buf_size]; |
|
|
|
|
|
//static uint8_t at_tx_buf[at_processer_tx_buf_size]; |
|
|
|
|
|
|
|
|
/* AT指令表 */ |
|
|
/* AT指令表 */ |
|
|
const AT_cmd_func at_cmd_func[] = { |
|
|
const AT_cmd_func at_cmd_func[] = { |
|
@ -132,3 +144,45 @@ unsigned char at_cmd_parse(unsigned char *p, unsigned char len) |
|
|
|
|
|
|
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void at_cmd_processer_push_data(uint8_t rxdata) |
|
|
|
|
|
{ |
|
|
|
|
|
if (!s_at_cmd_uart_rx_buf_is_processing) |
|
|
|
|
|
{ |
|
|
|
|
|
if (s_at_cmd_uart_rx_off < at_processer_rx_buf_size) |
|
|
|
|
|
{ |
|
|
|
|
|
at_rx_buf[s_at_cmd_uart_rx_off] = rxdata; |
|
|
|
|
|
s_at_cmd_uart_rx_off++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void at_cmd_processer_try_process_data(void) |
|
|
|
|
|
{ |
|
|
|
|
|
/** |
|
|
|
|
|
* @brief |
|
|
|
|
|
* 根据modbus协议,当超过3.5个字符时间后依然没有收到数据 |
|
|
|
|
|
*/ |
|
|
|
|
|
if (s_at_cmd_uart_rx_off != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
uint16_t modbus_uart_rx_off_before = s_at_cmd_uart_rx_off; |
|
|
|
|
|
|
|
|
|
|
|
HAL_Delay(1); |
|
|
|
|
|
|
|
|
|
|
|
sys_critical_enter(); |
|
|
|
|
|
if (s_at_cmd_uart_rx_off == modbus_uart_rx_off_before) |
|
|
|
|
|
{ |
|
|
|
|
|
s_at_cmd_uart_rx_buf_is_processing = true; |
|
|
|
|
|
} |
|
|
|
|
|
sys_critical_exit(); |
|
|
|
|
|
|
|
|
|
|
|
if (s_at_cmd_uart_rx_buf_is_processing) |
|
|
|
|
|
{ |
|
|
|
|
|
at_cmd_parse(at_rx_buf, s_at_cmd_uart_rx_off); |
|
|
|
|
|
sys_critical_enter(); |
|
|
|
|
|
s_at_cmd_uart_rx_off = 0; |
|
|
|
|
|
s_at_cmd_uart_rx_buf_is_processing = false; |
|
|
|
|
|
sys_critical_exit(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |