2020-02-11 10:00发布
tkggitfk24 发表于 2014-6-15 01:13 如果是polled方式,你肯定要查询有没有数据,没数据来你还死等啊, int方式可以采用事件或者信号量通知task ...
liao-ljj 发表于 2014-6-15 08:49 搞一个信号量,有接收时在read
wangpengcheng 发表于 2014-6-16 10:24 搞定了,还是自己看文档不仔细啊!串口在打开的时候有可以设置如下标志,是打开非阻塞读取串口驱动的!希望 ...
FSL_TICS_ZP 发表于 2014-6-17 09:05 好的,sorry,没看到你的问题,所以也没叫MQX工程师帮你看一下。
最多设置5个标签!
关键问题是驱动都是写好的,改起来挺麻烦!
实在没有办法的时候可能会用中断讯取,然后建信号量!
IO_SERIAL_NON_BLOCKING
Open the serial driver in non blocking mode. In this mode the _io_read() function doesn’t wait till the receive buffer is full, but it immediately returns received characters and number of received characters.
- char read_buff[50];
- int index = 0, size = 0;
- MQX_FILE_PTR uart_handle = fopen("ittya:", (char const *)IO_SERIAL_NON_BLOCKING);
- while(1)
- {
- //Wait Receive
- while(size == 0)
- {
- _time_delay(2);
- size = read(uart_handle, &read_buff[index], sizeof(read_buff));
- }
- //Buffer Index Change
- index += size;
- //Receive End Test
- if((read_buff[index - 1] == '
') && (read_buff[index - 2] == '
'))
- break;
- }
- fclose(uart_handle);
复制代码请版主帮忙结贴,谢谢!
好的,sorry,没看到你的问题,所以也没叫MQX工程师帮你看一下。
没事,有时候自己研究出来的印象比较深
一周热门 更多>