Commit graph

20 commits

Author SHA1 Message Date
Joakim Andersson 1738f0e64b console: tty: Fix k_sem_take with wait time from ISR
Fix k_sem_take called with a timeout value other than K_NO_WAIT from
isr.
This happens when tty_irq_input_hook calls tty_putchar with the `~`
character to give the user a clue that input was lost.

This resulted in the following assert in sem.c:
	ASSERTION FAIL @ WEST_TOPDIR/zephyr/kernel/sem.c:140

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-06-17 17:10:08 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
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 32bb2395c2 timeout: Fix up API usage
Kernel timeouts have always been a 32 bit integer despite the
existence of generation macros, and existing code has been
inconsistent about using them.  Upcoming commits are going to make the
timeout arguments opaque, so fix things up to be rigorously correct.
Changes include:

+ Adding a K_TIMEOUT_EQ() macro for code that needs to compare timeout
  values for equality (e.g. with K_FOREVER or K_NO_WAIT).

+ Adding a k_msleep() synonym for k_sleep() which can continue to take
  integral arguments as k_sleep() moves away to timeout arguments.

+ Pervasively using the K_MSEC(), K_SECONDS(), et. al. macros to
  generate timeout arguments.

+ Removing the usage of K_NO_WAIT as the final argument to
  K_THREAD_DEFINE().  This is just a count of milliseconds and we need
  to use a zero.

This patch include no logic changes and should not affect generated
code at all.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-03-31 19:40:47 -04:00
Peter Bigot 6e5db350b2 coccinelle: standardize k_sleep calls with integer timeouts
Re-run with updated script to convert integer literal delay arguments to
k_sleep to use the standard timeout macros.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-10-09 08:38:10 -04:00
Pavel Kral 51eb4572f5 subsystem: console: tty init checks and support for polled-only devices
This patch add tty runtime initialization check for console support
routines. Without it callers of routines API are not aware that
initialization of tty was failed. This patch basically checks
availability of console device and also its support for
interrupt driven transfers if routines are configured to use it.

Signed-off-by: Pavel Kral <pavel.kral@omsquare.com>
2019-09-08 12:43:49 +02:00
Anas Nashif 9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif d1b2718687 cleanup: include/: move uart.h to drivers/uart.h
move uart.h to drivers/uart.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif 52b3d2b671 cleanup: include/: move tty.h to console/tty.h
move tty.h to console/tty.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Paul Sokolovsky 9ec9c430b3 console: tty: Remove dependency on older "consoles"
Console subsystem doesn't depend on older consoles-in-drivers, the
only common thing between them is CONFIG_UART_CONSOLE_ON_DEV_NAME
setting, so make it so (by depending on either UART_CONSOLE or
CONSOLE_SUBSYS.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-02-28 16:57:50 -08:00
Paul Sokolovsky 0925411356 tty: Remove buffer params from tty_init()
Let's have more orthogonal and cleaner API, where buffers are
configured by tty_set_rx_buf/tty_set_tx_buf, and only them. It
means that newly initialized tty starts in unbuffered mode, which
is somewhat a sidestep from a main usecase behind tty, which is
buffered operation, but again, having a cleaner API (and good
docs, explaining users how it should be and what they should do)
prevails.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-12-20 12:21:49 +01:00
Paul Sokolovsky a7df3a1e09 tty: Support unbuffered operation to extend usecase coverage
The whole "tty" concept is conceived around efficient
interrupt-driven operation. However, it's beneficial to add
non interupt-driven operation under the same API:

1. Wider usecase coverage in general.
2. Allows to use the same familiar API (based on POSIX concepts)
even for UART implementations without interrupt support.
3. Allows to switch operation dynamically based on the needs.
For example, if the system is in degraded mode and interrupt
handling cannot be trusted/disabled, allows to still output
diagnostic information to user. This was the original motivation
to provide such a mode, to support logging subsystem's "panic"
mode.

To implement this feature, tty_set_rx_buf() and tty_set_tx_buf()
functions are provided, allowing to reconfigure buffers used
dynamically. If configured buffer length is 0, the operation
switched to unbuffered.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-12-20 12:21:49 +01:00
Paul Sokolovsky 1165e852c1 subsys: console: tty: Use tty_putchar() instead of console_putchar()
To be properly layered.

This call is used to signal to user an input buffer overload. Take
a chance to output just a single character in this case, to avoid
amplification and possible output buffer overflow either.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-11-30 08:05:40 -08:00
Paul Sokolovsky ed852e8b4a subsys: console: Split tty definitions into tty.h, to form its own API
This patch proceeds with the separation of older serial console
subsystem into device-independent console subsytem and buffered
serial device ("tty") API.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-11-30 08:05:40 -08:00
Paul Sokolovsky 6203020bfd subsys: console: Switch to POSIX-like read/write interface
Tty device gets only read/write calls, but console retains
getchar/putchar for convenience.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-11-04 17:31:39 -05:00
Paul Sokolovsky 9d3b48fd48 subsys: console: tty: Allow to specify transmit timeout
Previously, transmit was effectively non-blocking - a character either
went into buffer, or -1 was returned. Now it's possible to block if
buffer is full. Timeout is K_FOREVER by default, can be adjusted
with tty_set_tx_timeout() (similar to receive timeout).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-11-04 17:31:39 -05:00
Paul Sokolovsky 680085b3e2 subsys: console: tty: Allow to specify receive timeout
This allows to specify receive timeout, instead of previously
hardcoded K_FOREVER value. K_FOREVER is still the default, and can
be changes after tty initialization using tty_set_rx_timeout() call,
and timeout is stored as a property of tty. (Instead of e.g. being
a param of each receive call. Handling like that is required for
POSIX-like behavior of tty).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-11-04 17:31:39 -05:00
Paul Sokolovsky ca8aea1a62 subsys: console: Split serial tty handling to a separate module
Before going further for API refactoring in console subsys, makes
sense to split "tty" implementation from "console" implementation,
to make it clearer that "console" is just a "tty" instantiated on
a particular UART device.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-10-03 16:40:49 +02:00