fossasia / susi_linux

Hardware for SUSI AI https://susi.ai
Apache License 2.0
1.6k stars 148 forks source link

Try fixing: RaspberryPiWakeButton has no subject #461

Closed hongquan closed 5 years ago

hongquan commented 5 years ago

Fixes an error with WakeButton, reported by @Orbiter

Checklist

Test Passing

Short description of what this resolves:

Reported error log:

Feb 25 22:41:44 raspberrypi python3[559]: INFO: Susi has the wake button enabled
Feb 25 22:41:44 raspberrypi python3[559]: INFO: Susi runs on a RaspberryPi
Feb 25 22:41:44 raspberrypi python3[559]: /home/pi/SUSI.AI/susi_linux/main/hardware_components/rpi_wake_button.py:15: RuntimeWarning: This channel is already in use, continuing anyway.  Use GPIO.setwarnings(False) to disable warnings.
Feb 25 22:41:44 raspberrypi python3[559]:   GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
Feb 25 22:41:44 raspberrypi python3[559]: Traceback (most recent call last):
Feb 25 22:41:44 raspberrypi python3[559]:   File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
Feb 25 22:41:45 raspberrypi python3[559]:     "__main__", mod_spec)
Feb 25 22:41:45 raspberrypi python3[559]:   File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
Feb 25 22:41:45 raspberrypi python3[559]:     exec(code, run_globals)
Feb 25 22:41:45 raspberrypi python3[559]:   File "/home/pi/SUSI.AI/susi_linux/main/__main__.py", line 57, in <module>
Feb 25 22:41:45 raspberrypi python3[559]:     susiStateMachine = SusiStateMachine()
Feb 25 22:41:45 raspberrypi python3[559]:   File "/home/pi/SUSI.AI/susi_linux/main/states/susi_state_machine.py", line 94, in __init__
Feb 25 22:41:45 raspberrypi python3[559]:     self.__idle_state = IdleState(components)
Feb 25 22:41:45 raspberrypi python3[559]:   File "/home/pi/SUSI.AI/susi_linux/main/states/idle_state.py", line 27, in __init__
Feb 25 22:41:45 raspberrypi python3[559]:     self.components.wake_button.subject.subscribe(
Feb 25 22:41:45 raspberrypi python3[559]: AttributeError: 'RaspberryPiWakeButton' object has no attribute ‚subject‘

Changes proposed in this pull request:

Original author of the code forgot to add subject attribute. I'm not sure what is the proper fix, because I haven't understood his intention yet. But let's try mimicking subject found in other classes (HotwordDetector).