wiki:Component/TtyWrapper

SocLib Components General Index

Component description

This component is a common utility component. This creates a wrapper to a TTY process. The TTY process aims to provide a serial terminal to the user. Output will always be logged to a file named after the term's name.

There are 4 TTY backends:

  • wrapped Xterm
  • wrapped xtty (an ad-hoc terminal)
  • file (write only)
  • stdout (write only, stdout is shared with the simulator's messages)

Component usage

Object

soclib::common::TtyWrapper *tty;

Instanciation

You should use soclib::common::allocateTty to allocate a new TTY.

TtyWrapper honors $SOCLIB_TTY environment variable. Possible values are:

  • XTERM: use Xterm
  • XTTY: use xtty
  • TERM: log on stdout
  • FILES: only log to a file
  • PTS: open the master side of a pseudo-terminal. The slave PTY name will be advertized for on the console.

Default value is XTERM, if $DISPLAY is not set (ie there is no X server available), TERM is used as a fallback.

    soclib::common::TtyWrapper *my_tty = soclib::common::allocateTty( "my_tty_name" );

Usage

    soclib::common::TtyWrapper *my_tty = soclib::common::allocateTty( "my_tty_name" );
    char got_char;

    my_tty->putc('a')

    if ( my_tty->has_data() )
         got_char = my_tty->getc();
Last modified 13 years ago Last modified on May 11, 2009, 5:09:59 PM