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,
lib/libusb/context_reference.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 http://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, RemainingReferencesError, 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
- DEVICE_STRING_BYTES_MAX =
The maximum length for a device string descriptor in UTF-8.
255 max descriptor length with 2 byte header => 253 bytes UTF-16LE, no null termination (USB 2.0 9.6.7) => 126.5 codepoints => 126 * 3 + 1 => 382 bytes
Stay with 256 * 2/3 = 384 to be safe.
384- VERSION =
Library version of libusb for Ruby
"0.8.0"- LIBUSB_VERSION =
ENV['LIBUSB_VERSION'] || '1.0.30'
- LIBUSB_SOURCE_URI =
"https://github.com/libusb/libusb/releases/download/v#{LIBUSB_VERSION}/libusb-#{LIBUSB_VERSION}.tar.bz2"- LIBUSB_SOURCE_SHA256 =
'fea36f34f9156400209595e300840767ab1a385ede1dc7ee893015aea9c6dbaf'- MINI_PORTILE_VERSION =
'~> 2.1'
Class Method Summary collapse
Instance Method Summary collapse
-
#has_capability?(capability) ⇒ Boolean
Check at runtime if the loaded library has a given capability.
-
#set_option(option, *args) ⇒ Object
Set an default option in the libusb library.
-
#set_options(options = {}) ⇒ Object
Convenience function to set default options in the libusb library.
-
#version ⇒ Version
Get version of the underlying libusb library.
Class Method Details
.dev_string(base_class, sub_class, protocol) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/libusb/constants.rb', line 170 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 |
.raise_error(res, text) ⇒ Object
71 72 73 74 |
# File 'lib/libusb/constants.rb', line 71 def self.raise_error(res, text) klass = ErrorClassForResult[res] raise klass, "#{klass} #{text}" end |
Instance Method Details
#has_capability?(capability) ⇒ Boolean
Check at runtime if the loaded library has a given capability. Available since libusb-1.0.9.
51 52 53 54 |
# File 'lib/libusb.rb', line 51 def has_capability?(capability) r = Call.libusb_has_capability(capability) return r != 0 end |
#set_option(option, *args) ⇒ Object
Set an default option in the libusb library.
Use this function to configure a specific option within the library. See option list.
Some options require one or more arguments to be provided. Consult each option's documentation for specific requirements.
The option will be added to a list of default options that will be applied to all subsequently created contexts.
Available since libusb-1.0.22, LIBUSB_API_VERSION >= 0x01000106
Available since libusb-1.0.22
123 124 125 126 127 |
# File 'lib/libusb.rb', line 123 def set_option(option, *args) ffi_args = option_args_to_ffi(option, args, self) res = Call.libusb_set_option(nil, option, *ffi_args) LIBUSB.raise_error res, "in libusb_set_option" if res<0 end |
#set_options(options = {}) ⇒ Object
Convenience function to set default options in the libusb library.
Use this function to configure any number of options within the library. It takes a Hash the same way as given to LIBUSB::Context#initialize. See also option list.
Available since libusb-1.0.22, LIBUSB_API_VERSION >= 0x01000106
139 140 141 142 143 |
# File 'lib/libusb.rb', line 139 def (={}) .each do |k, v| set_option(k, *Array(v)) end end |