termios.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. * 2021/12/10 linzhenxing put tty system
  10. */
  11. #ifndef __TERMIOS_H__
  12. #define __TERMIOS_H__
  13. #include <sys/types.h>
  14. #include <sys/ioctl.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. typedef unsigned char cc_t;
  19. typedef unsigned int speed_t;
  20. typedef unsigned int tcflag_t;
  21. #define NCCS 32
  22. struct termios {
  23. tcflag_t c_iflag;
  24. tcflag_t c_oflag;
  25. tcflag_t c_cflag;
  26. tcflag_t c_lflag;
  27. cc_t c_line;
  28. cc_t c_cc[NCCS];
  29. speed_t __c_ispeed;
  30. speed_t __c_ospeed;
  31. };
  32. /* c_cc characters */
  33. #define VINTR 0
  34. #define VQUIT 1
  35. #define VERASE 2
  36. #define VKILL 3
  37. #define VEOF 4
  38. #define VTIME 5
  39. #define VMIN 6
  40. #define VSWTC 7
  41. #define VSTART 8
  42. #define VSTOP 9
  43. #define VSUSP 10
  44. #define VEOL 11
  45. #define VREPRINT 12
  46. #define VDISCARD 13
  47. #define VWERASE 14
  48. #define VLNEXT 15
  49. #define VEOL2 16
  50. /* c_iflag bits */
  51. #define IGNBRK 0000001
  52. #define BRKINT 0000002
  53. #define IGNPAR 0000004
  54. #define PARMRK 0000010
  55. #define INPCK 0000020
  56. #define ISTRIP 0000040
  57. #define INLCR 0000100
  58. #define IGNCR 0000200
  59. #define ICRNL 0000400
  60. #define IUCLC 0001000
  61. #define IXON 0002000
  62. #define IXANY 0004000
  63. #define IXOFF 0010000
  64. #define IMAXBEL 0020000
  65. #define IUTF8 0040000
  66. /* c_oflag bits */
  67. #define OPOST 0000001
  68. #define ONLCR 0000002
  69. #define OLCUC 0000004
  70. #define OCRNL 0000010
  71. #define ONOCR 0000020
  72. #define ONLRET 0000040
  73. #define OFILL 00000100
  74. #define OFDEL 00000200
  75. #define NLDLY 00001400
  76. #define NL0 00000000
  77. #define NL1 00000400
  78. #define NL2 00001000
  79. #define NL3 00001400
  80. #define TABDLY 00006000
  81. #define TAB0 00000000
  82. #define TAB1 00002000
  83. #define TAB2 00004000
  84. #define TAB3 00006000
  85. #define CRDLY 00030000
  86. #define KCR0 00000000
  87. #define KCR1 00010000
  88. #define KCR2 00020000
  89. #define KCR3 00030000
  90. #define FFDLY 00040000
  91. #define FF0 00000000
  92. #define FF1 00040000
  93. #define BSDLY 00100000
  94. #define BS0 00000000
  95. #define BS1 00100000
  96. #define VTDLY 00200000
  97. #define VT0 00000000
  98. #define VT1 00200000
  99. #define XTABS 01000000
  100. #define B0 0000000
  101. #define B50 0000001
  102. #define B75 0000002
  103. #define B110 0000003
  104. #define B134 0000004
  105. #define B150 0000005
  106. #define B200 0000006
  107. #define B300 0000007
  108. #define B600 0000010
  109. #define B1200 0000011
  110. #define B1800 0000012
  111. #define B2400 0000013
  112. #define B4800 0000014
  113. #define B9600 0000015
  114. #define B19200 0000016
  115. #define B38400 0000017
  116. #define B57600 0010001
  117. #define B115200 0010002
  118. #define B230400 0010003
  119. #define B460800 0010004
  120. #define B500000 0010005
  121. #define B576000 0010006
  122. #define B921600 0010007
  123. #define B1000000 0010010
  124. #define B1152000 0010011
  125. #define B1500000 0010012
  126. #define B2000000 0010013
  127. #define B2500000 0010014
  128. #define B3000000 0010015
  129. #define B3500000 0010016
  130. #define B4000000 0010017
  131. #define CSIZE 0000060
  132. #define CS5 0000000
  133. #define CS6 0000020
  134. #define CS7 0000040
  135. #define CS8 0000060
  136. #define CSTOPB 0000100
  137. #define CREAD 0000200
  138. #define PARENB 0000400
  139. #define PARODD 0001000
  140. #define HUPCL 0002000
  141. #define CLOCAL 0004000
  142. /* c_lflag bits */
  143. #define ISIG 0000001
  144. #define ICANON 0000002
  145. #define XCASE 0000004
  146. #define ECHO 0000010
  147. #define ECHOE 0000020
  148. #define ECHOK 0000040
  149. #define ECHONL 0000100
  150. #define NOFLSH 0000200
  151. #define TOSTOP 0000400
  152. #define ECHOCTL 0001000
  153. #define ECHOPRT 0002000
  154. #define ECHOKE 0004000
  155. #define FLUSHO 0010000
  156. #define PENDIN 0040000
  157. #define IEXTEN 0100000
  158. #define EXTPROC 0200000
  159. #define TCOOFF 0
  160. #define TCOON 1
  161. #define TCIOFF 2
  162. #define TCION 3
  163. #define TCIFLUSH 0
  164. #define TCOFLUSH 1
  165. #define TCIOFLUSH 2
  166. #define TCSANOW 0
  167. #define TCSADRAIN 1
  168. #define TCSAFLUSH 2
  169. #define EXTA 0000016
  170. #define EXTB 0000017
  171. #define CBAUD 0010017
  172. #define CBAUDEX 0010000
  173. #define CIBAUD 002003600000
  174. #define CMSPAR 010000000000
  175. #define CRTSCTS 020000000000
  176. #define XCASE 0000004
  177. #define ECHOCTL 0001000
  178. #define ECHOPRT 0002000
  179. #define ECHOKE 0004000
  180. #define FLUSHO 0010000
  181. #define PENDIN 0040000
  182. #define EXTPROC 0200000
  183. /* intr=^C quit=^| erase=del kill=^U
  184. eof=^D vtime=\0 vmin=\1 sxtc=\0
  185. start=^Q stop=^S susp=^Z eol=\0
  186. reprint=^R discard=^U werase=^W lnext=^V
  187. eol2=\0
  188. */
  189. #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
  190. speed_t cfgetospeed (const struct termios *);
  191. speed_t cfgetispeed (const struct termios *);
  192. int cfsetospeed (struct termios *, speed_t);
  193. int cfsetispeed (struct termios *, speed_t);
  194. int tcgetattr (int, struct termios *);
  195. int tcsetattr (int, int, const struct termios *);
  196. int tcsendbreak (int, int);
  197. int tcdrain (int);
  198. int tcflush (int, int);
  199. int tcflow (int, int);
  200. pid_t tcgetsid (int);
  201. void cfmakeraw(struct termios *);
  202. int cfsetspeed(struct termios *, speed_t);
  203. #ifdef __cplusplus
  204. }
  205. #endif
  206. #endif