Class: LIBUSB::Bos
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- LIBUSB::Bos
- Defined in:
- lib/libusb/bos.rb
Overview
A structure representing the Binary Device Object Store (BOS) descriptor. This descriptor is documented in section 9.6.2 of the USB 3.0 specification. All multiple-byte fields are represented in host-endian format.
Defined Under Namespace
Modules: GenericMethods Classes: ContainerId, DeviceCapability, PlatformDescriptor, SsUsbDeviceCapability, Usb20Extension
Instance Method Summary collapse
-
#bDescriptorType ⇒ Integer
in this context.
-
#bLength ⇒ Integer
Size of this descriptor (in bytes).
-
#bNumDeviceCaps ⇒ Integer
the BOS.
-
#device_capabilities ⇒ Array<Bos::DeviceCapability, Bos::Usb20Extension, Bos::SsUsbDeviceCapability, Bos::ContainerId>
bNumDeviceCap Device Capability Descriptors.
-
#device_capability_types ⇒ Array<Symbol>
Types of Capabilities.
-
#initialize(ctx, *args) ⇒ Bos
constructor
A new instance of Bos.
- #inspect ⇒ Object
-
#wTotalLength ⇒ Integer
Length of this descriptor and all of its sub descriptors.
Constructor Details
#initialize(ctx, *args) ⇒ Bos
Returns a new instance of Bos.
276 277 278 279 280 281 |
# File 'lib/libusb/bos.rb', line 276 def initialize(ctx, *args) @ctx = ctx super(*args) register_context(ctx, :libusb_free_bos_descriptor) end |
Instance Method Details
#bDescriptorType ⇒ Integer
in this context.
296 297 298 |
# File 'lib/libusb/bos.rb', line 296 def bDescriptorType self[:bDescriptorType] end |
#bLength ⇒ Integer
Returns Size of this descriptor (in bytes).
290 291 292 |
# File 'lib/libusb/bos.rb', line 290 def bLength self[:bLength] end |
#bNumDeviceCaps ⇒ Integer
the BOS
307 308 309 |
# File 'lib/libusb/bos.rb', line 307 def bNumDeviceCaps self[:bNumDeviceCaps] end |
#device_capabilities ⇒ Array<Bos::DeviceCapability, Bos::Usb20Extension, Bos::SsUsbDeviceCapability, Bos::ContainerId>
bNumDeviceCap Device Capability Descriptors
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/libusb/bos.rb', line 314 def device_capabilities pp_ext = FFI::MemoryPointer.new :pointer caps = [] # Capabilities are appended to the bos header ptr = pointer + offset_of(:dev_capability) bNumDeviceCaps.times do cap = DeviceCapability.new self, ptr.read_pointer case cap.bDevCapabilityType when LIBUSB::BT_WIRELESS_USB_DEVICE_CAPABILITY # no struct defined in libusb -> use generic DeviceCapability when LIBUSB::BT_USB_2_0_EXTENSION res = Call.libusb_get_usb_2_0_extension_descriptor(@ctx, cap.pointer, pp_ext) cap = Usb20Extension.new(@ctx, pp_ext.read_pointer) if res==0 when LIBUSB::BT_SS_USB_DEVICE_CAPABILITY res = Call.libusb_get_ss_usb_device_capability_descriptor(@ctx, cap.pointer, pp_ext) cap = SsUsbDeviceCapability.new(@ctx, pp_ext.read_pointer) if res==0 when LIBUSB::BT_CONTAINER_ID res = Call.libusb_get_container_id_descriptor(@ctx, cap.pointer, pp_ext) cap = ContainerId.new(@ctx, pp_ext.read_pointer) if res==0 when LIBUSB::BT_PLATFORM_DESCRIPTOR res = Call.libusb_get_platform_descriptor(@ctx, cap.pointer, pp_ext) cap = PlatformDescriptor.new(@ctx, pp_ext.read_pointer) if res==0 else # unknown capability -> use generic DeviceCapability end ptr += FFI.type_size(:pointer) caps << cap end caps end |
#device_capability_types ⇒ Array<Symbol>
Returns Types of Capabilities.
348 349 350 351 352 353 354 355 356 |
# File 'lib/libusb/bos.rb', line 348 def device_capability_types # Capabilities are appended to the bos header ptr = pointer + offset_of(:dev_capability) bNumDeviceCaps.times.map do cap = DeviceCapability.new self, ptr.read_pointer ptr += FFI.type_size(:pointer) Call::BosTypes.find cap.bDevCapabilityType end end |
#inspect ⇒ Object
358 359 360 |
# File 'lib/libusb/bos.rb', line 358 def inspect "\#<#{self.class} #{device_capability_types.join(", ")}>" end |
#wTotalLength ⇒ Integer
Returns Length of this descriptor and all of its sub descriptors.
301 302 303 |
# File 'lib/libusb/bos.rb', line 301 def wTotalLength self[:wTotalLength] end |