| | 1 | [wiki:Component SocLib Components General Index] |
| | 2 | |
| | 3 | = Component description = |
| | 4 | |
| | 5 | This component is a common utility component. |
| | 6 | This creates a wrapper to a TTY process. The TTY process aims to provide a serial terminal to the user. |
| | 7 | Output will always be logged to a file named after the term's name. |
| | 8 | |
| | 9 | There are 4 TTY backends: |
| | 10 | * wrapped Xterm |
| | 11 | * wrapped xtty (an ad-hoc terminal) |
| | 12 | * file (write only) |
| | 13 | * stdout (write only, stdout is shared with the simulator's messages) |
| | 14 | |
| | 15 | = Component usage = |
| | 16 | |
| | 17 | == Object == |
| | 18 | |
| | 19 | {{{ |
| | 20 | soclib::common::TtyWrapper *tty; |
| | 21 | }}} |
| | 22 | |
| | 23 | == Instanciation == |
| | 24 | |
| | 25 | You should use `soclib::common::allocateTty` to allocate a new TTY. |
| | 26 | |
| | 27 | !TtyWrapper honors `$SOCLIB_TTY` environment variable. Possible values are: |
| | 28 | * XTERM: use Xterm |
| | 29 | * XTTY: use xtty |
| | 30 | * TERM: log on stdout |
| | 31 | * FILES: only log to a file |
| | 32 | |
| | 33 | Default value is XTERM, if `$DISPLAY` is not set (ie there is no X server available), TERM is used as a fallback. |
| | 34 | |
| | 35 | {{{ |
| | 36 | soclib::common::TtyWrapper *my_tty = soclib::common::allocateTty( "my_tty_name" ); |
| | 37 | }}} |
| | 38 | |
| | 39 | == Usage == |
| | 40 | |
| | 41 | {{{ |
| | 42 | soclib::common::TtyWrapper *my_tty = soclib::common::allocateTty( "my_tty_name" ); |
| | 43 | char got_char; |
| | 44 | |
| | 45 | my_tty->putc('a') |
| | 46 | |
| | 47 | if ( my_tty->has_data() ) |
| | 48 | got_char = my_tty->getc(); |
| | 49 | }}} |