Commit graph

14 commits

Author SHA1 Message Date
Carles Cufi 8e297e87b3 console: Port to the new timeout API
Port the code so that it uses the new timeout API.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-05-07 11:01:55 +02:00
Andy Ross 7832738ae9 kernel/timeout: Make timeout arguments an opaque type
Add a k_timeout_t type, and use it everywhere that kernel API
functions were accepting a millisecond timeout argument.  Instead of
forcing milliseconds everywhere (which are often not integrally
representable as system ticks), do the conversion to ticks at the
point where the timeout is created.  This avoids an extra unit
conversion in some application code, and allows us to express the
timeout in units other than milliseconds to achieve greater precision.

The existing K_MSEC() et. al. macros now return initializers for a
k_timeout_t.

The K_NO_WAIT and K_FOREVER constants have now become k_timeout_t
values, which means they cannot be operated on as integers.
Applications which have their own APIs that need to inspect these
vs. user-provided timeouts can now use a K_TIMEOUT_EQ() predicate to
test for equality.

Timer drivers, which receive an integer tick count in ther
z_clock_set_timeout() functions, now use the integer-valued
K_TICKS_FOREVER constant instead of K_FOREVER.

For the initial release, to preserve source compatibility, a
CONFIG_LEGACY_TIMEOUT_API kconfig is provided.  When true, the
k_timeout_t will remain a compatible 32 bit value that will work with
any legacy Zephyr application.

Some subsystems present timeout (or timeout-like) values to their own
users as APIs that would re-use the kernel's own constants and
conventions.  These will require some minor design work to adapt to
the new scheme (in most cases just using k_timeout_t directly in their
own API), and they have not been changed in this patch, instead
selecting CONFIG_LEGACY_TIMEOUT_API via kconfig.  These subsystems
include: CAN Bus, the Microbit display driver, I2S, LoRa modem
drivers, the UART Async API, Video hardware drivers, the console
subsystem, and the network buffer abstraction.

k_sleep() now takes a k_timeout_t argument, with a k_msleep() variant
provided that works identically to the original API.

