Class: LIBUSB::Configuration
- Inherits:
-
FFI::ManagedStruct
- Object
- FFI::ManagedStruct
- LIBUSB::Configuration
- Includes:
- Comparable
- Defined in:
- lib/libusb/configuration.rb
Instance Attribute Summary collapse
-
#device ⇒ Device
readonly
The device this configuration belongs to.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(o) ⇒ Object
-
#bConfigurationValue ⇒ Object
Identifier value for this configuration.
-
#bDescriptorType ⇒ Object
Descriptor type (0x02).
-
#bLength ⇒ Object
Size of this descriptor (in bytes).
-
#bmAttributes ⇒ Integer
Configuration characteristics.
-
#bNumInterfaces ⇒ Object
Number of interfaces supported by this configuration.
-
#description ⇒ Object
Return name of this configuration as String.
-
#endpoints ⇒ Object
Return all endpoints of all interfaces of the configuration as Array of Endpoints.
-
#extra ⇒ String
Extra descriptors.
-
#iConfiguration ⇒ Object
Index of string descriptor describing this configuration.
-
#initialize(device, *args) ⇒ Configuration
constructor
A new instance of Configuration.
- #inspect ⇒ Object
- #interfaces ⇒ Object
-
#maxPower ⇒ Integer
Maximum power consumption of the USB device from this bus in this configuration when the device is fully opreation.
-
#settings ⇒ Object
Return all interface decriptions of the configuration as Array of Settings.
-
#wTotalLength ⇒ Object
Total length of data returned for this configuration.
Constructor Details
#initialize(device, *args) ⇒ Configuration
Returns a new instance of Configuration.
91 92 93 94 |
# File 'lib/libusb/configuration.rb', line 91 def initialize(device, *args) @device = device super(*args) end |
Instance Attribute Details
#device ⇒ Device (readonly)
Returns the device this configuration belongs to.
101 102 103 |
# File 'lib/libusb/configuration.rb', line 101 def device @device end |
Class Method Details
.release(ptr) ⇒ Object
96 97 98 |
# File 'lib/libusb/configuration.rb', line 96 def self.release(ptr) Call.libusb_free_config_descriptor(ptr) end |
Instance Method Details
#<=>(o) ⇒ Object
133 134 135 136 137 |
# File 'lib/libusb/configuration.rb', line 133 def <=>(o) t = device<=>o.device t = bConfigurationValue<=>o.bConfigurationValue if t==0 t end |
#bConfigurationValue ⇒ Object
Identifier value for this configuration.
55 56 57 |
# File 'lib/libusb/configuration.rb', line 55 def bConfigurationValue self[:bConfigurationValue] end |
#bDescriptorType ⇒ Object
Descriptor type (0x02)
40 41 42 |
# File 'lib/libusb/configuration.rb', line 40 def bDescriptorType self[:bDescriptorType] end |
#bLength ⇒ Object
Size of this descriptor (in bytes).
35 36 37 |
# File 'lib/libusb/configuration.rb', line 35 def bLength self[:bLength] end |
#bmAttributes ⇒ Integer
Configuration characteristics.
- Bit 7: Reserved, set to 1. (USB 1.0 Bus Powered)
- Bit 6: Self Powered
- Bit 5: Remote Wakeup
- Bit 4..0: Reserved, set to 0.
72 73 74 |
# File 'lib/libusb/configuration.rb', line 72 def bmAttributes self[:bmAttributes] end |
#bNumInterfaces ⇒ Object
Number of interfaces supported by this configuration.
50 51 52 |
# File 'lib/libusb/configuration.rb', line 50 def bNumInterfaces self[:bNumInterfaces] end |
#description ⇒ Object
Return name of this configuration as String.
123 124 125 126 |
# File 'lib/libusb/configuration.rb', line 123 def description return @description if defined? @description @description = device.try_string_descriptor_ascii(self.iConfiguration) end |
#endpoints ⇒ Object
Return all endpoints of all interfaces of the configuration as Array of Endpoints.
131 |
# File 'lib/libusb/configuration.rb', line 131 def endpoints() self.settings.map {|d| d.endpoints }.flatten end |
#extra ⇒ String
Extra descriptors.
86 87 88 89 |
# File 'lib/libusb/configuration.rb', line 86 def extra return if self[:extra].null? self[:extra].read_string(self[:extra_length]) end |
#iConfiguration ⇒ Object
Index of string descriptor describing this configuration.
60 61 62 |
# File 'lib/libusb/configuration.rb', line 60 def iConfiguration self[:iConfiguration] end |
#inspect ⇒ Object
111 112 113 114 115 116 117 118 119 120 |
# File 'lib/libusb/configuration.rb', line 111 def inspect attrs = [] attrs << self.bConfigurationValue.to_s bits = self.bmAttributes attrs << "SelfPowered" if (bits & 0b1000000) != 0 attrs << "RemoteWakeup" if (bits & 0b100000) != 0 desc = self.description attrs << desc if desc != '?' "\#<#{self.class} #{attrs.join(' ')}>" end |
#interfaces ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/libusb/configuration.rb', line 103 def interfaces ifs = [] self[:bNumInterfaces].times do |i| ifs << Interface.new(self, self[:interface] + i*Interface.size) end return ifs end |
#maxPower ⇒ Integer
Maximum power consumption of the USB device from this bus in this configuration when the device is fully opreation.
79 80 81 |
# File 'lib/libusb/configuration.rb', line 79 def maxPower self[:maxPower] end |
#settings ⇒ Object
Return all interface decriptions of the configuration as Array of Settings.
129 |
# File 'lib/libusb/configuration.rb', line 129 def settings() self.interfaces.map {|d| d.settings }.flatten end |
#wTotalLength ⇒ Object
Total length of data returned for this configuration.
45 46 47 |
# File 'lib/libusb/configuration.rb', line 45 def wTotalLength self[:wTotalLength] end |