respeaker/respeaker_python_library

AttributeError: 'Gpio' object has no attribute 'start'

Closed this issue · 1 comments

I set pin 12 with callback function, my code:

from  respeaker.gpio import *
import time

def btn_callback(pin_number, state):
    print('push')

io = Gpio(12, direction=INPUT, callback=btn_callback, edge=FALLING, active_low=0)
while True:
    time.sleep(0.1)

Following is the log file:

Traceback (most recent call last):
  File "io.py", line 1, in <module>
    from  respeaker.gpio import *
  File "/usr/lib/python2.7/site-packages/respeaker-0.6.0-py2.7.egg/respeaker/__init__.py", line 18, in                                                                                                                                <module>
    from respeaker.microphone import Microphone
  File "/usr/lib/python2.7/site-packages/respeaker-0.6.0-py2.7.egg/respeaker/microphone.py", line 35, i                                                                                                                               n <module>
    from respeaker.pixel_ring import pixel_ring
  File "/usr/lib/python2.7/site-packages/respeaker-0.6.0-py2.7.egg/respeaker/pixel_ring.py", line 18, i                                                                                                                               n <module>
    import respeaker.usb_hid
  File "/usr/lib/python2.7/site-packages/respeaker-0.6.0-py2.7.egg/respeaker/usb_hid/__init__.py", line                                                                                                                                60, in <module>
    devices = INTERFACE[usb_backend].getAllConnectedInterface()
  File "/usr/lib/python2.7/site-packages/respeaker-0.6.0-py2.7.egg/respeaker/usb_hid/pyusb_backend.py",                                                                                                                                line 71, in getAllConnectedInterface
    dev = usb.core.find(idVendor=0x2886, idProduct=0x0007)
  File "/usr/lib/python2.7/site-packages/usb/core.py", line 1253, in find
    import usb.backend.libusb1 as libusb1
  File "/usr/lib/python2.7/site-packages/usb/backend/libusb1.py", line 40, in <module>
    import usb.libloader
  File "/usr/lib/python2.7/site-packages/usb/libloader.py", line 32, in <module>
    import ctypes.util
  File "/usr/lib/python2.7/ctypes/util.py", line 89, in <module>
    import re, tempfile, errno
  File "/usr/lib/python2.7/tempfile.py", line 32, in <module>
    import io as _io
  File "/root/io.py", line 7, in <module>
    io = Gpio(12, direction=INPUT, callback=btn_callback, edge=FALLING, active_low=0)
  File "/usr/lib/python2.7/site-packages/respeaker-0.6.0-py2.7.egg/respeaker/gpio.py", line 121, in __i                                                                                                                               nit__
    self.start()
AttributeError: 'Gpio' object has no attribute 'start'

I found the problem here:

It must be:

self.thread.start()

@Huong-nt Thanks for the bug report. Fixed