Module: LIBUSB::Call

Extended by:
FFI::Library
Defined in:
lib/libusb/call.rb

Overview

C level interface - for internal use only

All enum codes are available as constants in LIBUSB namespace.

Defined Under Namespace

Classes: ControlSetup, DeviceDescriptor, IsoPacketDescriptor, Pollfd, Timeval, Transfer

Constant Summary collapse

ClassCodes =
enum :libusb_class_code, [
  :CLASS_PER_INTERFACE, 0,
  :CLASS_AUDIO, 1,
  :CLASS_COMM, 2,
  :CLASS_HID, 3,
  :CLASS_PRINTER, 7,
  :CLASS_PTP, 6,
  :CLASS_MASS_STORAGE, 8,
  :CLASS_HUB, 9,
  :CLASS_DATA, 10,
  :CLASS_WIRELESS, 0xe0,
  :CLASS_APPLICATION, 0xfe,
  :CLASS_VENDOR_SPEC, 0xff
]
Errors =
enum :libusb_error, [
  :SUCCESS, 0,
  :ERROR_IO, -1,
  :ERROR_INVALID_PARAM, -2,
  :ERROR_ACCESS, -3,
  :ERROR_NO_DEVICE, -4,
  :ERROR_NOT_FOUND, -5,
  :ERROR_BUSY, -6,
  :ERROR_TIMEOUT, -7,
  :ERROR_OVERFLOW, -8,
  :ERROR_PIPE, -9,
  :ERROR_INTERRUPTED, -10,
  :ERROR_NO_MEM, -11,
  :ERROR_NOT_SUPPORTED, -12,
  :ERROR_OTHER, -99,
]
TransferStatus =

Transfer status codes

enum :libusb_transfer_status, [
  :TRANSFER_COMPLETED,
  :TRANSFER_ERROR,
  :TRANSFER_TIMED_OUT,
  :TRANSFER_CANCELLED,
  :TRANSFER_STALL,
  :TRANSFER_NO_DEVICE,
  :TRANSFER_OVERFLOW,
]
TransferFlags =

libusb_transfer.flags values

enum :libusb_transfer_flags, [
  :TRANSFER_SHORT_NOT_OK, 1 << 0,
  :TRANSFER_FREE_BUFFER, 1 << 1,
  :TRANSFER_FREE_TRANSFER, 1 << 2,
  :TRANSFER_ADD_ZERO_PACKET, 1 << 3,
]
TransferTypes =
enum :libusb_transfer_type, [
  :TRANSFER_TYPE_CONTROL, 0,
  :TRANSFER_TYPE_ISOCHRONOUS, 1,
  :TRANSFER_TYPE_BULK, 2,
  :TRANSFER_TYPE_INTERRUPT, 3,
]
StandardRequests =
enum :libusb_standard_request, [
  :REQUEST_GET_STATUS, 0x00,
  :REQUEST_CLEAR_FEATURE, 0x01,
  :REQUEST_SET_FEATURE, 0x03,
  :REQUEST_SET_ADDRESS, 0x05,
  :REQUEST_GET_DESCRIPTOR, 0x06,
  :REQUEST_SET_DESCRIPTOR, 0x07,
  :REQUEST_GET_CONFIGURATION, 0x08,
  :REQUEST_SET_CONFIGURATION, 0x09,
  :REQUEST_GET_INTERFACE, 0x0A,
  :REQUEST_SET_INTERFACE, 0x0B,
  :REQUEST_SYNCH_FRAME, 0x0C,
]
EndpointDirections =
enum :libusb_endpoint_direction, [
  :ENDPOINT_IN, 0x80,
  :ENDPOINT_OUT, 0x00,
]
DescriptorTypes =
enum :libusb_descriptor_type, [
  :DT_DEVICE, 0x01,
  :DT_CONFIG, 0x02,
  :DT_STRING, 0x03,
  :DT_INTERFACE, 0x04,
  :DT_ENDPOINT, 0x05,
  :DT_HID, 0x21,
  :DT_REPORT, 0x22,
  :DT_PHYSICAL, 0x23,
  :DT_HUB, 0x29,
]
RequestTypes =
enum :libusb_request_type, [
  :REQUEST_TYPE_STANDARD, (0x00 << 5),
  :REQUEST_TYPE_CLASS, (0x01 << 5),
  :REQUEST_TYPE_VENDOR, (0x02 << 5),
  :REQUEST_TYPE_RESERVED, (0x03 << 5),
]
RequestRecipients =
enum :libusb_request_recipient, [
  :RECIPIENT_DEVICE, 0x00,
  :RECIPIENT_INTERFACE, 0x01,
  :RECIPIENT_ENDPOINT, 0x02,
  :RECIPIENT_OTHER, 0x03,
]
IsoSyncTypes =
enum :libusb_iso_sync_type, [
  :ISO_SYNC_TYPE_NONE, 0,
  :ISO_SYNC_TYPE_ASYNC, 1,
  :ISO_SYNC_TYPE_ADAPTIVE, 2,
  :ISO_SYNC_TYPE_SYNC, 3,
]
Speeds =
enum :libusb_speed, [
  :SPEED_UNKNOWN, 0,
  :SPEED_LOW, 1,
  :SPEED_FULL, 2,
  :SPEED_HIGH, 3,
  :SPEED_SUPER, 4,
]
Capabilities =
enum :libusb_capability, [
  :CAP_HAS_CAPABILITY, 0x0000,
  # Hotplug support is available on this platform.
  :CAP_HAS_HOTPLUG, 0x0001,
  # The library can access HID devices without requiring user intervention.
  # Note that before being able to actually access an HID device, you may
  # still have to call additional libusb functions such as
  # {DevHandle#detach_kernel_driver}.
  :CAP_HAS_HID_ACCESS, 0x0100,
  # The library supports detaching of the default USB driver, using
  # {DevHandle#detach_kernel_driver}, if one is set by the OS kernel.
  :CAP_SUPPORTS_DETACH_KERNEL_DRIVER, 0x0101,
]
HotplugEvents =

Since libusb version 1.0.16.

Hotplug events

enum :libusb_hotplug_event, [
  # A device has been plugged in and is ready to use.
  :HOTPLUG_EVENT_DEVICE_ARRIVED, 0x01,

  # A device has left and is no longer available.
  # It is the user's responsibility to call libusb_close on any handle associated with a disconnected device.
  # It is safe to call libusb_get_device_descriptor on a device that has left.
  :HOTPLUG_EVENT_DEVICE_LEFT, 0x02,
]
HotplugFlags =

Since libusb version 1.0.16.

Flags for hotplug events */

enum :libusb_hotplug_flag, [
  # Arm the callback and fire it for all matching currently attached devices.
  :HOTPLUG_ENUMERATE, 1,
]

Class Method Summary collapse

Class Method Details

.try_attach_function(method, *args) ⇒ Object



191
192
193
194
195
# File 'lib/libusb/call.rb', line 191

def self.try_attach_function(method, *args)
  if ffi_libraries.find{|lib| lib.find_function(method) }
    attach_function method, *args
  end
end