我怎样才能用超时读取tty的文件? [英] How i can read tty file with timeout?

查看:372
本文介绍了我怎样才能用超时读取tty的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在/ dev目录,在那里我发送AT命令的tty设备。我想读逐行和停止超时后读取文件。<​​/ P>

解决方案

您可以使用该程序的stty 配置tty设备。要查看终端的/ dev / ttyS0的速率设置,请尝试

的stty -a -F为/ dev / ttyS0来

关于超时默认设置为分= 1;时间= 0 ,这意味着,该读出程序将读取,直到至少一个字符已经被读取并且没有超时。例如使用

的stty -F为/ dev / ttyS0来分钟0时10

读程序(例如)将完成1秒东西是否已读或不读之后。该参数的单位时间是十分之一秒;你可以看看男人的stty 了解更多信息。

I have tty device in /dev , where I send AT commands. I want to read line by line and stop reading file after timeout.

解决方案

You can use the program stty to configure the tty device. To see the settings for terminal /dev/ttyS0, try

stty -a -F /dev/ttyS0

The default settings regarding timeout are min = 1; time = 0, which means that the reading program will read until at least one character has been read and there is no timeout. Using e.g.

stty -F /dev/ttyS0 min 0 time 10

the reading program (e.g. cat) will finish reading after one second whether anything has been read or not. The unit for the parameter time is tenths of a second; you can check out man stty for more information.

这篇关于我怎样才能用超时读取tty的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