Skip to content
This repository has been archived by the owner on Sep 27, 2018. It is now read-only.

Develop Scripts for Shut Down and Restart of Pi via GPIO status #16

Closed
arandell93 opened this issue Dec 14, 2016 · 12 comments
Closed

Develop Scripts for Shut Down and Restart of Pi via GPIO status #16

arandell93 opened this issue Dec 14, 2016 · 12 comments
Assignees
Milestone

Comments

@arandell93
Copy link
Member

In order to provide a method for safetly shutting down or restarting the pi, we need the ability to initiate a safe shutdown from the outside of the boat without needing to be communicating with it from Shoreside.

This is best implemented using buttons attached to the GPIO pins. I will provide hardware required for this.

Proposal:

  1. One GPIO pin to initiate a shutdown script
  2. One GPIO pin to initiate a restart script
@arandell93 arandell93 added this to the Rev 1.01 milestone Dec 14, 2016
@arandell93
Copy link
Member Author

arandell93 commented Dec 16, 2016

See this link from the element14 community.

I am assigning

  • GPIO 23 (pin 16) as the shutdown button
  • GPIO 24 (pin 18) as the restart button

@arandell93
Copy link
Member Author

arandell93 commented Dec 16, 2016

Note: GPIO pins must be configured with internal pull-up resistances enabled, like so:

# Use the Broadcom SOC Pin numbers
# Setup the Pins with Internal pullups enabled and PINs in reading mode.
GPIO.setmode(GPIO.BCM)
GPIO.setup(16, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(18, GPIO.IN, pull_up_down = GPIO.PUD_UP)

@whymarrh
Copy link
Member

Can we have some sort of indicator (an LED?) onboard that can let us know the process has begun?

@arandell93
Copy link
Member Author

arandell93 commented Dec 17, 2016

Yeah we can, as described here.

We will use

  • GPIO 4 (pin 7) as the output to the LED.

I propose a different blinking pattern depending on what script (reset or shutdown) you run. Perhaps solid for shutdown and blink for reset?

@whymarrh
Copy link
Member

I propose a different blinking pattern depending on what script (reset or shutdown) you run. Perhaps solid for shutdown and blink for reset?

That is, I would set pin 7 high during shutdown and it would turn off when the Pi powers off?

For reset, some odd pattern of highs and lows (e.g. (high + low)* + high + off)?

@arandell93
Copy link
Member Author

Yessir!

@whymarrh
Copy link
Member

I propose a different blinking pattern depending on what script (reset or shutdown) you run. Perhaps solid for shutdown and blink for reset?

Let's not be at that. How about using:

Name:   gpio-poweroff
Info:   Drives a GPIO high or low on poweroff (including halt)
Load:   dtoverlay=gpio-poweroff,<param>=<val>
Params: gpiopin                 GPIO for signalling (default 26)

        active_low              Set if the power control device requires a
                                high->low transition to trigger a power-down.
                                Note that this will require the support of a
                                custom dt-blob.bin to prevent a power-down
                                during the boot process, and that a reboot
                                will also cause the pin to go low.

from the gpio-poweroff overlay. We can drive GPIO 4 low->high when powering off. Thoughts?

@arandell93
Copy link
Member Author

Won't that mean that the LED will only light up for a brief period of time as the unit is powering down, and will do the same thing regardless of reset or shutdown?

@whymarrh
Copy link
Member

Thinking about it more, I think what I proposed above should be fine for our purposes. GPIO 4 will be high long enough for us to notice it. We can use that pin in addition to the red and green lights onboard the Pi itself (it's not like it's underwater 😏). I think having that information will be more than enough to determine if the Pi is responding to the buttons.

As for knowing when the Pi is back in action, if I were to schedule a light or something to notify us, it'd be scheduled for the exact same time the control software starts up, at which point we may as well use any number of other factors to know whether it's working. If we really want some indication that the Pi is up and running, we can open up a new issue to add something to the control software proper.

@arandell93
Copy link
Member Author

We can use that pin in addition to the red and green lights onboard the Pi itself

Absolutely fine for now but when we change enclosures there are no guarantees that it will be transparent. The LED is to be mounted in the enclosure lid to give us that indication at that point.

we may as well use any number of other factors

Such as? Also we can divert this to a new issue if you would like, but we'll push it to the next release post 1.2 bug fixes. Cool?

@whymarrh
Copy link
Member

One possible example would be the the boat sending its position to the shore—no positions, no boat.

I admit it's not foolproof—if we want a "hardware" indication, we can have the control software do something (I'd be open to whatever, even if it's another LED) though I think that merits its own issue.

@arandell93
Copy link
Member Author

Moving indicator LED discussion to #24

whymarrh added a commit that referenced this issue Jun 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants