TizenRT Libs&Environment
v2.0 M2
Main Page
Modules
Data Structures
Files
File List
Globals
termios.h
Go to the documentation of this file.
1
/****************************************************************************
2
*
3
* Copyright 2016 Samsung Electronics All Rights Reserved.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing,
12
* software distributed under the License is distributed on an
13
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14
* either express or implied. See the License for the specific
15
* language governing permissions and limitations under the License.
16
*
17
****************************************************************************/
18
/****************************************************************************
19
* include/termios.h
20
*
21
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
22
* Author: Gregory Nutt <gnutt@nuttx.org>
23
*
24
* Redistribution and use in source and binary forms, with or without
25
* modification, are permitted provided that the following conditions
26
* are met:
27
*
28
* 1. Redistributions of source code must retain the above copyright
29
* notice, this list of conditions and the following disclaimer.
30
* 2. Redistributions in binary form must reproduce the above copyright
31
* notice, this list of conditions and the following disclaimer in
32
* the documentation and/or other materials provided with the
33
* distribution.
34
* 3. Neither the name NuttX nor the names of its contributors may be
35
* used to endorse or promote products derived from this software
36
* without specific prior written permission.
37
*
38
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49
* POSSIBILITY OF SUCH DAMAGE.
50
*
51
****************************************************************************/
58
#ifndef __INCLUDE_TERMIOS_H
61
#define __INCLUDE_TERMIOS_H
62
63
/****************************************************************************
64
* Included Files
65
****************************************************************************/
66
67
#include <tinyara/config.h>
68
#include <sys/types.h>
69
#include <stdint.h>
70
71
/****************************************************************************
72
* Pre-Processor Definitions
73
****************************************************************************/
74
75
/* Terminal input modes (c_iflag in the termios structure) */
76
77
#define BRKINT (1 << 0)
/* Bit 0: Signal interrupt on break */
78
#define ICRNL (1 << 1)
/* Bit 1: Map CR to NL on input */
79
#define IGNBRK (1 << 2)
/* Bit 2: Ignore break condition */
80
#define IGNCR (1 << 3)
/* Bit 3: Ignore CR */
81
#define IGNPAR (1 << 4)
/* Bit 4: Ignore characters with parity errors */
82
#define INLCR (1 << 5)
/* Bit 5: Map NL to CR on input */
83
#define INPCK (1 << 6)
/* Bit 6: Enable input parity check */
84
#define ISTRIP (1 << 7)
/* Bit 7: Strip character */
85
#define IUCLC (1 << 8)
/* Bit 8: Map upper-case to lower-case on input (LEGACY) */
86
#define IXANY (1 << 9)
/* Bit 9: Enable any character to restart output */
87
#define IXOFF (1 << 10)
/* Bit 10: Enable start/stop input control */
88
#define IXON (1 << 11)
/* Bit 11: Enable start/stop output control */
89
#define PARMRK (1 << 12)
/* Bit 12: Mark parity errors */
90
91
/* Terminal output modes (c_oflag in the termios structure) */
92
93
#define OPOST (1 << 0)
/* Bit 0: Post-process output */
94
#define OLCUC (1 << 1)
/* Bit 1: Map lower-case to upper-case on output (LEGACY) */
95
#define ONLCR (1 << 2)
/* Bit 2: Map NL to CR-NL on output */
96
#define OCRNL (1 << 3)
/* Bit 3: Map CR to NL on output */
97
#define ONOCR (1 << 4)
/* Bit 4: No CR output at column 0 */
98
#define ONLRET (1 << 5)
/* Bit 5: NL performs CR function */
99
#define OFILL (1 << 6)
/* Bit 6: Use fill characters for delay */
100
#define NLDLY (1 << 7)
/* Bit 7: Select newline delays: */
101
#define NL0 (0 << 7)
/* Newline character type 0 */
102
#define NL1 (1 << 7)
/* Newline character type 1 */
103
#define CRDLY (3 << 8)
/* Bits 8-9: Select carriage-return delays: */
104
#define CR0 (0 << 8)
/* Carriage-return delay type 0 */
105
#define CR1 (1 << 8)
/* Carriage-return delay type 1 */
106
#define CR2 (2 << 8)
/* Carriage-return delay type 2 */
107
#define CR3 (3 << 8)
/* Carriage-return delay type 3 */
108
#define TABDLY (3 << 10)
/* Bit 10-11: Select horizontal-tab delays: */
109
#define TAB0 (0 << 10)
/* Horizontal-tab delay type 0 */
110
#define TAB1 (1 << 10)
/* Horizontal-tab delay type 1 */
111
#define TAB2 (2 << 10)
/* Horizontal-tab delay type 2 */
112
#define TAB3 (3 << 10)
/* Expand tabs to spaces */
113
#define BSDLY (1 << 12)
/* Bit 12: Select backspace delays: */
114
#define BS0 (0 << 12)
/* Backspace-delay type 0 */
115
#define BS1 (1 << 12)
/* Backspace-delay type 1 */
116
#define VTDLY (1 << 13)
/* Bit 13: Select vertical-tab delays: */
117
#define VT0 (0 << 13)
/* Vertical-tab delay type 0 */
118
#define VT1 (1 << 13)
/* Vertical-tab delay type 1 */
119
#define FFDLY (1 << 14)
/* Bit 14: Select form-feed delays: */
120
#define FF0 (0 << 14)
/* Form-feed delay type 0 */
121
#define FF1 (1 << 14)
/* Form-feed delay type 1 */
122
123
/* Control Modes (c_cflag in the termios structure) */
124
125
#define CSIZE (3 << 0)
/* Bits 0-1: Character size: */
126
#define CS5 (0 << 0)
/* 5 bits */
127
#define CS6 (1 << 0)
/* 6 bits */
128
#define CS7 (2 << 0)
/* 7 bits */
129
#define CS8 (3 << 0)
/* 8 bits */
130
#define CSTOPB (1 << 2)
/* Bit 2: Send two stop bits, else one */
131
#define CREAD (1 << 3)
/* Bit 3: Enable receiver */
132
#define PARENB (1 << 4)
/* Bit 4: Parity enable */
133
#define PARODD (1 << 5)
/* Bit 5: Odd parity, else even */
134
#define HUPCL (1 << 6)
/* Bit 6: Hang up on last close */
135
#define CLOCAL (1 << 7)
/* Bit 7: Ignore modem status lines */
136
#define CCTS_OFLOW (1 << 8)
/* Bit 8: CTS flow control of output */
137
#define CRTSCTS CCTS_OFLOW
138
#define CRTS_IFLOW (1 << 9)
/* Bit 9: RTS flow control of input */
139
140
/* Local Modes (c_lflag in the termios structure) */
141
142
#define ECHO (1 << 0)
/* Bit 0: Enable echo */
143
#define ECHOE (1 << 1)
/* Bit 1: Echo erase character as error-correcting backspace */
144
#define ECHOK (1 << 2)
/* Bit 2: Echo KILL */
145
#define ECHONL (1 << 3)
/* Bit 3: Echo NL */
146
#define ICANON (1 << 4)
/* Bit 4: Canonical input (erase and kill processing) */
147
#define IEXTEN (1 << 5)
/* Bit 5: Enable extended input character processing */
148
#define ISIG (1 << 6)
/* Bit 6: Enable signals */
149
#define NOFLSH (1 << 7)
/* Bit 7: Disable flush after interrupt or quit */
150
#define TOSTOP (1 << 8)
/* Bit 8: Send SIGTTOU for background output */
151
#define XCASE (1 << 9)
/* Bit 9: Canonical upper/lower presentation (LEGACY) */
152
153
/* The following are subscript names for the termios c_cc array */
154
155
#define VEOF 0
/* Bit 0: EOF character (canonical mode) */
156
#define VMIN VEOF
/* Bit 0: MIN value (Non-canonical mode) */
157
#define VEOL 1
/* Bit 1: EOL character (canonical mode) */
158
#define VTIME VEOL
/* Bit 1: TIME value (Non-canonical mode) */
159
#define VERASE 2
/* Bit 2: ERASE character (canonical mode) */
160
#define VINTR 3
/* Bit 3: INTR character */
161
#define VKILL 4
/* Bit 4: KILL character (canonical mode) */
162
#define VQUIT 5
/* Bit 5: QUIT character */
163
#define VSTART 6
/* Bit 6: START character */
164
#define VSTOP 7
/* Bit 7: STOP character */
165
#define VSUSP 8
/* Bit 8: SUSP character */
166
#define NCCS 9
/* Bit 9: Size of the array c_cc for control characters */
167
168
/* Baud Rate Selection. These are instances of type speed_t. Values of 38400
169
* and below are specified by POSIX; values above 38400 are sometimes referred
170
* to as extended values and most values appear in most termios.h implementations.
171
*
172
* NOTE that is TinyAra that the encoding of the speed_t values is simply the
173
* value of the baud itself. So this opens a window for non-portable abuse
174
* of the speed-related interfaces: The defined values should be used where-
175
* ever possible for reasons of portability.
176
*/
177
178
#define B0 0
/* Hang up */
179
#define B50 50
/* 50 baud */
180
#define B75 75
/* 75 baud */
181
#define B110 110
/* 110 baud */
182
#define B134 134
/* 134.5 baud */
183
#define B150 150
/* 150 baud */
184
#define B200 200
/* 200 baud */
185
#define B300 300
/* 300 baud */
186
#define B600 600
/* 600 baud */
187
#define B1200 1200
/* 1,200 baud */
188
#define B1800 1800
/* 1,800 baud */
189
#define B2400 2400
/* 2,400 baud */
190
#define B4800 4800
/* 4,800 baud */
191
#define B9600 9600
/* 9,600 baud */
192
#define B19200 19200
/* 19,200 baud */
193
#define B38400 38400
/* 38,400 baud */
194
195
#define B57600 57600
/* 57,600 baud */
196
#define B115200 115200
/* 115,200 baud */
197
#define B128000 128000
/* 128,000 baud */
198
#define B230400 230400
/* 230,400 baud */
199
#define B256000 256000
/* 256,000 baud */
200
#define B460800 460800
/* 460,800 baud */
201
#define B500000 500000
/* 500,000 baud */
202
#define B576000 576000
/* 576,000 baud */
203
#define B921600 921600
/* 921,600 baud */
204
#define B1000000 1000000
/* 1,000,000 baud */
205
#define B1152000 1152000
/* 1,152,000 baud */
206
#define B1500000 1500000
/* 1,500,000 baud */
207
#define B2000000 2000000
/* 2,000,000 baud */
208
#define B2500000 2500000
/* 2,500,000 baud */
209
#define B3000000 3000000
/* 3,000,000 baud */
210
211
/* Attribute Selection (used with tcsetattr()) */
212
213
#define TCSANOW 0
/* Change attributes immediately */
214
#define TCSADRAIN 1
/* Change attributes when output has drained */
215
#define TCSAFLUSH 2
/* Change attributes when output has drained; also flush pending input */
216
217
/* Line Control (used with tcflush()) */
218
219
#define TCIFLUSH 0
/* Flush pending input. Flush untransmitted output */
220
#define TCIOFLUSH 1
/* Flush both pending input and untransmitted output */
221
#define TCOFLUSH 2
/* Flush untransmitted output */
222
223
/* Constants for use with tcflow() */
224
225
#define TCIOFF 0
/* Transmit a STOP character, intended to suspend input data */
226
#define TCION 1
/* Transmit a START character, intended to restart input data */
227
#define TCOOFF 2
/* Suspend output */
228
#define TCOON 3
/* Restart output */
229
230
/****************************************************************************
231
* Public Type Definitions
232
****************************************************************************/
233
234
/* Baud rate selection */
235
236
typedef
uint32_t
speed_t
;
/* Used for terminal baud rates */
237
238
/* Types used within the termios structure */
239
240
typedef
uint16_t
tcflag_t
;
/* Used for terminal modes */
241
typedef
int
cc_t
;
/* Used for terminal special characters */
242
243
/* The termios structure */
244
249
struct
termios
{
250
/* Exposed fields defined by POSIX */
251
252
tcflag_t
c_iflag
;
/* Input modes */
253
tcflag_t
c_oflag
;
/* Output modes */
254
tcflag_t
c_cflag
;
/* Control modes */
255
tcflag_t
c_lflag
;
/* Local modes */
256
cc_t
c_cc
[
NCCS
];
/* Control chars */
257
258
/* Implementation specific fields. For portability reasons, these fields
259
* should not be accessed directly, but rather through only through the
260
* cf[set|get][o|i]speed() POSIX interfaces.
261
*/
262
263
speed_t
c_speed
;
/* Input/output speed (non-POSIX) */
264
};
265
266
/****************************************************************************
267
* Public Function Prototypes
268
****************************************************************************/
269
270
#ifdef __cplusplus
271
#define EXTERN extern "C"
272
extern
"C"
{
273
#else
274
#define EXTERN extern
275
#endif
276
277
/* The cfgetspeed() function is a non-POSIX function will extract the baud
278
* from the termios structure to which the termiosp argument points. TinyAra
279
* does not control input/output baud independently. Both must be the same.
280
* The POSIX standard interfaces, cfigetispeed() and cfigetospeed() are
281
* supported by simply defining them to be cfgetspeed().
282
*/
283
288
speed_t
cfgetspeed(FAR
const
struct
termios
*termiosp);
289
#define cfgetispeed(termiosp) cfgetspeed(termiosp)
290
#define cfgetospeed(termiosp) cfgetspeed(termiosp)
291
292
/* The cfsetspeed() function is a non-POSIX function that sets the baud
293
* stored in the structure pointed to by termiosp to speed. TinyAra does
294
* not control input/output baud independently. Both must be the same.
295
* The POSIX standard interfaces, cfigetispeed() and cfigetospeed() are
296
* supported by simply defining them to be cfsetspeed().
297
*/
301
int
cfsetspeed(FAR
struct
termios
*termiosp,
speed_t
speed);
302
#define cfsetispeed(termiosp, speed) cfsetspeed(termiosp, speed)
303
#define cfsetospeed(termiosp, speed) cfsetspeed(termiosp, speed)
304
305
/* Wait for transmission of output */
309
int
tcdrain(
int
fd);
310
311
/* Suspend or restart the transmission or reception of data */
315
int
tcflow(
int
fd,
int
action);
316
317
/* Flush non-transmitted output data, non-read input data or both */
321
int
tcflush(
int
fd,
int
cmd);
325
/* Get the parameters associated with the terminal */
333
int
tcgetattr
(
int
fd, FAR
struct
termios
*termiosp);
334
335
/* Get process group ID for session leader for controlling terminal */
340
pid_t tcgetsid(
int
fd);
341
342
/* Send a "break" for a specific duration */
346
int
tcsendbreak(
int
fd,
int
duration);
351
/* Set the parameters associated with the terminal */
359
int
tcsetattr
(
int
fd,
int
options, FAR
const
struct
termios
*termiosp);
360
361
/* Check if a file descriptor corresponds to a terminal I/O file */
362
367
int
isatty(
int
fd);
372
#undef EXTERN
373
#ifdef __cplusplus
374
}
375
#endif
376
377
#endif
/* __INCLUDE_TERMIOS_H */
termios
Structure of termios.
Definition:
termios.h:249
termios::c_iflag
tcflag_t c_iflag
Definition:
termios.h:252
tcgetattr
int tcgetattr(int fd, FAR struct termios *termiosp)
get the parameters associated with the terminal
tcsetattr
int tcsetattr(int fd, int options, FAR const struct termios *termiosp)
set the parameters associated with the terminal
termios::c_lflag
tcflag_t c_lflag
Definition:
termios.h:255
tcflag_t
uint16_t tcflag_t
Definition:
termios.h:240
termios::c_speed
speed_t c_speed
Definition:
termios.h:263
cc_t
int cc_t
Definition:
termios.h:241
NCCS
#define NCCS
Definition:
termios.h:166
termios::c_cflag
tcflag_t c_cflag
Definition:
termios.h:254
speed_t
uint32_t speed_t
Definition:
termios.h:236
termios::c_oflag
tcflag_t c_oflag
Definition:
termios.h:253
termios::c_cc
cc_t c_cc[NCCS]
Definition:
termios.h:256
os
include
termios.h
Generated by
1.8.11