Most of the changes here are just type/configuration management and
documentation, but there are logic changes in mempool, where a loop
that used a timeout numerically has been reworked using a new
z_timeout_end_calc() predicate.  Also in queue.c, a (when POLL was
enabled) a similar loop was needlessly used to try to retry the
k_poll() call after a spurious failure.  But k_poll() does not fail
spuriously, so the loop was removed.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Ulf Magnusson 8d8d9904cd console: Have CONSOLE_GET{CHAR,LINE} dep. on SERIAL_SUPPORT_INTERRUPT
Overlooked dependency in commit 97de99adca ("console: kconfig: Have
CONSOLE_{GETCHAR,GETLINE} depend on UART_CONSOLE"). CONSOLE_GETCHAR and
CONSOLE_GETLINE select CONSOLE_HANDLER, which selects
UART_INTERRUPT_DRIVEN, which depends on SERIAL_SUPPORT_INTERRUPT.

Fixed some selects with unsatisfied dependencies in CI.

(CONSOLE_HANDLER also depends on SERIAL, but it's redundant, since it
already depends on UART_CONSOLE, which depends on SERIAL. This is
simplified in https://github.com/zephyrproject-rtos/zephyr/pull/22116.)

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-28 12:56:50 -06:00
Ulf Magnusson 97de99adca console: kconfig: Have CONSOLE_{GETCHAR,GETLINE} depend on UART_CONSOLE
CONSOLE_GETCHAR and CONSOLE_GETLINE select CONSOLE_HANDLER and
UART_CONSOLE_DEBUG_SERVER_HOOKS, which depend on UART_CONSOLE, but
UART_CONSOLE is n for some boards, giving a select with unsatisfied
dependencies and a warning. Triggers in CI.

Looking at the code, CONSOLE_{GETCHAR,GETLINE} also depend on
UART_CONSOLE there. Add a 'depends on UART_CONSOLE' to the 'choice' that
contains them.

Maybe the samples/subsys/console/{echo,getchar}/ samples shouldn't be
run on some boards that they're currently run on, but there's still the
issue that CONSOLE_{GETCHAR,GETLINE} shouldn't be shown in menuconfig
when they don't apply.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-01-22 22:47:02 -05:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Ulf Magnusson 48edfc2203 console: kconfig: Put 'menuconfig CONSOLE_SUBSYS' in top-level menu
The 'Console' menu contains just 'config CONSOLE_SUBSYS' and its
indented children.

Remove one menu level by removing the 'Console' menu and turning
CONSOLE_SUBSYS into a 'menuconfig' symbol.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-05-15 05:10:01 -05:00
Paul Sokolovsky 2ffb951630 console: Kconfig: Update for recent changes
Buffer sizes aren't required to be power of 2 for a while. Describe
that by setting buffers sizes to 0, one can get non interrupt driven
operation.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-12-20 12:21:49 +01:00
Paul Sokolovsky 78d2476348 subsys: console: Mark as EXPERIMENTAL.
This subsys is in the process of collecting requirements/usecases,
the API is subject to change. (Should have been marked experimental
from the beginning.)

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-08-14 11:56:42 -07:00
Ulf Magnusson 1073882998 subsys: kconfig: Remove 'default n' properties and clean up a bit
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.

Remove some 'default ""' properties on string symbols too.

Also make definitions more consistent by converting some

  config FOO
  	<type>
  	prompt "foo"

definitions to a shorter form:

  config FOO
  	<type> "foo"

This shorthand works for int/hex/string symbols too, not just for bool
symbols.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-12 23:13:22 -04:00
Paul Sokolovsky 5acb7fc9a9 subsys: console: Make CONSOLE_GETCHAR and *_GETLINE optional
It should be possible to make both these options off, and that
should be default, otherwise targets not supporting them yet, e.g.
native_posix, have build issues.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-06-20 15:59:12 -04:00
Paul Sokolovsky f6d8ab8289 subsys: console: Factor out fifo-based console input abstraction
Console subsystem is intended to be a layer between console drivers
and console clients, like e.g. shell. This change factors out code
from shell which dealed with individial console drivers and moves it
to console subsystem, under the name console_register_line_input().

To accommodate for this change, older console subsys Kconfig symbol
is changed from CONFIG_CONSOLE_PULL to CONFIG_CONSOLE_SUBSYS
(CONFIG_CONSOLE is already used by console drivers). This signifies
that console subsystem is intended to deal with all of console
aspects in Zephyr (existing and new), not just provide some "new"
functionality on top of raw console drivers, like it initially
started.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-06-20 15:59:12 -04:00
Anas Nashif 429c2a4d9d kconfig: fix help syntax and add spaces
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-13 17:43:28 -06:00
Paul Sokolovsky 3cb13b9687 subsys: console: Add buffered output support to console subsystem
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-05-15 15:56:56 -04:00
Paul Sokolovsky 542c2b93d0 subsys: console: Add pull-style console API support.
This change introduces console_getchar() and console_getline() API
calls which can be used to get pending console input (either one
char or whole line), or block waiting for one. In this regard, they
are similar to well-known ANSI C function getchar/gets/fgets, and
are intended to ease porting of existing applications to Zephyr, and
indeed, these functions (shaped as an external module) are already
used by few applications.

The implementation of the functions is structured as a new "console"
subsystem. The intention is that further generic console code may be
pulled there instead of being in drivers/console/. Besides the
functions themselves, initialization code and sample applications
are included.

At this time, there're may limitations of how these functions can
be used. For example, console_getchar() and console_getline() are
mutually exclusive, and both are incompatible with callback
(push-style) console API (and e.g. with console shell subsystem
which uses this API). Again, the intention is to make a first step
towards refactoring console subsystem to allow more flexible
real-world usage, better reusability and composability.

Change-Id: I3f4015bb5b26e0656f82f428b11ba30e980d25a0
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-04-01 20:44:17 +00:00