Skip to content

Commit

Permalink
Update shutdown.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadr committed Feb 24, 2021
1 parent b6d2053 commit 0bf9013
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions modules/shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ def run(self):
# Shutdown can be initated from GPIO26
poller = select.poll()
try:
with open('/sys/class/gpio/export', 'wb') as f:
with open('/sys/class/gpio/export', 'w') as f:
f.write('%d' % self.gpio)
except Exception:
# Usually it means we ran this before
pass
try:
with open('/sys/class/gpio/gpio%d/direction' % self.gpio, 'wb') as f:
with open('/sys/class/gpio/gpio%d/direction' % self.gpio, 'w') as f:
f.write('in')
except Exception:
logging.warn('Either no GPIO subsystem or no access')
return
with open('/sys/class/gpio/gpio%d/edge' % self.gpio, 'wb') as f:
with open('/sys/class/gpio/gpio%d/edge' % self.gpio, 'w') as f:
f.write('both')
with open('/sys/class/gpio/gpio%d/active_low' % self.gpio, 'wb') as f:
with open('/sys/class/gpio/gpio%d/active_low' % self.gpio, 'w') as f:
f.write('1')
with open('/sys/class/gpio/gpio%d/value' % self.gpio, 'rb') as f:
with open('/sys/class/gpio/gpio%d/value' % self.gpio, 'r') as f:
f.read()
poller.register(f, select.POLLPRI)
poller.register(self.server, select.POLLHUP)
Expand Down

2 comments on commit 0bf9013

@dadr
Copy link
Contributor

@dadr dadr commented on 0bf9013 Feb 24, 2021

Choose a reason for hiding this comment

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

Didn't see shutdown running in the thread trace, so did the obvious.
These changes resulted in the thread running again, but...
NOTE: I don't have a button connected to shutdown, so I did not test if this actually works.

@dadr
Copy link
Contributor

@dadr dadr commented on 0bf9013 Feb 25, 2021

Choose a reason for hiding this comment

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

This is what got me confused with helper.py. These calls were failing when opening sysfs as binary.

Please sign in to comment.