Skip to content

pyterm: add /sleep function#11095

Merged
benpicco merged 1 commit intoRIOT-OS:masterfrom
benpicco:pyterm_sleep
Jan 15, 2020
Merged

pyterm: add /sleep function#11095
benpicco merged 1 commit intoRIOT-OS:masterfrom
benpicco:pyterm_sleep

Conversation

@benpicco
Copy link
Contributor

@benpicco benpicco commented Mar 4, 2019

The init_cmd feature is quite handy for automated pyterm runs but there
is no delay between the commands, so they are all written to the target at once.

This adds a /sleep function that can be added between init_cmd commands
to prevent them from overflowing the RX buffer on the target.

@PeterKietzmann PeterKietzmann added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: tools Area: Supplementary tools labels Mar 5, 2019
@MrKevinWeiss MrKevinWeiss requested a review from cladmi March 5, 2019 07:54
@MrKevinWeiss
Copy link
Contributor

Hey @benpicco,
is it possible to add (or point to) a test case that shows the issue and the correction?

@benpicco
Copy link
Contributor Author

benpicco commented Mar 5, 2019

Sure. I just wanted a quick way to gauge the connection to several devices as a move along, so I wrote a little pyterm init script that allows me to save the output for logging:

When I do

[init_cmd]
init_cmd0 = ping6 fe80::d07:d5e9:7c9:572d
init_cmd1 = ping6 fe80::7b7a:342f:9d73:b482
init_cmd2 = ping6 fe80::8877:ae5b:82c9:561e
init_cmd3 = ping6 fe80::abcd:1

I get

2019-03-05 10:59:24,278 - INFO # ping6 fe80::d07:d5e9:7c9:572d
2019-03-05 10:59:27,283 - INFO # 
2019-03-05 10:59:27,287 - INFO # --- fe80::d07:d5e9:7c9:572d PING statistics ---
2019-03-05 10:59:27,292 - INFO # 3 packets transmitted, 0 packets received, 100% packet loss
> 2019-03-05 10:59:27,295 - INFO #  ping6 fe80::7b7a:342f:9d73:b482
2019-03-05 10:59:30,301 - INFO # 
2019-03-05 10:59:30,305 - INFO # --- fe80::7b7a:342f:9d73:b482 PING statistics ---
2019-03-05 10:59:30,310 - INFO # 3 packets transmitted, 0 packets received, 100% packet loss
> 2019-03-05 10:59:30,327 - INFO #  ping6 fe80::8877:ae5b:82c9:561e
2019-03-05 10:59:33,319 - INFO # 
2019-03-05 10:59:33,329 - INFO # --- fe80::8877:ae5b:82c9:561e PING statistics ---
2019-03-05 10:59:33,331 - INFO # 3 packets transmitted, 0 packets received, 100% packet lo

The last command is missing because the RX buffer was full.
When instead I do

[init_cmd]
init_cmd0 = ping6 fe80::d07:d5e9:7c9:572d
init_cmd1 = /sleep 3
init_cmd2 = ping6 fe80::7b7a:342f:9d73:b482
init_cmd3 = /sleep 3
init_cmd4 = ping6 fe80::8877:ae5b:82c9:561e
init_cmd5 = /sleep 3
init_cmd6 = ping6 fe80::abcd:1

all commands are executed

2019-03-05 10:59:51,439 - INFO # ping6 fe80::d07:d5e9:7c9:572d
2019-03-05 10:59:51,439 - INFO # 
2019-03-05 10:59:51,440 - INFO # --- fe80::d07:d5e9:7c9:572d PING statistics ---
2019-03-05 10:59:51,440 - INFO # 3 packets transmitted, 0 packets received, 100% packet loss
> 2019-03-05 10:59:51,441 - INFO #  ping6 fe80::7b7a:342f:9d73:b482
2019-03-05 10:59:51,454 - INFO # 
2019-03-05 10:59:51,458 - INFO # --- fe80::7b7a:342f:9d73:b482 PING statistics ---
2019-03-05 10:59:51,469 - INFO # 3 packets transmitted, 0 packets received, 100% packet loss
> 2019-03-05 10:59:51,469 - INFO #  ping6 fe80::8877:ae5b:82c9:561e
2019-03-05 10:59:54,473 - INFO # 
2019-03-05 10:59:54,476 - INFO # --- fe80::8877:ae5b:82c9:561e PING statistics ---
2019-03-05 10:59:54,482 - INFO # 3 packets transmitted, 0 packets received, 100% packet loss
> 2019-03-05 10:59:54,484 - INFO #  ping6 fe80::abcd:1
2019-03-05 10:59:57,488 - INFO # 
2019-03-05 10:59:57,491 - INFO # --- fe80::abcd:1 PING statistics ---
2019-03-05 10:59:57,496 - INFO # 3 packets transmitted, 0 packets received, 100% packet loss

@cladmi
Copy link
Contributor

cladmi commented Mar 5, 2019

I have a question on the usage, do you need the interactive shell after or do you just send automated commands ?

