termios.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2017/08/30 Bernard The first version
  9. */
  10. #ifndef __TERMIOS_H__
  11. #define __TERMIOS_H__
  12. #include <sys/types.h>
  13. #include <sys/ioctl.h>
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. typedef unsigned char cc_t;
  18. typedef unsigned int speed_t;
  19. typedef unsigned int tcflag_t;
  20. #define NCCS 32
  21. struct termios {
  22. tcflag_t c_iflag;
  23. tcflag_t c_oflag;
  24. tcflag_t c_cflag;
  25. tcflag_t c_lflag;
  26. cc_t c_line;
  27. cc_t c_cc[NCCS];
  28. speed_t __c_ispeed;
  29. speed_t __c_ospeed;
  30. };
  31. #define VINTR 0
  32. #define VQUIT 1
  33. #define VERASE 2
  34. #define VKILL 3
  35. #define VEOF 4
  36. #define VTIME 5
  37. #define VMIN 6
  38. #define VSWTC 7
  39. #define VSTART 8
  40. #define VSTOP 9
  41. #define VSUSP 10
  42. #define VEOL 11
  43. #define VREPRINT 12
  44. #define VDISCARD 13
  45. #define VWERASE 14
  46. #define VLNEXT 15
  47. #define VEOL2 16
  48. #define IGNBRK 0000001
  49. #define BRKINT 0000002
  50. #define IGNPAR 0000004
  51. #define PARMRK 0000010
  52. #define INPCK 0000020
  53. #define ISTRIP 0000040
  54. #define INLCR 0000100
  55. #define IGNCR 0000200
  56. #define ICRNL 0000400
  57. #define IUCLC 0001000
  58. #define IXON 0002000
  59. #define IXANY 0004000
  60. #define IXOFF 0010000
  61. #define IMAXBEL 0020000
  62. #define IUTF8 0040000
  63. #define OPOST 0000001
  64. #define OLCUC 0000002
  65. #define ONLCR 0000004
  66. #define OCRNL 0000010
  67. #define ONOCR 0000020
  68. #define ONLRET 0000040
  69. #define OFILL 0000100
  70. #define OFDEL 0000200
  71. #define NLDLY 0000400
  72. #define NL0 0000000
  73. #define NL1 0000400
  74. #define CRDLY 0003000
  75. #define CR0 0000000
  76. #define CR1 0001000
  77. #define CR2 0002000
  78. #define CR3 0003000
  79. #define TABDLY 0014000
  80. #define TAB0 0000000
  81. #define TAB1 0004000
  82. #define TAB2 0010000
  83. #define TAB3 0014000
  84. #define BSDLY 0020000
  85. #define BS0 0000000
  86. #define BS1 0020000
  87. #define FFDLY 0100000
  88. #define FF0 0000000
  89. #define FF1 0100000
  90. #define VTDLY 0040000
  91. #define VT0 0000000
  92. #define VT1 0040000
  93. #define B0 0000000
  94. #define B50 0000001
  95. #define B75 0000002
  96. #define B110 0000003
  97. #define B134 0000004
  98. #define B150 0000005
  99. #define B200 0000006
  100. #define B300 0000007
  101. #define B600 0000010
  102. #define B1200 0000011
  103. #define B1800 0000012
  104. #define B2400 0000013
  105. #define B4800 0000014
  106. #define B9600 0000015
  107. #define B19200 0000016
  108. #define B38400 0000017
  109. #define B57600 0010001
  110. #define B115200 0010002
  111. #define B230400 0010003
  112. #define B460800 0010004
  113. #define B500000 0010005
  114. #define B576000 0010006
  115. #define B921600 0010007
  116. #define B1000000 0010010
  117. #define B1152000 0010011
  118. #define B1500000 0010012
  119. #define B2000000 0010013
  120. #define B2500000 0010014
  121. #define B3000000 0010015
  122. #define B3500000 0010016
  123. #define B4000000 0010017
  124. #define CSIZE 0000060
  125. #define CS5 0000000
  126. #define CS6 0000020
  127. #define CS7 0000040
  128. #define CS8 0000060
  129. #define CSTOPB 0000100
  130. #define CREAD 0000200
  131. #define PARENB 0000400
  132. #define PARODD 0001000
  133. #define HUPCL 0002000
  134. #define CLOCAL 0004000
  135. #define ISIG 0000001
  136. #define ICANON 0000002
  137. #define ECHO 0000010
  138. #define ECHOE 0000020
  139. #define ECHOK 0000040
  140. #define ECHONL 0000100
  141. #define NOFLSH 0000200
  142. #define TOSTOP 0000400
  143. #define IEXTEN 0100000
  144. #define TCOOFF 0
  145. #define TCOON 1
  146. #define TCIOFF 2
  147. #define TCION 3
  148. #define TCIFLUSH 0
  149. #define TCOFLUSH 1
  150. #define TCIOFLUSH 2
  151. #define TCSANOW 0
  152. #define TCSADRAIN 1
  153. #define TCSAFLUSH 2
  154. #define EXTA 0000016
  155. #define EXTB 0000017
  156. #define CBAUD 0010017
  157. #define CBAUDEX 0010000
  158. #define CIBAUD 002003600000
  159. #define CMSPAR 010000000000
  160. #define CRTSCTS 020000000000
  161. #define XCASE 0000004
  162. #define ECHOCTL 0001000
  163. #define ECHOPRT 0002000
  164. #define ECHOKE 0004000
  165. #define FLUSHO 0010000
  166. #define PENDIN 0040000
  167. #define EXTPROC 0200000
  168. #define XTABS 0014000
  169. speed_t cfgetospeed (const struct termios *);
  170. speed_t cfgetispeed (const struct termios *);
  171. int cfsetospeed (struct termios *, speed_t);
  172. int cfsetispeed (struct termios *, speed_t);
  173. int tcgetattr (int, struct termios *);
  174. int tcsetattr (int, int, const struct termios *);
  175. int tcsendbreak (int, int);
  176. int tcdrain (int);
  177. int tcflush (int, int);
  178. int tcflow (int, int);
  179. pid_t tcgetsid (int);
  180. void cfmakeraw(struct termios *);
  181. int cfsetspeed(struct termios *, speed_t);
  182. #ifdef __cplusplus
  183. }
  184. #endif
  185. #endif