Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell: add generic RX buffer flush function #79371

Conversation

jakub-uC
Copy link
Contributor

@jakub-uC jakub-uC commented Oct 3, 2024

Added a generic function z_shell_backend_rx_buffer_flush to clear the RX buffer when resuming the shell. The function repeatedly calls the backend's read API until the buffer is empty or a maximum of 1000 iterations is reached. This prevents unintended command execution after shell_start.

@zephyrbot zephyrbot added the area: Shell Shell subsystem label Oct 3, 2024
@jakub-uC jakub-uC requested a review from rlubos October 3, 2024 13:17
@jakub-uC jakub-uC force-pushed the feature/shell-add-flush-function-to-shell-api branch from ab9d738 to 8a9c440 Compare October 3, 2024 13:32
@pdgendt pdgendt self-requested a review October 3, 2024 13:42
@jakub-uC jakub-uC force-pushed the feature/shell-add-flush-function-to-shell-api branch from 8a9c440 to 882fe44 Compare October 3, 2024 14:24
subsys/shell/shell.c Outdated Show resolved Hide resolved
@jakub-uC jakub-uC force-pushed the feature/shell-add-flush-function-to-shell-api branch 2 times, most recently from e0b64f2 to fad60f3 Compare October 3, 2024 16:43
@jakub-uC jakub-uC added the bug The issue is a bug, or the PR is fixing a bug label Oct 4, 2024
@jakub-uC
Copy link
Contributor Author

jakub-uC commented Oct 7, 2024

@nordic-krch kind reminder

subsys/shell/shell_ops.c Outdated Show resolved Hide resolved
@jakub-uC jakub-uC force-pushed the feature/shell-add-flush-function-to-shell-api branch from 982a06e to 2ade93e Compare October 9, 2024 07:03
Copy link
Collaborator

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't there a shell backend with a custom flush function?

subsys/shell/shell_ops.c Outdated Show resolved Hide resolved
@nordic-krch
Copy link
Contributor

Commit now has flushing function but it is not called anywhere and commit message states that it is called during resume.

@jakub-uC jakub-uC force-pushed the feature/shell-add-flush-function-to-shell-api branch from 2ade93e to e27563c Compare October 9, 2024 07:17
@jakub-uC
Copy link
Contributor Author

jakub-uC commented Oct 9, 2024

Wasn't there a shell backend with a custom flush function?

I don’t recall any backend flush function; there was only a function to flush the shell's TX buffer.

Added a generic function `z_shell_backend_rx_buffer_flush` to clear
the RX buffer when resuming the shell. The function repeatedly calls
the backend's `read` API until the buffer is empty or a maximum of
1000 iterations is reached. This prevents unintended command
execution after `shell_start`.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
@jakub-uC jakub-uC force-pushed the feature/shell-add-flush-function-to-shell-api branch from e27563c to 993b8bb Compare October 9, 2024 07:37
@jakub-uC jakub-uC changed the title shell: extend backend API with flush function support shell: add generic RX buffer flush function Oct 9, 2024
@aescolar aescolar merged commit 5bb7212 into zephyrproject-rtos:main Oct 9, 2024
24 checks passed
@jakub-uC jakub-uC deleted the feature/shell-add-flush-function-to-shell-api branch October 9, 2024 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Shell Shell subsystem bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants