1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="Serial driver details"
23 HREF="io-serial-driver-details.html"><LINK
25 TITLE="Serial driver details"
26 HREF="io-serial-driver-details.html"><LINK
28 TITLE="How to Write a Driver"
29 HREF="io-how-to-write-a-driver.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="io-serial-driver-details.html"
65 >Chapter 16. Serial driver details</TD
71 HREF="io-how-to-write-a-driver.html"
85 NAME="IO-TTY-DRIVER">TTY driver</H1
87 >Use the include file <TT
89 ><cyg/io/ttyio.h></TT
93 >This driver is built on top of the simple
94 serial driver and is typically used for a device that interfaces with
95 humans such as a terminal. It provides some minimal formatting of data
96 on output and allows for line-oriented editing on input.</P
102 NAME="AEN10715">Runtime configuration</H2
104 >Runtime configuration is achieved by exchanging data structures with
105 the driver via the <TT
107 >cyg_io_set_config()</TT
111 >cyg_io_get_config()</TT
120 CLASS="PROGRAMLISTING"
122 cyg_uint32 tty_out_flags;
123 cyg_uint32 tty_in_flags;
124 } cyg_tty_info_t;</PRE
135 is used to control what happens to data as it is send to the serial
136 port. It contains a bitmap comprised of the bits as defined by the
139 >CYG_TTY_OUT_FLAGS_xxx</TT
148 CLASS="PROGRAMLISTING"
149 >#define CYG_TTY_OUT_FLAGS_CRLF 0x0001 // Map '\n' => '\n\r' on output</PRE
154 >If this bit is set in <TT
160 any occurrence of the character "\n" will
161 be replaced by the sequence "\n\r" before
162 being sent to the device.</P
170 is used to control how data is handled as it comes from the serial
171 port. It contains a bitmap comprised of the bits as defined by the
174 >CYG_TTY_IN_FLAGS_xxx</TT
183 CLASS="PROGRAMLISTING"
184 >#define CYG_TTY_IN_FLAGS_CR 0x0001 // Map '\r' => '\n' on input</PRE
189 >If this bit is set in <TT
195 character "\r" (“return” or “enter” on
196 most keyboards) will be mapped to "\n".</P
204 CLASS="PROGRAMLISTING"
205 >#define CYG_TTY_IN_FLAGS_CRLF 0x0002 // Map '\n\r' => '\n' on input</PRE
210 >If this bit is set in <TT
216 character sequence "\n\r" (often sent by DOS/Windows
217 based terminals) will be mapped to "\n". </P
225 CLASS="PROGRAMLISTING"
226 >#define CYG_TTY_IN_FLAGS_BINARY 0x0004 // No input processing</PRE
231 >If this bit is set in <TT
237 input will not be manipulated in any way before being placed in
238 the user’s buffer. </P
246 CLASS="PROGRAMLISTING"
247 >#define CYG_TTY_IN_FLAGS_ECHO 0x0008 // Echo characters as processed</PRE
252 >If this bit is set in <TT
258 will be echoed back to the serial port as they are processed. </P
265 NAME="AEN10742">API details</H2
273 CLASS="PROGRAMLISTING"
274 >cyg_io_read(handle, buf, len)</PRE
279 >This function is used to read data from the device. In the
280 default case, data is read until an end-of-line character ("\n"
281 or "\r") is read. Additionally, the characters are echoed
282 back to the [terminal] device. Minimal editing
283 of the input is also supported. </P
291 >When connecting to a remote target via GDB it is not possible
292 to provide console input while GDB is connected. The GDB remote
293 protocol does not support input. Users must disconnect from GDB
294 if this functionality is required.</P
304 CLASS="PROGRAMLISTING"
306 cyg_io_write(handle, buf, len)</PRE
311 >This function is used to send data to the device. In the default
312 case, the end-of-line character "\n" is replaced by the
321 CLASS="PROGRAMLISTING"
322 >cyg_io_get_config(handle, key, buf, len)</PRE
327 >This function is used to get information about the channel’s
328 configuration at runtime. </P
337 >CYG_IO_GET_CONFIG_TTY_INFO</TT
355 >This function retrieves the current state of the
365 >Serial driver keys (see above) may also be specified
366 in which case the call is passed directly to the serial
375 CLASS="PROGRAMLISTING"
376 >cyg_io_set_config(handle, key, buf, len)</PRE
381 >This function is used to modify the channel’s configuration
391 >CYG_IO_SET_CONFIG_TTY_INFO</TT
409 >This function changes the current state of the
419 keys (see above) may also be specified in which case the
420 call is passed directly to the serial driver. </P
428 SUMMARY="Footer navigation table"
439 HREF="io-serial-driver-details.html"
457 HREF="io-how-to-write-a-driver.html"
467 >Serial driver details</TD
473 HREF="io-serial-driver-details.html"
481 >How to Write a Driver</TD