sys/shell: Make echoing and prompt runtime-configurable.#12087
Closed
jcarrano wants to merge 9 commits intoRIOT-OS:masterfrom
Closed
sys/shell: Make echoing and prompt runtime-configurable.#12087jcarrano wants to merge 9 commits intoRIOT-OS:masterfrom
jcarrano wants to merge 9 commits intoRIOT-OS:masterfrom
Conversation
Member
|
I think |
Contributor
Author
|
I chose ps because of the |
The test for the line cancellation (ctrl-c) functionality was unable to detect error because of the way pexpect matches output. While working on the long line shell bug, a regression was about to be introduced because of this. This commit fixes the test by directly reading from the child process and expects an exact response. To make the test more robust, the newline handling was changed in native, where an extra empty line was being sent with each character.
Add a command to retrieve buffer size and then force an extremely long line. This is failing right now because of a bug in the shell. The terminal was changed to socat, as pyterm messes up the I/O and makes testing impossible.
The numeric value for EOF is (-1). This caused the shell to return the same code when EOF was encountered and when the line lenght was exceeded. Additionally, if the line length is exceeded, the correct behaviour is to consume the remaining characters until the end of the line, to prevent the following line from containing (potentially dangerous) garbage.
6d87457 to
365711c
Compare
Contributor
Author
|
I discovered some bugs in #10635 that were introduced during rebasing. I rebased this on top of the fixed branch. |
There was some code added to "prevent putchar from being inlined", which supposedly enlarged the code size. It does not seem to have any effect: both before and after the change the size is the same: $ BOARD=samr21-xpro make -c tests/shell all ...... text data bss dec hex filename 10416 140 2612 13168 3370 /home/jcarrano/source/vanillaRIOT/tests/shell/bin/samr21-xpro/tests_shell.elf It makes sense: the compiler is not _that_ dumb.
ifdefs in the middle of code reduce readability and debugability and should be avoided.
This adds a persistent state to the shell that stores the echo configuration and the prompt character. Both can be changed by the user with special built in commmands - @eon: turn echo on. - @eon: turn echo off. - @ps x: make x the prompt character. "@ps" (without any char) disables the prompt. This is implemented in a way that does not consume any additional RAM- it only adds some bytes to the code. A couple of bytes are stolen from the user supplied buffer to store this new configurations. The default state us given by the same compile time defines as before so this change is backwards compatible.
2 tasks
8 tasks
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
This adds a persistent state to the shell that stores the echo configuration and the prompt character. Both can be changed by the user with special built in commmands
@eon: turn echo on.@eoff: turn echo off.@ps x: make x the prompt character.@ps(without any char) disables the prompt.This is implemented in a way that does not consume any additional RAM- it only adds some bytes to the code. A couple of bytes are stolen from the user supplied buffer to store this new configurations.
The default state us given by the same compile time defines as before so this change is backwards compatible.
This will make the shell better suited for automated testing:
Testing procedure
TODO: I should add some test vectors.
Issues/PRs references
Part of #10994 .
Depends on: #10635 .
I made #12085 to fend off accusations that this will increase code size.