The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

POSIX::1003::Termios - POSIX general terminal interface

INHERITANCE

 POSIX::1003::Termios
   is a POSIX::1003

 POSIX::1003::Termios
   is a POSIX::Termios

SYNOPSIS

  use POSIX::1003::Termios qw(:speed);
  $termios = POSIX::1003::Termios->new;
  $ispeed = $termios->getispeed;
  $termios->setospeed(B9600);

  use POSIX::1003::Termios qw(:functions :actions);
  tcsendbreak($fd, $duration);
  tcflush($fd, TCIFLUSH);

  $tty  = ttyname($fd);
  $tty  = ttyname($fh->fileno);

DESCRIPTION

This module provides an interface to the "General Terminal Interfaces", as specified by POSIX. The actual implementation is part of POSIX.xs

METHODS

Constructors

POSIX::1003::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.

  $termios = POSIX::1003::Termios->new;

Accessors

$obj->getattr([FD])

Get terminal control attributes (POSIX function tcgetattr). Pass a file descriptor, which defaults to 0 (stdin). Returns undef on failure.

  # Obtain the attributes for stdin
  $termios->getattr(0);
  $termios->getattr();

  # Obtain the attributes for stdout
  $termios->getattr(1);
$obj->getcc(INDEX)

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);

$obj->getcflag()

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

$obj->getiflag()

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

$obj->getispeed()

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

$obj->getlflag()

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

$obj->getoflag()

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

$obj->getospeed()

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

$obj->setattr(FD, FLAGS)

Set terminal control attributes (POSIX function tcsetattr). Returns undef on failure.

  # Set attributes immediately for stdout.
  $termios->setattr(1, TCSANOW);
$obj->setcc(VALUE, INDEX)

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(VEOF, 1 );

$obj->setcflag(FLAGS)

Set the c_cflag field of a termios object. $termios->setcflag( $c_cflag | CLOCAL );

$obj->setiflag(FLAGS)

Set the c_iflag field of a termios object. $termios->setiflag( $c_iflag | BRKINT );

$obj->setispeed()

Set the input baud rate. Returns undef on failure. $termios->setispeed( B9600 );

$obj->setlflag(FLAGS)

Set the c_lflag field of a termios object. $termios->setlflag( $c_lflag | ECHO );

$obj->setoflag(FLAGS)

Set the c_oflag field of a termios object. $termios->setoflag( $c_oflag | OPOST );

$obj->setospeed()

Set the output baud rate. $termios->setospeed( B9600 );

FUNCTIONS

tcdrain(FD)
tcflow(FD, ACTION)

See the possible ACTION values in "CONSTANTS", import tag :action

tcflush(FD, QUEUE)

See the possible QUEUE values in "CONSTANTS", import tag :flush

tcsendbreak(FD, DURATION)

DURATION is system dependent.

ttyname(FD)

Returns the path to the special device which relates to the file-descriptor. See also POSIX::1003::Proc::ctermid()

  $tty  = ttyname($fd);
  $tty  = ttyname($fh->fileno);

CONSTANTS

Available baudrates (ispeed and ospeed), export tag :speed.
  B0 B50 B75 B110 B134 B150 B200 B300 B600 B1200
  B1800 B2400 B4800 B9600 B19200 B38400
Interface values (getattr and setattr), export tag :actions.
  TCSADRAIN TCSANOW TCOON TCION TCSAFLUSH TCIOFF TCOOFF
To be used as tcflush() parameter QUEUE
  TCIOFLUSH TCOFLUSH TCIFLUSH
c_cc field values, export tag :flags as have all following constants.
  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

SEE ALSO

This module is part of POSIX-1003 distribution version 0.03, built on December 22, 2011. Website: http://perl.overmeer.net. The code is based on POSIX, which is released with Perl itself.

COPYRIGHTS

Copyrights of the perl code and the related documentation by 2011 by Mark Overmeer. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html