Module: LIBUSB

Defined in:
lib/libusb.rb,
lib/libusb/bos.rb,
lib/libusb/call.rb,
lib/libusb/stdio.rb,
lib/libusb/device.rb,
lib/libusb/context.rb,
lib/libusb/setting.rb,
lib/libusb/endpoint.rb,
lib/libusb/transfer.rb,
lib/libusb/constants.rb,
lib/libusb/interface.rb,
lib/libusb/dev_handle.rb,
lib/libusb/gem_helper.rb,
lib/libusb/version_gem.rb,
lib/libusb/dependencies.rb,
lib/libusb/eventmachine.rb,
lib/libusb/ss_companion.rb,
lib/libusb/configuration.rb,
lib/libusb/libusb_recipe.rb,
lib/libusb/version_struct.rb

Overview

This file is part of Libusb for Ruby.

Libusb for Ruby is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Libusb for Ruby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with Libusb for Ruby. If not, see <www.gnu.org/licenses/>.

Defined Under Namespace

Modules: Call, Stdio Classes: Bos, BulkStreamTransfer, BulkTransfer, Configuration, Context, ControlTransfer, CrossLibrary, DevHandle, Device, Endpoint, Error, GemHelper, Interface, InterruptTransfer, IsoPacket, IsochronousTransfer, LibusbRecipe, Setting, SsCompanion, Transfer, Version

Constant Summary collapse

CONTROL_SETUP_SIZE =
8
DT_DEVICE_SIZE =
18
DT_CONFIG_SIZE =
9
DT_INTERFACE_SIZE =
9
DT_ENDPOINT_SIZE =
7
DT_ENDPOINT_AUDIO_SIZE =

Audio extension

9
DT_HUB_NONVAR_SIZE =
7
ENDPOINT_ADDRESS_MASK =

in bEndpointAddress

0x0f
ENDPOINT_DIR_MASK =
0x80
TRANSFER_TYPE_MASK =

in bmAttributes

0x03
ISO_SYNC_TYPE_MASK =
0x0C
ISO_USAGE_TYPE_MASK =
0x30
POLLIN =
1
POLLOUT =
4
HOTPLUG_MATCH_ANY =

Wildcard matching for hotplug events.

-1
VERSION =

Library version of libusb for Ruby

"0.6.4"
LIBUSB_VERSION =
ENV['LIBUSB_VERSION'] || '1.0.22'
LIBUSB_SOURCE_URI =
"https://github.com/libusb/libusb/releases/download/v#{LIBUSB_VERSION}/libusb-#{LIBUSB_VERSION}.tar.bz2"
LIBUSB_SOURCE_SHA1 =
'10116aa265aac4273a0c894faa089370262ec0dc'
MINI_PORTILE_VERSION =
'~> 2.1'

Class Method Summary collapse

Class Method Details

.dev_string(base_class, sub_class, protocol) ⇒ Object



155
156
157
158
159
160
161
162
163
164
165
# File 'lib/libusb/constants.rb', line 155

def self.dev_string(base_class, sub_class, protocol)
  if desc = CLASS_CODES_HASH3[[base_class, sub_class, protocol]]
    desc
  elsif desc = CLASS_CODES_HASH2[[base_class, sub_class]]
    desc + " (%02x)" % [protocol]
  elsif desc = CLASS_CODES_HASH1[base_class]
    desc + " (%02x,%02x)" % [sub_class, protocol]
  else
    "Unknown(%02x,%02x,%02x)" % [base_class, sub_class, protocol]
  end
end

.has_capability?(capability) ⇒ Boolean

Check at runtime if the loaded library has a given capability. Available since libusb-1.0.9.

Parameters:

  • capability (Symbol)

    the Capabilities symbol to check for

Returns:

  • (Boolean)

    true if the running library has the capability, false otherwise



49
50
51
52
# File 'lib/libusb.rb', line 49

def self.has_capability?(capability)
  r = Call.libusb_has_capability(capability)
  return r != 0
end

.raise_error(res, text) ⇒ Object

Raises:

  • (klass)


66
67
68
69
# File 'lib/libusb/constants.rb', line 66

def self.raise_error(res, text)
  klass = ErrorClassForResult[res]
  raise klass, "#{klass} #{text}"
end

.versionVersion

Get version of the underlying libusb library. Available since libusb-1.0.10.

Returns:



39
40
41
# File 'lib/libusb.rb', line 39

def self.version
  Version.new(Call.libusb_get_version)
end