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

sys/shell: add pm command for power management #13679

Closed
wants to merge 2 commits into from

Conversation

gschorcht
Copy link
Contributor

Contribution description

This PR moves the pm commands from tests/periph_pm' to a shell command module pm_cmd to make them available for embedding in other applications, e.g. for debugging by using

USEMODULE=pm_cmd BOARD=... make -C tests/shell

The test application tests/periph_pm now uses the shell command module instead of defining the pm commands by itself.

Dependent on module pm_layered and feature periph_rtc the following commands are available:

off		turn off
reboot		reboot
set		set power mode
block		block power mode
unblock		unblock power mode
unblock_rtc	temporary unblock power mode

The set, block, unblock commands are available if the platform supports pm_layerd. The unblock_rtc is only available if the platform support pm_layered and feature periph_rtc.

Testing procedure

Compile and flash tests/periph for a board with periph_rtc feature, for example

make BOARD=nucleo-f411re -C tests/periph_pm flash term

and excute the following tests:

  • Set mode 1
    > rtc gettime
    2020-03-22 16:30:18
    > rtc setalarm 2020-03-22 16:30:40
    > pm set 1
    CPU will enter power mode 1.
    ...
    > 
    
  • Set mode 1
    rtc setalarm 2020-03-22 16:31:50
    > 
    > pm set 0
    CPU will enter power mode 0.
    .main(): This is RIOT! (Version: 2020.04-devel-1400-g5aff3-sys/shell/pm_cmd)
    test_shell.
    >
    
  • Unblock mode 1 for 5 seconds
    > pm unblock 1 5
    
  • Reboot with pm command
    > pm reboot
    
  • Power off pm command
    > pm off
    

Issues/PRs references

@gschorcht gschorcht requested a review from MrKevinWeiss as a code owner March 22, 2020 16:30
@gschorcht gschorcht added Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Mar 22, 2020
@aabadie
Copy link
Contributor

aabadie commented Mar 22, 2020

Sorry, duplicate of #11731...

@gschorcht
Copy link
Contributor Author

@aabadie Sorry, duplicate of #11731

Okay, I didn't realize that, no problem. I just needed the pm command to test PM in other applications and had to copy and paste it over and over again. So I just moved it to a module and thought it was worth sharing it with others. If there is already a PR, this is even better.

@gschorcht gschorcht closed this Mar 22, 2020
@benemorius
Copy link
Member

At first glance this looks more mature than #11731 so I'm inclined to abandon it.

@gschorcht could you add a pm show command?

@gschorcht
Copy link
Contributor Author

@gschorcht could you add a pm show command?

Sure.

@aabadie
Copy link
Contributor

aabadie commented Mar 22, 2020

At first glance this looks more mature than #11731 so I'm inclined to abandon it.

Not sure, this PR introduces pm_cmd which I think is not needed (well, there are design decisions that should be further discussed, since pm reboot might now be duplicated in the shell) .
I would rather go with #11731 which is close from being merged (if you address the remaining comments). We can improve it later or eventually @gschorcht can take it over ?

The pm show command is also a nice addition in #11731.

@benemorius
Copy link
Member

@aabadie you're right I'm sorry I completely forgot there was a review on that one already. IIRC I addressed the comments and neglected to say anything about it. I'll check on it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants