README.rst
1.. zephyr:code-sample:: console_getline
2 :name: console_getline()
3
4 Use console_getline() to read an input line from the console.
5
6Overview
7********
8
9This example shows how to use :c:func:`console_getline` function.
10Similar to the well-known ANSI C gets() and fgets() functions,
11:c:func:`console_getline` either returns the next available input
12line or blocks waiting for one. Using this function, it should be fairly
13easy to port existing ANSI C, POSIX, or Linux applications which process
14console input line by line. The sample also allows to see details of how
15a line is returned by the function.
16
17If you are interested in character by character console input, see
18:zephyr:code-sample:`console_getchar`.
19
20
21Requirements
22************
23
24UART console is required to run this sample.
25
26
27Building and Running
28********************
29
30The easiest way to run this sample is using QEMU:
31
32.. zephyr-app-commands::
33 :zephyr-app: samples/subsys/console/getline
34 :host-os: unix
35 :board: qemu_x86
36 :goals: run
37 :compact:
38
39Now start pressing keys on a keyboard, followed by Enter. The input line
40will be printed back, with a hex code of the last character, to show that
41line does not include any special "end of line" characters (like LF, CR,
42etc.)
43Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
44