posix_termios.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * File : termios.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2017, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2017/08/30 Bernard The first version
  23. */
  24. #ifndef TERMIOS_H__
  25. #define TERMIOS_H__
  26. #include <rtthread.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. typedef unsigned char cc_t;
  31. typedef unsigned int speed_t;
  32. typedef unsigned int tcflag_t;
  33. #define NCCS 32
  34. struct termios {
  35. tcflag_t c_iflag;
  36. tcflag_t c_oflag;
  37. tcflag_t c_cflag;
  38. tcflag_t c_lflag;
  39. cc_t c_line;
  40. cc_t c_cc[NCCS];
  41. speed_t __c_ispeed;
  42. speed_t __c_ospeed;
  43. };
  44. #define VINTR 0
  45. #define VQUIT 1
  46. #define VERASE 2
  47. #define VKILL 3
  48. #define VEOF 4
  49. #define VTIME 5
  50. #define VMIN 6
  51. #define VSWTC 7
  52. #define VSTART 8
  53. #define VSTOP 9
  54. #define VSUSP 10
  55. #define VEOL 11
  56. #define VREPRINT 12
  57. #define VDISCARD 13
  58. #define VWERASE 14
  59. #define VLNEXT 15
  60. #define VEOL2 16
  61. #define IGNBRK 0000001
  62. #define BRKINT 0000002
  63. #define IGNPAR 0000004
  64. #define PARMRK 0000010
  65. #define INPCK 0000020
  66. #define ISTRIP 0000040
  67. #define INLCR 0000100
  68. #define IGNCR 0000200
  69. #define ICRNL 0000400
  70. #define IUCLC 0001000
  71. #define IXON 0002000
  72. #define IXANY 0004000
  73. #define IXOFF 0010000
  74. #define IMAXBEL 0020000
  75. #define IUTF8 0040000
  76. #define OPOST 0000001
  77. #define OLCUC 0000002
  78. #define ONLCR 0000004
  79. #define OCRNL 0000010
  80. #define ONOCR 0000020
  81. #define ONLRET 0000040
  82. #define OFILL 0000100
  83. #define OFDEL 0000200
  84. #define NLDLY 0000400
  85. #define NL0 0000000
  86. #define NL1 0000400
  87. #define CRDLY 0003000
  88. #define CR0 0000000
  89. #define CR1 0001000
  90. #define CR2 0002000
  91. #define CR3 0003000
  92. #define TABDLY 0014000
  93. #define TAB0 0000000
  94. #define TAB1 0004000
  95. #define TAB2 0010000
  96. #define TAB3 0014000
  97. #define BSDLY 0020000
  98. #define BS0 0000000
  99. #define BS1 0020000
  100. #define FFDLY 0100000
  101. #define FF0 0000000
  102. #define FF1 0100000
  103. #define VTDLY 0040000
  104. #define VT0 0000000
  105. #define VT1 0040000
  106. #define B0 0000000
  107. #define B50 0000001
  108. #define B75 0000002
  109. #define B110 0000003
  110. #define B134 0000004
  111. #define B150 0000005
  112. #define B200 0000006
  113. #define B300 0000007
  114. #define B600 0000010
  115. #define B1200 0000011
  116. #define B1800 0000012
  117. #define B2400 0000013
  118. #define B4800 0000014
  119. #define B9600 0000015
  120. #define B19200 0000016
  121. #define B38400 0000017
  122. #define B57600 0010001
  123. #define B115200 0010002
  124. #define B230400 0010003
  125. #define B460800 0010004
  126. #define B500000 0010005
  127. #define B576000 0010006
  128. #define B921600 0010007
  129. #define B1000000 0010010
  130. #define B1152000 0010011
  131. #define B1500000 0010012
  132. #define B2000000 0010013
  133. #define B2500000 0010014
  134. #define B3000000 0010015
  135. #define B3500000 0010016
  136. #define B4000000 0010017
  137. #define CSIZE 0000060
  138. #define CS5 0000000
  139. #define CS6 0000020
  140. #define CS7 0000040
  141. #define CS8 0000060
  142. #define CSTOPB 0000100
  143. #define CREAD 0000200
  144. #define PARENB 0000400
  145. #define PARODD 0001000
  146. #define HUPCL 0002000
  147. #define CLOCAL 0004000
  148. #define ISIG 0000001
  149. #define ICANON 0000002
  150. #define ECHO 0000010
  151. #define ECHOE 0000020
  152. #define ECHOK 0000040
  153. #define ECHONL 0000100
  154. #define NOFLSH 0000200
  155. #define TOSTOP 0000400
  156. #define IEXTEN 0100000
  157. #define TCOOFF 0
  158. #define TCOON 1
  159. #define TCIOFF 2
  160. #define TCION 3
  161. #define TCIFLUSH 0
  162. #define TCOFLUSH 1
  163. #define TCIOFLUSH 2
  164. #define TCSANOW 0
  165. #define TCSADRAIN 1
  166. #define TCSAFLUSH 2
  167. #define EXTA 0000016
  168. #define EXTB 0000017
  169. #define CBAUD 0010017
  170. #define CBAUDEX 0010000
  171. #define CIBAUD 002003600000
  172. #define CMSPAR 010000000000
  173. #define CRTSCTS 020000000000
  174. #define XCASE 0000004
  175. #define ECHOCTL 0001000
  176. #define ECHOPRT 0002000
  177. #define ECHOKE 0004000
  178. #define FLUSHO 0010000
  179. #define PENDIN 0040000
  180. #define EXTPROC 0200000
  181. #define XTABS 0014000
  182. speed_t cfgetospeed (const struct termios *);
  183. speed_t cfgetispeed (const struct termios *);
  184. int cfsetospeed (struct termios *, speed_t);
  185. int cfsetispeed (struct termios *, speed_t);
  186. int tcgetattr (int, struct termios *);
  187. int tcsetattr (int, int, const struct termios *);
  188. int tcsendbreak (int, int);
  189. int tcdrain (int);
  190. int tcflush (int, int);
  191. int tcflow (int, int);
  192. pid_t tcgetsid (int);
  193. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  194. void cfmakeraw(struct termios *);
  195. int cfsetspeed(struct termios *, speed_t);
  196. #endif
  197. #ifdef __cplusplus
  198. }
  199. #endif
  200. #endif