@benpicco
Copy link
Contributor Author

benpicco commented Mar 5, 2019

I just send automated commands - I actually send /quit as the last command.

Copy link
Contributor

@MrKevinWeiss MrKevinWeiss left a comment

Choose a reason for hiding this comment

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

As it is just a wrapper for sleep, it doesn't matter about code size, and people don't have to use it, I think it is fine to add it. I will wait for others to give opinions though before moving forward.

@cladmi
Copy link
Contributor

cladmi commented Mar 11, 2019

I am asking about the usage, because we are maybe moving away from having pyterm by default for some boards. And doing this is similar to what is currently done in shell tests.

I know it is not a test but more controlling a node through code on the host machine. So in in the vein of I am starting to do in #10949 over make term instead of inside make term.

However I think that for the moment it could be done in the same way as our tests are.
And if writing it as a test does not work, I would gladly have feedback to take it into account and make your usecase work.

@benpicco
Copy link
Contributor Author

What I like about pyterm is that it simply writes to stdout. So when I kill pyterm, the output stays in the terminal. I can also just pipe it to a file or run grep on it.

@MrKevinWeiss MrKevinWeiss added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 12, 2019
The init_cmd feature is quite handy for automated pyterm runs but there
is no delay between the commands that are executed.

This adds a /sleep function that can be added between init_cmd commands
to prevent them from overflowing the RX buffer on the target.
@benpicco benpicco added the Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer label Jul 29, 2019
@smlng smlng removed request for cladmi and smlng September 19, 2019 09:12
@benpicco
Copy link
Contributor Author

btw.: this is still useful.

E.g. I want to try some modulations but don't want to change the code of the example application or the driver defaults:

[init_cmd]
init_cmd0 = ifconfig 7 set phy_mode fsk
init_cmd1 = ifconfig 7 set fec NRNSC

Now if I want to to more complex things, the \sleep command, while a crutch, is still handy.

@MrKevinWeiss
Copy link
Contributor

I can jump back on this. My concern here is that this is pyterm specific. I also think that the automated tests now try to select socat by default.

I don't mind having extra features on tools so I think the concept is still OK.
To clarify when you say automated script you are not talking about the /tests/*/tests/01-run.py type scripts that testrunner targets, you are just talking about simple scripts that you use when testing?

@MrKevinWeiss MrKevinWeiss added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Nov 15, 2019
@MrKevinWeiss
Copy link
Contributor

Tested and it works

@MrKevinWeiss MrKevinWeiss added the Reviewed: 3-testing The PR was tested according to the maintainer guidelines label Nov 15, 2019
@MrKevinWeiss
Copy link
Contributor

used the tests/shell application with the nucleo-l433rc

Details
> /sleep 20
help
test
echo 123
help
help
test
echo 123
2019-11-15 10:30:06,784 - INFO #  help
help
2019-11-15 10:30:06,787 - INFO # Command              Description
2019-11-15 10:30:06,789 - INFO # ---------------------------------------
2019-11-15 10:30:06,792 - INFO # start_test           starts a test
2019-11-15 10:30:06,795 - INFO # end_test             ends a test
2019-11-15 10:30:06,799 - INFO # echo                 prints the input command
2019-11-15 10:30:06,803 - INFO # reboot               Reboot the node
2019-11-15 10:30:06,809 - INFO # ps                   Prints information about running threads.
> 2019-11-15 10:30:06,810 - INFO #  test
2019-11-15 10:30:06,813 - INFO # shell: command not found: test
> 2019-11-15 10:30:06,814 - INFO #  echo 123
2019-11-15 10:30:06,815 - INFO # "echo""123"
> 2019-11-15 10:30:06,816 - INFO #  help
2019-11-15 10:30:06,819 - INFO # Command              Description
2019-11-15 10:30:06,822 - INFO # ---------------------------------------
2019-11-15 10:30:06,824 - INFO # start_test           starts a test
2019-11-15 10:30:06,827 - INFO # end_test             ends a test
2019-11-15 10:30:06,831 - INFO # echo                 prints the input command
2019-11-15 10:30:06,834 - INFO # reboot               Reboot the node
2019-11-15 10:30:06,840 - INFO # ps                   Prints information about running threads.
> 

I can also exit the shell during the sleep.

@aabadie
Copy link
Contributor

aabadie commented Jan 15, 2020

This one seems ready and has been tested. @MrKevinWeiss what's your opinion ?

Copy link
Contributor

@MrKevinWeiss MrKevinWeiss left a comment

Choose a reason for hiding this comment

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

Maybe we rerun CI but it was fine for me. ACK.

@MrKevinWeiss MrKevinWeiss added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 15, 2020
@benpicco benpicco merged commit 8a99824 into RIOT-OS:master Jan 15, 2020
@benpicco benpicco deleted the pyterm_sleep branch January 15, 2020 17:25
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 Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Reviewed: 3-testing The PR was tested according to the maintainer guidelines 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.

5 participants