VxWorks Reference Manual : Libraries

ptyDrv

NAME

ptyDrv - pseudo-terminal driver

ROUTINES

ptyDrv( ) - initialize the pseudo-terminal driver
ptyDevCreate( ) - create a pseudo terminal
ptyDevRemove( ) - destroy a pseudo terminal

DESCRIPTION

The pseudo-terminal driver provides a tty-like interface between a master and slave process, typically in network applications. The master process simulates the "hardware" side of the driver (e.g., a USART serial chip), while the slave process is the application program that normally talks to the driver.

USER-CALLABLE ROUTINES

Most of the routines in this driver are accessible only through the I/O system. However, the following routines must be called directly: ptyDrv( ) to initialize the driver, ptyDevCreate( ) to create devices, and ptyDevRemove( ) to remove an existing device.

INITIALIZING THE DRIVER

Before using the driver, it must be initialized by calling ptyDrv( ). This routine must be called before any reads, writes, or calls to ptyDevCreate( ).

CREATING PSEUDO-TERMINAL DEVICES

Before a pseudo-terminal can be used, it must be created by calling ptyDevCreate( ):

    STATUS ptyDevCreate
        (
        char  *name,      /* name of pseudo terminal      */
        int   rdBufSize,  /* size of terminal read buffer */
        int   wrtBufSize  /* size of write buffer         */
        )
For instance, to create the device pair "/pty/0.M" and "/pty/0.S", with read and write buffer sizes of 512 bytes, the proper call would be:
   ptyDevCreate ("/pty/0.", 512, 512);
When ptyDevCreate( ) is called, two devices are created, a master and slave. One is called nameM and the other nameS. They can then be opened by the master and slave processes. Data written to the master device can then be read on the slave device, and vice versa. Calls to ioctl( ) may be made to either device, but they should only apply to the slave side, since the master and slave are the same device.

The ptyDevRemove( ) routine will delete an existing pseudo-terminal device and reclaim the associated memory. Any file descriptors associated with the device will be closed.

IOCTL FUNCTIONS

Pseudo-terminal drivers respond to the same ioctl( ) functions used by tty devices. These functions are defined in ioLib.h and documented in the manual entry for tyLib.

INCLUDE FILES

ioLib.h, ptyDrv.h

SEE ALSO

ptyDrv, tyLib, VxWorks Programmer's Guide: I/O System


Libraries : Routines

ptyDrv( )

NAME

ptyDrv( ) - initialize the pseudo-terminal driver

SYNOPSIS


STATUS ptyDrv (void)

DESCRIPTION

This routine initializes the pseudo-terminal driver. It must be called before any other routine in this module.

RETURNS

OK, or ERROR if the master or slave devices cannot be installed.

SEE ALSO

ptyDrv


Libraries : Routines

ptyDevCreate( )

NAME

ptyDevCreate( ) - create a pseudo terminal

SYNOPSIS

STATUS ptyDevCreate
    (
    char * name,      /* name of pseudo terminal */
    int    rdBufSize, /* size of terminal read buffer */
    int    wrtBufSize /* size of write buffer */
    )

DESCRIPTION

This routine creates a master and slave device which can then be opened by the master and slave processes. The master process simulates the "hardware" side of the driver, while the slave process is the application program that normally talks to a tty driver. Data written to the master device can then be read on the slave device, and vice versa.

RETURNS

OK, or ERROR if memory is insufficient.

SEE ALSO

ptyDrv


Libraries : Routines

ptyDevRemove( )

NAME

ptyDevRemove( ) - destroy a pseudo terminal

SYNOPSIS

STATUS ptyDevRemove
    (
    char * pName /* name of pseudo terminal to remove */
    )

DESCRIPTION

This routine removes an existing master and slave device and releases all allocated memory. It will close any open files using either device.

RETURNS

OK, or ERROR if terminal not found

SEE ALSO

ptyDrv