dnx RTOS 2.2.0 "Eagle"
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
TTY Driver

Detailed Description

Description

Driver handles terminal virtual device. Driver creates VT100 virtual terminal. Driver is necessary to handle user input and output. Each terminal can handle at least one application. It is possible to connect many application to single terminal but output may be mixed. In most cases the TTY driver input and output is UART device.

Device (drivers) connection table

Grade Device In Out
0 UART/file - /dev/ttyS0
1 TTY driver /dev/ttyS0 /dev/tty0
2 Application /dev/tty0 /dev/tty0

Supported architectures

Details

Meaning of major and minor numbers

The major number determine number of terminal. The minor number should be set always to 0.

Numeration restrictions

Major number should be used in range from 0 to maximum number of terminals configured in module options. Minor number should be always 0.

Driver initialization

To initialize driver the following code can be used:

driver_init("TTY", 0, 0, "/dev/tty0"); // terminal 0
driver_init("TTY", 1, 0, "/dev/tty1"); // terminal 1

Driver release

To release driver the following code can be used:

driver_release("TTY", 0, 0);
driver_release("TTY", 1, 0);

Driver configuration

Driver can be configured in Configtool. Runtime configuration is not possible.

Data write

Writing data to device is the same as writing data to regular file.

Data read

Reading data from device is the same as reading data from regular file.

Terminal switching

Terminals can be switched by using F1 - F4 keys or by using ioctl() function.

Macros

#define IOCTL_TTY__GET_CURRENT_TTY   _IOR(TTY, 0x00, int*)
 Gets current TTY number. More...
 
#define IOCTL_TTY__SWITCH_TTY_TO   _IOW(TTY, 0x01, int*)
 Switch terminal to selected one. More...
 
#define IOCTL_TTY__GET_COL   _IOR(TTY, 0x02, int*)
 Gets number of columns. More...
 
#define IOCTL_TTY__GET_ROW   _IOR(TTY, 0x03, int*)
 Gets number of rows. More...
 
#define IOCTL_TTY__CLEAR_SCR   _IO(TTY, 0x04)
 Clear screen. More...
 
#define IOCTL_TTY__ECHO_ON   _IO(TTY, 0x05)
 Enable terminal echo. More...
 
#define IOCTL_TTY__ECHO_OFF   _IO(TTY, 0x06)
 Disable terminal echo. More...
 
#define IOCTL_TTY__SET_EDITLINE   _IOW(TTY, 0x07, const char*)
 Set edit line to specified user's text (string). More...
 
#define IOCTL_TTY__GET_NUMBER_OF_TTYS   _IOR(TTY, 0x08, int*)
 Gets number of virtual terminals. More...
 
#define IOCTL_TTY__REFRESH_LAST_LINE   _IO(TTY, 0x09)
 Refreshes last line. More...
 

Macro Definition Documentation

#define IOCTL_TTY__CLEAR_SCR   _IO(TTY, 0x04)
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_TTY__ECHO_OFF   _IO(TTY, 0x06)
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_TTY__ECHO_ON   _IO(TTY, 0x05)
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_TTY__GET_COL   _IOR(TTY, 0x02, int*)
Parameters
[RD]int * number of columns
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_TTY__GET_CURRENT_TTY   _IOR(TTY, 0x00, int*)
Parameters
[RD]int * terminal number
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_TTY__GET_NUMBER_OF_TTYS   _IOR(TTY, 0x08, int*)
Parameters
[RD]int * number of virtual terminals
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_TTY__GET_ROW   _IOR(TTY, 0x03, int*)
Parameters
[RD]int * number of rows
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_TTY__REFRESH_LAST_LINE   _IO(TTY, 0x09)
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_TTY__SET_EDITLINE   _IOW(TTY, 0x07, const char*)
Parameters
[WR]const char * string passed to edit line
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_TTY__SWITCH_TTY_TO   _IOW(TTY, 0x01, int*)
Parameters
[WR]int * terminal number
Returns
On success 0 is returned, otherwise -1.