Linux内核修改串口缓冲区,关于linux串口,定时器与缓存的问题分析与解决

本文探讨了Linux内核非规范输入处理模式下,串口缓冲区的VTIME和VMIN参数对读取行为的影响。MIN设置接收字符的最小数量,TIME作为字符定时器。当MIN=0且TIME>0时,TIME作为超时值;MIN>0且TIME>0时,TIME作为字符间定时器。通过调整这两个参数,可以避免串口阻塞并实现灵活的读取策略。举例说明,将newtio.c_cc[VMIN]设为1,newtio.c_cc[VTIME]设为31,允许在100ms内接收0-31个字符,防止串口阻塞。
摘要由CSDN通过智能技术生成

In non-canonical input processing mode, input is not assembled into lines and input processing (erase, kill, delete, etc.) does not occur. Two parameters control the behavior of this mode: c_cc[VTIME] sets the character timer, and c_cc[VMIN] sets the minimum number of characters to receive before satisfying the read.

If MIN > 0 and TIME = 0, MIN sets the number of characters to receive before the read is satisfied. As TIME is zero, the timer is not used.

If MIN = 0 and TIME > 0, TIME serves as a timeout value. The read will be satisfied if a single character is read, or TIME is exceeded (t = TIME *0.1 s). If TIME is exceeded, no character will be returned.

If MIN > 0 and TIME > 0, TIME serves as an inter-character timer. The read will be satisfied if MIN characters are received, or the time between two characters exceeds TIME. The timer is restarted every time a character is received and only becomes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值