# Which code routines are handling the shutdown button?

**URL:** <https://forum.ubiquityrobotics.com/t/which-code-routines-are-handling-the-shutdown-button/955>\
**Category:** Uncategorized\
**Created:** [April 25, 2022, 4:38pm UTC](https://forum.ubiquityrobotics.com/t/which-code-routines-are-handling-the-shutdown-button/955 "2022-04-25T16:38:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![FolsomMike](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/folsommike/32/229_2.png) [@FolsomMike](https://forum.ubiquityrobotics.com/u/FolsomMike)\
**Post date:** [April 25, 2022, 4:38pm UTC](https://forum.ubiquityrobotics.com/t/which-code-routines-are-handling-the-shutdown-button/955/1 "2022-04-25T16:38:03Z")

</div>

I am trying to find the routine which is monitoring the shutdown button (input 6) on the Sonar board.

Also, which routine actually generates the system shutdown command?

I see where pi\_sonar is using the GPIO signals from the sonar board to handle the sonar sensors, but I cannot find any code/script/module which is monitoring the shutdown button GPIO input.

[UPDATE]

Looks like it is handled by an overlay and some functionality intrinsic to Linux or systemd:

/boot/config.txt

dtoverlay=ubiquity-led-buttons

* * *

The Raspberry Pi info states that a shutdown button can be set up by:

dtoverlay=gpio-shutdown

so I assume that ‘dtoverlay=ubiquity-led-buttons’ is accomplishing the same thing in some manner.

This assumption is backed up by Ubiquity’s instruction to remove ‘dtoverlay=ubiquity-led-buttons’ to free up the GPIO 6 pin for other uses.

Now to find the source for ‘/boot/overlays/ubiquity-led-buttons.dtbo’ or convert it back to human-readable.

I found the source for ‘/boot/overlays/ubiquity-led-buttons.dtbo’ at:

> **[pi\_image\_build/device-tree/source at master · UbiquityRobotics/pi\_image\_build](https://github.com/UbiquityRobotics/pi_image_build/tree/master/device-tree/source)**
>
> master/device-tree/source

---

<div class="post-metadata">

**Author:** ![anfederman](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/anfederman/32/141_2.png) [@anfederman](https://forum.ubiquityrobotics.com/u/anfederman)\
**Post date:** [May 1, 2022, 4:41pm UTC](https://forum.ubiquityrobotics.com/t/which-code-routines-are-handling-the-shutdown-button/955/2 "2022-05-01T16:41:43Z")

</div>

I tested on our Noetic 04/02 beta, the buttons work, and open the GUI to the shutdown or network settings screen. I don’t know if they work if no screen is detected.

---

<div class="post-metadata">

**Author:** ![mjstn2011](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/mjstn2011/32/30_2.png) [@mjstn2011](https://forum.ubiquityrobotics.com/u/mjstn2011)\
**Post date:** [May 10, 2022, 7:59am UTC](https://forum.ubiquityrobotics.com/t/which-code-routines-are-handling-the-shutdown-button/955/3 "2022-05-10T07:59:55Z")

</div>

With a half of a certainty I had been under the impression it is not as graceful as a shutdown command and is more like a jump to reset. Take this as in informed rumor, not as fact. It is all at kernel level was my understanding thus the need for the overlay approach. I would like to see someday a root level background monitor that does a true shutdown outside of ROS. This is something I have done on my robots.

What I use is on my github but because we use most all GPIO lines on Magni this is not compatible with Magni so would require some hacking. [MarkWorldCodeModules/RaspberryPiUtilities at master · mjstn/MarkWorldCodeModules · GitHub](https://github.com/mjstn/MarkWorldCodeModules/tree/master/RaspberryPiUtilities)  
See the sys\_monitor.py as a starting point. Just sharing and not recommending, it is NOT magni compatible as it stands.
