posix_termios.h 4.3 KB

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