From 1738f0e64ba171915326f009ad3ed3764739baeb Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Tue, 16 Jun 2020 14:48:47 +0200 Subject: [PATCH] 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 --- subsys/console/tty.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subsys/console/tty.c b/subsys/console/tty.c index fabdd3b76c8..487ceb81e25 100644 --- a/subsys/console/tty.c +++ b/subsys/console/tty.c @@ -73,7 +73,9 @@ static int tty_putchar(struct tty_serial *tty, uint8_t c) int tx_next; int res; - res = k_sem_take(&tty->tx_sem, SYS_TIMEOUT_MS(tty->tx_timeout)); + res = k_sem_take(&tty->tx_sem, + k_is_in_isr() ? K_NO_WAIT : + SYS_TIMEOUT_MS(tty->tx_timeout)); if (res < 0) { return res; }