[Python] AttributeError: 'generator' object has no attribute 'set_configuration'

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    I would want to collect DATA from a USB audio codec connected to a raspberry pi. So first I'm trying a simple program to write some data

    import usb.core
    import usb.util

    # find our device
    dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)

    # was it found?
    if dev is None:
    raise ValueError('Device not found')

    # set the active configuration. With no arguments, the first
    # configuration will be the active one
    dev.set_configuration()

    # get an endpoint instance
    cfg = dev.get_active_configuration()
    intf = cfg[(0,0)]

    ep = usb.util.find_descriptor(
    intf,
    # match the first OUT endpoint
    custom_match = \
    lambda e: \
    usb.util.endpoint_direction(e.bEndpointAddress) == \
    usb.util.ENDPOINT_OUT)

    assert ep is not None

    # write the data
    ep.write('test')


    Here is my error : AttributeError: 'generator' object has no attribute 'set_configuration'

    Here is what the tutorial says about this function : After, we set the configuration to use. Note that no argument indicating what configuration we want was supplied. As you will see, many PyUSB functions have defaults for most common devices. In this case, the configuration set is the first one found.

    So I didn't understand why I'm getting this error. Any ideas please ?

    Continue reading...

Compartilhe esta Página