Skip to content

pyterm: configuring repeating command on empty line #12120

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

Conversation

cladmi
Copy link
Contributor

@cladmi cladmi commented Aug 29, 2019

Contribution description

Allow configuring that it sends an empty newline when it receives a newline.

Alternative to #12096

Toggle implementation based on https://stackoverflow.com/a/15008806/395687

Testing procedure

Run the shell and execute 'help' then just send an empty line with 'enter'.

It repeats the command as in master without options:

Default behavior
BOARD=samr21-xpro RIOT_CI_BUILD=1 make --no-print-directory -C examples/default/ flash term
Building application "default" for "samr21-xpro" with MCU "samd21".

   text    data     bss     dec     hex filename
  40864     508    6048   47420    b93c /home/harter/work/git/RIOT/examples/default/bin/samr21-xpro/default.elf
/home/harter/work/git/RIOT/dist/tools/edbg/edbg  -t atmel_cm0p -b -v -p -f /home/harter/work/git/RIOT/examples/default/bin/samr21-xpro/default.bin
Debugger: ATMEL EDBG CMSIS-DAP ATML2127031800004678 01.1A.00FB (S)
Clock frequency: 16.0 MHz
Target: SAM R21G18 (Rev C)
Programming..................................................................................................................................................................... done.
Verification..................................................................................................................................................................... done.
/home/harter/work/git/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200"
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2019-08-29 15:18:57,560 - INFO # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
help
2019-08-29 15:19:00,699 - INFO # help
2019-08-29 15:19:00,702 - INFO # Command              Description
2019-08-29 15:19:00,705 - INFO # ---------------------------------------
2019-08-29 15:19:00,709 - INFO # reboot               Reboot the node
2019-08-29 15:19:00,714 - INFO # ps                   Prints information about running threads.
2019-08-29 15:19:00,718 - INFO # random_init          initializes the PRNG
2019-08-29 15:19:00,723 - INFO # random_get           returns 32 bit of pseudo randomness
2019-08-29 15:19:00,728 - INFO # rtc                  control RTC peripheral interface
2019-08-29 15:19:00,732 - INFO # ifconfig             Configure network interfaces
2019-08-29 15:19:00,738 - INFO # txtsnd               Sends a custom string as is over the link layer
2019-08-29 15:19:00,744 - INFO # saul                 interact with sensors and actuators using SAUL
>
2019-08-29 15:19:07,002 - INFO #  help
2019-08-29 15:19:07,005 - INFO # Command              Description
2019-08-29 15:19:07,008 - INFO # ---------------------------------------
2019-08-29 15:19:07,012 - INFO # reboot               Reboot the node
2019-08-29 15:19:07,017 - INFO # ps                   Prints information about running threads.
2019-08-29 15:19:07,021 - INFO # random_init          initializes the PRNG
2019-08-29 15:19:07,026 - INFO # random_get           returns 32 bit of pseudo randomness
2019-08-29 15:19:07,031 - INFO # rtc                  control RTC peripheral interface
2019-08-29 15:19:07,035 - INFO # ifconfig             Configure network interfaces
2019-08-29 15:19:07,041 - INFO # txtsnd               Sends a custom string as is over the link layer
2019-08-29 15:19:07,048 - INFO # saul                 interact with sensors and actuators using SAUL
> 2019-08-29 15:19:10,513 - INFO # Exiting Pyterm
/home/harter/work/git/RIOT/examples/default/../../Makefile.include:566: recipe for target 'term' failed
make: *** [term] Interrupt

The new behavior can be used by setting PYTERMFLAGS=" --no-repeat-command-on-empty-line" in the environment:

Sending the newline, just sends the newline to the shell
PYTERMFLAGS=" --no-repeat-command-on-empty-line" BOARD=samr21-xpro RIOT_CI_BUILD=1 make --no-print-directory -C examples/default/ flash term
Building application "default" for "samr21-xpro" with MCU "samd21".

   text    data     bss     dec     hex filename
  40864     508    6048   47420    b93c /home/harter/work/git/RIOT/examples/default/bin/samr21-xpro/default.elf
/home/harter/work/git/RIOT/dist/tools/edbg/edbg  -t atmel_cm0p -b -v -p -f /home/harter/work/git/RIOT/examples/default/bin/samr21-xpro/default.bin
Debugger: ATMEL EDBG CMSIS-DAP ATML2127031800004678 01.1A.00FB (S)
Clock frequency: 16.0 MHz
Target: SAM R21G18 (Rev C)
Programming..................................................................................................................................................................... done.
Verification..................................................................................................................................................................... done.
/home/harter/work/git/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200"  --no-repeat-command-on-empty-line
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2019-08-29 15:20:45,250 - INFO # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.
help
2019-08-29 15:20:52,803 - INFO # help
2019-08-29 15:20:52,806 - INFO # Command              Description
2019-08-29 15:20:52,809 - INFO # ---------------------------------------
2019-08-29 15:20:52,812 - INFO # reboot               Reboot the node
2019-08-29 15:20:52,818 - INFO # ps                   Prints information about running threads.
2019-08-29 15:20:52,822 - INFO # random_init          initializes the PRNG
2019-08-29 15:20:52,827 - INFO # random_get           returns 32 bit of pseudo randomness
2019-08-29 15:20:52,832 - INFO # rtc                  control RTC peripheral interface
2019-08-29 15:20:52,836 - INFO # ifconfig             Configure network interfaces
2019-08-29 15:20:52,842 - INFO # txtsnd               Sends a custom string as is over the link layer
2019-08-29 15:20:52,848 - INFO # saul                 interact with sensors and actuators using SAUL
>
2019-08-29 15:20:53,683 - INFO #

Issues/PRs references

Alternative to #12096

Allow configuring that it sends an empty newline when it receives a newline.
@jcarrano jcarrano self-requested a review September 9, 2019 16:52
@jcarrano jcarrano added Area: tools Area: Supplementary tools Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Sep 9, 2019
@aabadie aabadie added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 10, 2019
Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

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

The new feature (disabling command repeat) works as expected and the default behaviour is unchanged (repeat command on enter).
Nothing to say on code changes. ACK

@aabadie aabadie merged commit abd1cd5 into RIOT-OS:master Sep 10, 2019
@cladmi
Copy link
Contributor Author

cladmi commented Sep 10, 2019

Thank you for the review.

@cladmi cladmi deleted the pr/pyterm/configurable_repeat_command_on_empty_line branch September 10, 2019 12:31
@kb2ma kb2ma added this to the Release 2019.10 milestone Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants