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, [
  # Control endpoint
  :TRANSFER_TYPE_CONTROL, 0,
  # Isochronous endpoint
  :TRANSFER_TYPE_ISOCHRONOUS, 1,
  # Bulk endpoint
  :TRANSFER_TYPE_BULK, 2,
  # Interrupt endpoint
  :TRANSFER_TYPE_INTERRUPT, 3,
  # Stream endpoint
  :TRANSFER_TYPE_BULK_STREAM, 4,
]
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, [
  # Device descriptor. See {Device}
  :DT_DEVICE, 0x01,
  # Configuration descriptor. See {Configuration}
  :DT_CONFIG, 0x02,
  # String descriptor
  :DT_STRING, 0x03,
  # Interface descriptor. See {Interface}
  :DT_INTERFACE, 0x04,
  # Endpoint descriptor. See {Endpoint}
  :DT_ENDPOINT, 0x05,
  # BOS descriptor
  :DT_BOS, 0x0f,
  # Device Capability descriptor
  :DT_DEVICE_CAPABILITY, 0x10,
  # HID descriptor
  :DT_HID, 0x21,
  # HID report descriptor
  :DT_REPORT, 0x22,
  # Physical descriptor
  :DT_PHYSICAL, 0x23,
  # Hub descriptor
  :DT_HUB, 0x29,
  # SuperSpeed Hub descriptor
  :DT_SUPERSPEED_HUB, 0x2a,
  # SuperSpeed Endpoint Companion descriptor
  :DT_SS_ENDPOINT_COMPANION, 0x30,
]
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 =

Speed codes. Indicates the speed at which the device is operating.

enum :libusb_speed, [
  # The OS doesn't report or know the device speed.
  :SPEED_UNKNOWN, 0,
  # The device is operating at low speed (1.5MBit/s).
  :SPEED_LOW, 1,
  # The device is operating at full speed (12MBit/s).
  :SPEED_FULL, 2,
  # The device is operating at high speed (480MBit/s).
  :SPEED_HIGH, 3,
  # The device is operating at super speed (5000MBit/s).
  :SPEED_SUPER, 4,
  # The device is operating at super speed plus (10000MBit/s).
  # Available since libusb-1.0.22
  :SPEED_SUPER_PLUS, 5,
]
SupportedSpeeds =

Supported speeds (wSpeedSupported) bitfield. Indicates what speeds the device supports.

enum :libusb_supported_speed, [
  # Low speed operation supported (1.5MBit/s).
  :LOW_SPEED_OPERATION, 1,
  # Full speed operation supported (12MBit/s).
  :FULL_SPEED_OPERATION, 2,
  # High speed operation supported (480MBit/s).
  :HIGH_SPEED_OPERATION, 4,
  # Superspeed operation supported (5000MBit/s).
  :SUPER_SPEED_OPERATION, 8,
]
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,
]
Usb20ExtensionAttributes =

Masks for the bits of the Bos::Usb20Extension#bmAttributes field of the USB 2.0 Extension descriptor.

enum :libusb_usb_2_0_extension_attributes, [
  # Supports Link Power Management (LPM)
  :BM_LPM_SUPPORT, 2,
]
SsUsbDeviceCapabilityAttributes =

Masks for the bits of the Bos::SsUsbDeviceCapability#bmAttributes field field of the SuperSpeed USB Device Capability descriptor.

enum :libusb_ss_usb_device_capability_attributes, [
  # Supports Latency Tolerance Messages (LTM)
  :BM_LTM_SUPPORT, 2,
]
BosTypes =

USB capability types

enum :libusb_bos_type, [
  # Wireless USB device capability
  :BT_WIRELESS_USB_DEVICE_CAPABILITY, 1,
  # USB 2.0 extensions
  :BT_USB_2_0_EXTENSION, 2,
  # SuperSpeed USB device capability
  :BT_SS_USB_DEVICE_CAPABILITY, 3,
  # Container ID type
  :BT_CONTAINER_ID, 4,
]
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,
]
LogLevels =

Log message levels.

  • :LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)

  • :LOG_LEVEL_ERROR (1) : error messages are printed to stderr

  • :LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr

  • :LOG_LEVEL_INFO (3) : informational messages are printed to stderr

  • :LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stderr

enum :libusb_log_level, [
  :LOG_LEVEL_NONE, 0,
  :LOG_LEVEL_ERROR, 1,
  :LOG_LEVEL_WARNING, 2,
  :LOG_LEVEL_INFO, 3,
  :LOG_LEVEL_DEBUG, 4,
]
Options =

Available option values for LIBUSB::Context#set_option.

enum :libusb_option, [
  # Set the log message verbosity.
  #
  # The default level is :LOG_LEVEL_NONE, which means no messages are ever
  # printed. If you choose to increase the message verbosity level, ensure
  # that your application does not close the stderr file descriptor.
  #
  # You are advised to use level :LOG_LEVEL_WARNING. libusb is conservative
  # with its message logging and most of the time, will only log messages that
  # explain error conditions and other oddities. This will help you debug
  # your software.
  #
  # If the +LIBUSB_DEBUG+ environment variable was set when libusb was
  # initialized, this function does nothing: the message verbosity is fixed
  # to the value in the environment variable.
  #
  # If libusb was compiled without any message logging, this function does
  # nothing: you'll never get any messages.
  #
  # If libusb was compiled with verbose debug message logging, this function
  # does nothing: you'll always get messages from all levels.
  :OPTION_LOG_LEVEL,

  # Use the UsbDk backend for a specific context, if available.
  #
  # This option should be set immediately after calling {Context.new}, otherwise
  # unspecified behavior may occur.
  #
  # Only valid on Windows.
  #
  # Available since libusb-1.0.22.
  :OPTION_USE_USBDK,
]

Class Method Summary collapse

Class Method Details

.try_attach_function(method, *args) ⇒ Object


318
319
320
321
322
# File 'lib/libusb/call.rb', line 318

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