VxWorks Reference Manual : Libraries
ptyDrv - pseudo-terminal driver
ptyDrv( ) - initialize the pseudo-terminal driver
ptyDevCreate( ) - create a pseudo terminal
ptyDevRemove( ) - destroy a pseudo terminal
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.
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.
Before using the driver, it must be initialized by calling ptyDrv( ). This routine must be called before any reads, writes, or calls to ptyDevCreate( ).
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.
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.
ioLib.h, ptyDrv.h
ptyDrv, tyLib, VxWorks Programmer's Guide: I/O System
ptyDrv( ) - initialize the pseudo-terminal driver
STATUS ptyDrv (void)
This routine initializes the pseudo-terminal driver. It must be called before any other routine in this module.
OK, or ERROR if the master or slave devices cannot be installed.
ptyDevCreate( ) - create a pseudo terminal
STATUS ptyDevCreate ( char * name, /* name of pseudo terminal */ int rdBufSize, /* size of terminal read buffer */ int wrtBufSize /* size of write buffer */ )
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.
OK, or ERROR if memory is insufficient.
ptyDevRemove( ) - destroy a pseudo terminal
STATUS ptyDevRemove ( char * pName /* name of pseudo terminal to remove */ )
This routine removes an existing master and slave device and releases all allocated memory. It will close any open files using either device.
OK, or ERROR if terminal not found