Method: LIBUSB::DevHandle#claim_interface

Defined in:
lib/libusb/dev_handle.rb

#claim_interface(interface) ⇒ Object

Claim an interface on a given device handle.

You must claim the interface you wish to use before you can perform I/O on any of its endpoints.

It is legal to attempt to claim an already-claimed interface, in which case libusb just returns without doing anything.

Claiming of interfaces is a purely logical operation; it does not cause any requests to be sent over the bus. Interface claiming is used to instruct the underlying operating system that your application wishes to take ownership of the interface.

This is a non-blocking function.

If called with a block, the device handle is passed through to the block and the interface is released when the block has finished.

Parameters:

  • the interface or it’s bInterfaceNumber you wish to claim



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/libusb/dev_handle.rb', line 76

def claim_interface(interface)
  interface = interface.bInterfaceNumber if interface.respond_to? :bInterfaceNumber
  res = Call.libusb_claim_interface(@pHandle, interface)
  LIBUSB.raise_error res, "in libusb_claim_interface" if res!=0
  return self unless block_given?
  begin
    yield self
  ensure
    release_interface(interface)
  end
end