免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3488 | 回复: 4
打印 上一主题 下一主题

[Perl][POSIX::Termios]请教终端设置及相关作用,以及values含义 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-15 10:16 |只看该作者 |倒序浏览
5可用积分
POSIX::Termios
new
Create a new Termios object. This object will be destroyed automatically when it is no longer needed. A Termios object corresponds to the termios C struct. new() mallocs a new one, getattr() fills it from a file descriptor, and setattr() sets a file descriptor's parameters to match Termios' contents.

        $termios = POSIX::Termios->new;
getattr
Get terminal control attributes.

Obtain the attributes for stdin.

        $termios->getattr( 0 ) # Recommended for clarity.
        $termios->getattr()
Obtain the attributes for stdout.

        $termios->getattr( 1 )
Returns undef on failure.

getcc
Retrieve a value from the c_cc field of a termios object. The c_cc field is an array so an index must be specified.

        $c_cc[1] = $termios->getcc(1);
getcflag
Retrieve the c_cflag field of a termios object.

        $c_cflag = $termios->getcflag;
getiflag
Retrieve the c_iflag field of a termios object.

        $c_iflag = $termios->getiflag;
getispeed
Retrieve the input baud rate.

        $ispeed = $termios->getispeed;
getlflag
Retrieve the c_lflag field of a termios object.

        $c_lflag = $termios->getlflag;
getoflag
Retrieve the c_oflag field of a termios object.

        $c_oflag = $termios->getoflag;
getospeed
Retrieve the output baud rate.

        $ospeed = $termios->getospeed;
setattr
Set terminal control attributes.

Set attributes immediately for stdout.

        $termios->setattr( 1, &POSIX::TCSANOW );
Returns undef on failure.

setcc
Set a value in the c_cc field of a termios object. The c_cc field is an array so an index must be specified.

        $termios->setcc( &POSIX::VEOF, 1 );
setcflag
Set the c_cflag field of a termios object.

        $termios->setcflag( $c_cflag | &POSIX::CLOCAL );
setiflag
Set the c_iflag field of a termios object.

        $termios->setiflag( $c_iflag | &POSIX::BRKINT );
setispeed
Set the input baud rate.

        $termios->setispeed( &POSIX::B9600 );
Returns undef on failure.

setlflag
Set the c_lflag field of a termios object.

        $termios->setlflag( $c_lflag | &POSIX::ECHO );
setoflag
Set the c_oflag field of a termios object.

        $termios->setoflag( $c_oflag | &POSIX::OPOST );
setospeed
Set the output baud rate.

        $termios->setospeed( &POSIX::B9600 );
Returns undef on failure.

Baud rate values
B38400 B75 B200 B134 B300 B1800 B150 B0 B19200 B1200 B9600 B600 B4800 B50 B2400 B110

Terminal interface values
TCSADRAIN TCSANOW TCOON TCIOFLUSH TCOFLUSH TCION TCIFLUSH TCSAFLUSH TCIOFF TCOOFF

c_cc field values
VEOF VEOL VERASE VINTR VKILL VQUIT VSUSP VSTART VSTOP VMIN VTIME NCCS

c_cflag field values
CLOCAL CREAD CSIZE CS5 CS6 CS7 CS8 CSTOPB HUPCL PARENB PARODD

c_iflag field values
BRKINT ICRNL IGNBRK IGNCR IGNPAR INLCR INPCK ISTRIP IXOFF IXON PARMRK

c_lflag field values
ECHO ECHOE ECHOK ECHONL ICANON IEXTEN ISIG NOFLSH TOSTOP

c_oflag field values
OPOST

最佳答案

查看完整内容

有用吗?《Linux 程序设计入门》 第四版 §5 终端 §5.4 termios结构§5.4 termios结构Termios是POSIX规定的标准接口,它和System V的接口termio.类似。使用数据结构termios,在termios.h中定义,该文件还包含小量的函数调用。使用termios.h中的函数调用时,要链接合适的函数库。根据系统,可能是标准的c库或者curses库。如有必要,编译的时候需要添加:-lcurses。老系统中甚至为-lncurses。http://blog.chinaunix.net/u/21908/sh ...

论坛徽章:
0
2 [报告]
发表于 2008-12-15 10:16 |只看该作者
有用吗?

《Linux 程序设计入门》 第四版 §5 终端 §5.4 termios结构
§5.4  termios结构

Termios是POSIX规定的标准接口,它和System V的接口termio.类似。使用数据结构termios,在termios.h中定义,该文件还包含小量的函数调用。

使用termios.h中的函数调用时,要链接合适的函数库。根据系统,可能是标准的c库或者curses库。如有必要,编译的时候需要添加:-lcurses。老系统中甚至为-lncurses。

http://blog.chinaunix.net/u/21908/showart.php?id=1712980

论坛徽章:
3
戌狗
日期:2014-09-10 17:07:162015年辞旧岁徽章
日期:2015-03-03 16:54:15wusuopu
日期:2016-06-17 17:43:45
3 [报告]
发表于 2008-12-15 10:38 |只看该作者
TERMIOS详解
http://www.cublog.cn/u/8780/showart_190638.html

POSIX操作系统串行编程指南
http://blog.csdn.net/dima_zy/archive/2008/02/28/2127097.aspx
Serial Programming Guide for POSIX Operating Systems http://www.easysw.com/%7Emike/serial/serial.html#3_1

论坛徽章:
0
4 [报告]
发表于 2008-12-15 10:48 |只看该作者
我在创建tty后调用bash测试,发现more命令输出1屏就自动退出了,man命令有概率会发生输入控制字符的提示位置到了屏幕当中,不知道怎么设置好。。。。。。

[ 本帖最后由 huhuegg 于 2008-12-15 11:09 编辑 ]

论坛徽章:
0
5 [报告]
发表于 2008-12-16 15:41 |只看该作者
虽然more输出1屏就退出的问题没有解决,不过还是谢谢帮助
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP