Method: LIBUSB::Device#parent

Defined in:
lib/libusb/device.rb

#parentDevice?

Get the the parent from the specified device [EXPERIMENTAL]. Available since libusb-1.0.12.

Returns:

  • (Device, nil)

    the device parent or nil if not available

See Also:


112
113
114
115
116
117
118
119
120
# File 'lib/libusb/device.rb', line 112

def parent
  pppDevs = FFI::MemoryPointer.new :pointer
  Call.libusb_get_device_list(@context.instance_variable_get(:@ctx), pppDevs)
  ppDevs = pppDevs.read_pointer
  pParent = Call.libusb_get_parent(@pDev)
  parent = pParent.null? ? nil : Device.new(@context, pParent)
  Call.libusb_free_device_list(ppDevs, 1)
  parent
end