Get line status information for the terminal device
#include <sys/dcmd_chr.h> #define DCMD_CHR_LINESTATUS __DIOF(_CMD_IOCTL_TTY, 106, int) /* TIOCMGET */
Argument | Value |
---|---|
filedes | A file descriptor that you obtained by opening the device. |
dcmd | DCMD_CHR_LINESTATUS |
dev_data_ptr | A pointer to an int |
n_bytes | sizeof(int) |
dev_info_ptr | NULL |
This command gets line status information for the terminal device and is usually associated with the control lines of a serial port. It's also implemented as the TIOCMGET ioctl() command.
The contents of the returned data depend on the device. The stty utility calls this function and displays this information.
None.
The line status information, which is a combination of the following bits (depending on the type of device):
Device type | Bit | Description |
---|---|---|
Serial | _LINESTATUS_SER_DTR (TIOCM_DTR) | Data terminal ready |
_LINESTATUS_SER_RTS (TIOCM_RTS) | Request to send | |
_LINESTATUS_SER_CTS (TIOCM_CTS) | Clear to send | |
_LINESTATUS_SER_DSR (TIOCM_DSR) | Data set ready | |
_LINESTATUS_SER_RI (TIOCM_RI or TIOCM_RNG) | Ring | |
_LINESTATUS_SER_CD (TIOCM_CAR or TIOCM_CD) | Carrier detect | |
Console | _LINESTATUS_CON_SCROLL | Scroll Lock is on |
_LINESTATUS_CON_NUM | Num Lock is on | |
_LINESTATUS_CON_CAPS | Caps Lock is on | |
_LINESTATUS_CON_SHIFT | Shift is pressed (not currently used) | |
_LINESTATUS_CON_CTRL | Ctrl is pressed (not currently used) | |
_LINESTATUS_CON_ALT | Alt is pressed (not currently used) | |
Parallel | _LINESTATUS_PAR_NOERROR | No error detected |
_LINESTATUS_PAR_SELECTED | Selected | |
_LINESTATUS_PAR_PAPEROUT | No paper | |
_LINESTATUS_PAR_NOTACK | Not acknowledge | |
_LINESTATUS_PAR_NOTBUSY | Not busy |
Check to see if RTS is set:
int data = 0, error; if (error = devctl (fd, DCMD_CHR_LINESTATUS, &data, sizeof(data), NULL)) { fprintf(stderr, "Error getting RTS: %s\n", strerror ( error )); exit(EXIT_FAILURE); } if (data & _LINESTATUS_SER_RTS) { printf("RTS is set.\n"); } else { printf("RTS isn't set.\n"); }