MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / tcsetattr

Function tcsetattr

components/libc/posix/io/termios/termios.c:57–80  ·  view source on GitHub ↗

* @brief Sets the attributes of a terminal device. * @param fd File descriptor of the terminal device. * @param act Action to be taken for the attribute change (TCSANOW, TCSADRAIN, or TCSAFLUSH). * @param tio Pointer to a struct termios containing the new attributes. * @return Upon successful completion, returns 0; otherwise, returns -1 and sets errno to indicate the error. * * @not

Source from the content-addressed store, hash-verified

55 * and the function returns -1.
56 */
57int tcsetattr(int fd, int act, const struct termios *tio)
58{
59 switch (act)
60 {
61 case TCSANOW:
62 /* make the change immediately */
63 return (ioctl(fd, TCSETA, (void*)tio));
64 case TCSADRAIN:
65 /*
66 * Don't make the change until all currently written data
67 * has been transmitted.
68 */
69 return (ioctl(fd, TCSETAW, (void*)tio));
70 case TCSAFLUSH:
71 /* Don't make the change until all currently written data
72 * has been transmitted, at which point any received but
73 * unread data is also discarded.
74 */
75 return (ioctl(fd, TCSETAF, (void*)tio));
76 default:
77 errno = EINVAL;
78 return (-1);
79 }
80}
81
82/**
83 * @brief Gets the session ID of a terminal.

Callers 5

configureSerialFunction · 0.85
configureSerialFunction · 0.85
set_sttyFunction · 0.85
restore_sttyFunction · 0.85
config_commFunction · 0.85

Calls 1

ioctlFunction · 0.50

Tested by 1

config_commFunction · 0.68