tools/usb_gadget/gadget.py
def SetInterface(self, interface, alt_setting):
    """Handle a SET_INTERFACE request from the host.

    See Universal Serial Bus Specification Revision 2.0 section 9.4.10.

    Args:
      interface: Interface number to configure.
      alt_setting: Alternate setting to select.

    Returns:
      True on success, None on error to stall the pipe.
    """
    print('SetInterface({}, {})'.format(interface, alt_setting))

    config_desc = self.GetConfigurationDescriptor()
    interface_desc = None
    for interface_option in config_desc.GetInterfaces():
      if (interface_option.bInterfaceNumber == interface and
          interface_option.bAlternateSetting == alt_setting):
        interface_desc = interface_option
    if interface_desc is None:
      return None

    endpoint_addrs = self._active_endpoints.setdefault(interface, set())
    for endpoint_addr in endpoint_addrs:
      self._chip.StopEndpoint(endpoint_addr)
      del self._endpoint_interface_map[endpoint_addr]
    for endpoint_desc in interface_desc.GetEndpoints():
      self._chip.StartEndpoint(endpoint_desc)
      endpoint_addrs.add(endpoint_desc.bEndpointAddress)
      self._endpoint_interface_map[endpoint_desc.bEndpointAddress] = \
          interface_desc.bInterfaceNumber
    return True
Handle a SET_INTERFACE request from the host.

    See Universal Serial Bus Specification Revision 2.0 section 9.4.10.

    Args:
      interface: Interface number to configure.
      alt_setting: Alternate setting to select.

    Returns:
      True on success, None on error to stall the pipe.
    
Handle a SET_INTERFACE request from the host.
Handle a SET_INTERFACE request from the host .
def SetInterface(self, interface, alt_setting):
    print('SetInterface({}, {})'.format(interface, alt_setting))
    config_desc = self.GetConfigurationDescriptor()
    interface_desc = None
    for interface_option in config_desc.GetInterfaces():
      if (interface_option.bInterfaceNumber == interface and
          interface_option.bAlternateSetting == alt_setting):
        interface_desc = interface_option
    if interface_desc is None:
      return None
    endpoint_addrs = self._active_endpoints.setdefault(interface, set())
    for endpoint_addr in endpoint_addrs:
      self._chip.StopEndpoint(endpoint_addr)
      del self._endpoint_interface_map[endpoint_addr]
    for endpoint_desc in interface_desc.GetEndpoints():
      self._chip.StartEndpoint(endpoint_desc)
      endpoint_addrs.add(endpoint_desc.bEndpointAddress)
      self._endpoint_interface_map[endpoint_desc.bEndpointAddress] = \
          interface_desc.bInterfaceNumber
    return True
def SetInterface ( self , interface , alt_setting ) : print ( 'SetInterface({}, {})' . format ( interface , alt_setting ) ) config_desc = self . GetConfigurationDescriptor ( ) interface_desc = None for interface_option in config_desc . GetInterfaces ( ) : if ( interface_option . bInterfaceNumber == interface and interface_option . bAlternateSetting == alt_setting ) : interface_desc = interface_option if interface_desc is None : return None endpoint_addrs = self . _active_endpoints . setdefault ( interface , set ( ) ) for endpoint_addr in endpoint_addrs : self . _chip . StopEndpoint ( endpoint_addr ) del self . _endpoint_interface_map [ endpoint_addr ] for endpoint_desc in interface_desc . GetEndpoints ( ) : self . _chip . StartEndpoint ( endpoint_desc ) endpoint_addrs . add ( endpoint_desc . bEndpointAddress ) self . _endpoint_interface_map [ endpoint_desc . bEndpointAddress ] = interface_desc . bInterfaceNumber return True
Handle a SET_INTERFACE request from the host.
Handle a SET_INTERFACE request from the host .
"""Handle a SET_INTERFACE request from the host.

    See Universal Serial Bus Specification Revision 2.0 section 9.4.10.

    Args:
      interface: Interface number to configure.
      alt_setting: Alternate setting to select.

    Returns:
      True on success, None on error to stall the pipe.
    """
True on success, None on error to stall the pipe.
True on success None on error to stall the pipe .
self
interface
Interface number to configure.
Interface number to configure .
alt_setting
Alternate setting to select.
Alternate setting to select .