console: add functions to set the timeout

While the tty_* api already has functions
to set the rx and the tx timeout, the console_*
api didn't had one.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This commit is contained in:
Fin Maaß
2026-01-16 18:16:26 +01:00
committed by Anas Nashif
parent 2ed0e04dc8
commit 77c4fd9a53
2 changed files with 32 additions and 0 deletions

View File

@@ -110,6 +110,28 @@ void console_getline_init(void);
*/
char *console_getline(void);
/**
* @brief Set receive timeout for console operations.
*
* Set timeout for console_getchar() and console_read() operations.
* Default timeout after initialization is K_FOREVER.
*
* @param timeout Maximum time to wait when reading.
*/
void console_set_rx_timeout(k_timeout_t timeout);
/**
* @brief Set transmit timeout for console operations.
*
* Set timeout for console_putchar() and console_write() operations, for
* a case when output buffer is full.
* Default timeout after initialization is K_FOREVER.
*
* @param timeout Maximum time to wait when writing.
*/
void console_set_tx_timeout(k_timeout_t timeout);
#ifdef __cplusplus
}
#endif

View File

@@ -47,6 +47,16 @@ int console_getchar(void)
return c;
}
void console_set_rx_timeout(k_timeout_t timeout)
{
console_serial.rx_timeout = timeout;
}
void console_set_tx_timeout(k_timeout_t timeout)
{
console_serial.tx_timeout = timeout;
}
int console_init(void)
{
const struct device *uart_dev;