shell: Add handling of CONFIG_LOG_INPLACE_PROCESS option
Extended shell to be able to process logs in place (in the context of a log call). In order to achieve that, shell was extended to support for TX blocking operations. If CONFIG_LOG_INPLACE_PROCESS is enabled then shell instance attempts to be initialized in blocking TX mode. If fails to do so, shell log backend is disabled. If successfully enabled logs are processed and printed in the context of the call. Due to that change, user may expirience interleaved output as shell has no means to multiplex shell output with logger output. In extreme, huge amount of log messages may prevent shell thread execution and shell may become unresponsive. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
4c2deebcdf
commit
2e6892c9b0
5 changed files with 105 additions and 31 deletions
|
@ -180,18 +180,14 @@ static int uninit(const struct shell_transport *transport)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int enable(const struct shell_transport *transport, bool blocking)
|
||||
static int enable(const struct shell_transport *transport, bool blocking_tx)
|
||||
{
|
||||
const struct shell_uart *sh_uart = (struct shell_uart *)transport->ctx;
|
||||
|
||||
sh_uart->ctrl_blk->blocking = blocking;
|
||||
sh_uart->ctrl_blk->blocking_tx = blocking_tx;
|
||||
|
||||
if (blocking) {
|
||||
if (!IS_ENABLED(CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN)) {
|
||||
k_timer_stop(sh_uart->timer);
|
||||
}
|
||||
if (blocking_tx) {
|
||||
#ifdef CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN
|
||||
uart_irq_rx_disable(sh_uart->ctrl_blk->dev);
|
||||
uart_irq_tx_disable(sh_uart->ctrl_blk->dev);
|
||||
#endif
|
||||
}
|
||||
|
@ -218,7 +214,7 @@ static int write(const struct shell_transport *transport,
|
|||
const u8_t *data8 = (const u8_t *)data;
|
||||
|
||||
if (IS_ENABLED(CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN) &&
|
||||
!sh_uart->ctrl_blk->blocking) {
|
||||
!sh_uart->ctrl_blk->blocking_tx) {
|
||||
irq_write(sh_uart, data, length, cnt);
|
||||
} else {
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue