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, SsplusSublinkAttribute, SsplusUsbDeviceCapability, 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.
408 409 410 411 412 413 |
# File 'lib/libusb/bos.rb', line 408 def initialize(ctx, *args) @ctx = ctx super(*args) register_context(ctx, :libusb_free_bos_descriptor) end |
Instance Method Details
#bDescriptorType ⇒ Integer
in this context.
428 429 430 |
# File 'lib/libusb/bos.rb', line 428 def bDescriptorType self[:bDescriptorType] end |
#bLength ⇒ Integer
Returns Size of this descriptor (in bytes).
422 423 424 |
# File 'lib/libusb/bos.rb', line 422 def bLength self[:bLength] end |
#bNumDeviceCaps ⇒ Integer
the BOS
439 440 441 |
# File 'lib/libusb/bos.rb', line 439 def bNumDeviceCaps self[:bNumDeviceCaps] end |
#device_capabilities ⇒ Array<Bos::DeviceCapability, Bos::Usb20Extension, Bos::SsUsbDeviceCapability, Bos::ContainerId>
bNumDeviceCap Device Capability Descriptors
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
# File 'lib/libusb/bos.rb', line 454 def device_capabilities caps = [] # Capabilities are appended to the bos header ptr = pointer + offset_of(:dev_capability) bNumDeviceCaps.times do cap = DeviceCapability.new self, ptr.read_pointer cap = case cap.bDevCapabilityType when LIBUSB::BT_WIRELESS_USB_DEVICE_CAPABILITY # no struct defined in libusb -> use generic DeviceCapability cap when LIBUSB::BT_USB_2_0_EXTENSION wrap_device_capability(cap, :libusb_get_usb_2_0_extension_descriptor, Usb20Extension) when LIBUSB::BT_SS_USB_DEVICE_CAPABILITY wrap_device_capability(cap, :libusb_get_ss_usb_device_capability_descriptor, SsUsbDeviceCapability) when LIBUSB::BT_SUPERSPEED_PLUS_CAPABILITY wrap_device_capability(cap, :libusb_get_ssplus_usb_device_capability_descriptor, SsplusUsbDeviceCapability) when LIBUSB::BT_CONTAINER_ID wrap_device_capability(cap, :libusb_get_container_id_descriptor, ContainerId) when LIBUSB::BT_PLATFORM_DESCRIPTOR wrap_device_capability(cap, :libusb_get_platform_descriptor, PlatformDescriptor) else # unknown capability -> use generic DeviceCapability cap end ptr += FFI.type_size(:pointer) caps << cap end caps end |
#device_capability_types ⇒ Array<Symbol>
Returns Types of Capabilities.
487 488 489 490 491 492 493 494 495 |
# File 'lib/libusb/bos.rb', line 487 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
497 498 499 |
# File 'lib/libusb/bos.rb', line 497 def inspect "\#<#{self.class} #{device_capability_types.join(", ")}>" end |
#wTotalLength ⇒ Integer
Returns Length of this descriptor and all of its sub descriptors.
433 434 435 |
# File 'lib/libusb/bos.rb', line 433 def wTotalLength self[:wTotalLength] end |