zephyr/samples/subsys/console/getchar
Sebastian Bøe 55ee53ce91 cmake: Prepend 'cmake_minimum_required()' into 'app' build scripts
Prepend the text 'cmake_minimum_required(VERSION 3.8.2)' into the
application and test build scripts.

Modern versions of CMake will spam users with a deprecation warning
when the toplevel CMakeLists.txt does not specify a CMake
version. This is documented in bug #8355.

To resolve this we include a cmake_minimum_required() line into the
toplevel build scripts. Additionally, cmake_minimum_required is
invoked from within boilerplate.cmake. The highest version will be
enforced.

This patch allows us to afterwards change CMake policy CMP000 from OLD
to NEW which in turn finally rids us of the verbose warning.

The extra boilerplate is considered more acceptable than the verbosity
of the CMP0000 policy.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-08-15 04:06:50 -07:00
..
src samples: console: add print statements for user 2018-07-13 08:48:40 -04:00
CMakeLists.txt cmake: Prepend 'cmake_minimum_required()' into 'app' build scripts 2018-08-15 04:06:50 -07:00
README.rst
prj.conf subsys: console: Factor out fifo-based console input abstraction 2018-06-20 15:59:12 -04:00
sample.yaml

README.rst

.. _console_getchar_sample:

console_getchar() Sample Application
####################################

Overview
********

This example shows how to use :cpp:func:`console_getchar()` function.
Similar to the well-known ANSI C getchar() function,
:cpp:func:`console_getchar()` either returns the next available input
character or blocks waiting for one. Using this function, it should be
fairly easy to port existing ANSI C, POSIX, or Linux applications which
process console input character by character. The sample also allows to
see key/character codes as returned by the function.

If you are interested in line by line console input, see
:ref:`console_getline_sample`.


Requirements
************

UART console is required to run this simple.


Building and Running
********************

The easiest way to run this sample is using QEMU:

.. zephyr-app-commands::
   :zephyr-app: samples/subsys/console/getchar
   :host-os: unix
   :board: qemu_x86
   :goals: run
   :compact:

Now start pressing keys on a keyboard, and they will be printed both as
hex values and in character form. Be sure to press Enter, Up/Down, etc.
key to check what control characters are produced for them.