本帖最后由 胖胖的杰瑞鼠 于 2024-10-21 17:50 编辑
我使用这个工程进行串口接收测试,hosal_uart_dev_t uart_dev_int = {
.config = {
.uart_id = 0,
.tx_pin = 16, // TXD GPIO
.rx_pin = 7, // RXD GPIO
.cts_pin = 255,
.rts_pin = 255,
.baud_rate = 115200,
.data_width = HOSAL_DATA_WIDTH_8BIT,
.parity = HOSAL_NO_PARITY,
.stop_bits = HOSAL_STOP_BITS_1,
.mode = HOSAL_UART_MODE_POLL,
},
};
如果发送更长的数据ATSOCKETSENDasdqwertyuiopzxcvbnm123456789,接收到的__uart_rx_callback : 1
rx num : 0 0x41
__uart_rx_callback : 8
rx num : 0 0x54
rx num : 1 0x53
rx num : 2 0x4f
rx num : 3 0x43
rx num : 4 0x4b
rx num : 5 0x45
rx num : 6 0x54
rx num : 7 0x53
__uart_rx_callback : 32
rx num : 0 0x45
rx num : 1 0x4e
rx num : 2 0x44
rx num : 3 0x61
rx num : 4 0x73
rx num : 5 0x64
rx num : 6 0x71
rx num : 7 0x77
rx num : 8 0x65
rx num : 9 0x72
rx num : 10 0x74
rx num : 11 0x79
rx num : 12 0x75
rx num : 13 0x69
rx num : 14 0x6f
rx num : 15 0x70
rx num : 16 0x7a
rx num : 17 0x78
rx num : 18 0x63
rx num : 19 0x76
rx num : 20 0x62
rx num : 21 0x6e
rx num : 22 0x6d
rx num : 23 0x31
rx num : 24 0x32
rx num : 25 0x33
rx num : 26 0x34
rx num : 27 0x35
rx num : 28 0x36
rx num : 29 0x37
rx num : 30 0x38
rx num : 31 0x39
__uart_rx_callback : 0
__uart_rx_callback : 0
blufi demo test 260
缺了很多,这是为什么,三种方式都不能完整接收到我发的一帧数据
static void uart_init(void)
{
hosal_uart_init(&uart_dev_int);
hosal_uart_ioctl(&uart_dev_int, HOSAL_UART_MODE_SET, (void *)HOSAL_UART_MODE_INT);
hosal_uart_callback_set(&uart_dev_int, HOSAL_UART_RX_CALLBACK,
__uart_rx_callback, &uart_dev_int);
hosal_uart_callback_set(&uart_dev_int, HOSAL_UART_TX_CALLBACK,
__uart_tx_callback, &uart_dev_int);
hosal_uart_ioctl(&uart_dev_int, HOSAL_UART_TX_TRIGGER_ON, NULL);
// hosal_uart_ioctl(&uart_dev_int, HOSAL_UART_RX_TRIGGER_ON, NULL);
}
static int __uart_rx_callback(void *p_arg)
{
int ret;
hosal_uart_dev_t *p_dev = (hosal_uart_dev_t *)p_arg;
ret = hosal_uart_receive(&uart_dev_int, data_buf, sizeof(data_buf));
printf("__uart_rx_callback : %d\r\n", ret);
for (int i = 0; i < ret; i++)
{
printf("rx num : %d 0x%02x\r\n", i, data_buf);
}
return 0;
}
接收到的数据不完整发送123456789,接收到__uart_rx_callback : 1
rx num : 0 0x31
__uart_rx_callback : 8
rx num : 0 0x32
rx num : 1 0x33
rx num : 2 0x34
rx num : 3 0x35
rx num : 4 0x36
rx num : 5 0x37
rx num : 6 0x38
rx num : 7 0x39
__uart_rx_callback : 0
|