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)
- - (Object) <=>(o)
-
- (Object) bConfigurationValue
Identifier value for this configuration.
-
- (Object) bDescriptorType
Descriptor type (0x02).
-
- (Object) bLength
Size of this descriptor (in bytes).
-
- (Integer) bmAttributes
Configuration characteristics.
-
- (Integer) bMaxPower
(also: #maxPower)
Maximum power consumption of the USB device from this bus in this configuration when the device is fully opreation.
-
- (Object) bNumInterfaces
Number of interfaces supported by this configuration.
-
- (Object) description
Return name of this configuration as String.
-
- (Object) endpoints
Return all endpoints of all interfaces of the configuration as Array of Endpoints.
-
- (String) extra
Extra descriptors.
-
- (Object) iConfiguration
Index of string descriptor describing this configuration.
-
- (Configuration) initialize(device, *args)
constructor
A new instance of Configuration.
- - (Object) inspect
- - (Object) interfaces
- - (Boolean) remote_wakeup?
- - (Boolean) self_powered?
-
- (Object) settings
Return all interface decriptions of the configuration as Array of Settings.
-
- (Object) wTotalLength
Total length of data returned for this configuration.
Constructor Details
- (Configuration) initialize(device, *args)
A new instance of Configuration
108 109 110 111 |
# File 'lib/libusb/configuration.rb', line 108 def initialize(device, *args) @device = device super(*args) end |
Instance Attribute Details
- (Device) device (readonly)
The device this configuration belongs to.
118 119 120 |
# File 'lib/libusb/configuration.rb', line 118 def device @device end |
Class Method Details
+ (Object) release(ptr)
113 114 115 |
# File 'lib/libusb/configuration.rb', line 113 def self.release(ptr) Call.libusb_free_config_descriptor(ptr) end |
Instance Method Details
- (Object) <=>(o)
149 150 151 152 153 |
# File 'lib/libusb/configuration.rb', line 149 def <=>(o) t = device<=>o.device t = bConfigurationValue<=>o.bConfigurationValue if t==0 t end |
- (Object) bConfigurationValue
Identifier value for this configuration.
55 56 57 |
# File 'lib/libusb/configuration.rb', line 55 def bConfigurationValue self[:bConfigurationValue] end |
- (Object) bDescriptorType
Descriptor type (0x02)
40 41 42 |
# File 'lib/libusb/configuration.rb', line 40 def bDescriptorType self[:bDescriptorType] end |
- (Object) bLength
Size of this descriptor (in bytes).
35 36 37 |
# File 'lib/libusb/configuration.rb', line 35 def bLength self[:bLength] end |
- (Integer) bmAttributes
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.
75 76 77 |
# File 'lib/libusb/configuration.rb', line 75 def bmAttributes self[:bmAttributes] end |
- (Integer) bMaxPower Also known as: maxPower
Maximum power consumption of the USB device from this bus in this configuration when the device is fully opreation.
92 93 94 |
# File 'lib/libusb/configuration.rb', line 92 def bMaxPower self[:bMaxPower] end |
- (Object) bNumInterfaces
Number of interfaces supported by this configuration.
50 51 52 |
# File 'lib/libusb/configuration.rb', line 50 def bNumInterfaces self[:bNumInterfaces] end |
- (Object) description
Return name of this configuration as String.
139 140 141 142 |
# File 'lib/libusb/configuration.rb', line 139 def description return @description if defined? @description @description = device.try_string_descriptor_ascii(self.iConfiguration) end |
- (Object) endpoints
Return all endpoints of all interfaces of the configuration as Array of Endpoints.
147 |
# File 'lib/libusb/configuration.rb', line 147 def endpoints() self.settings.map {|d| d.endpoints }.flatten end |
- (String) extra
Extra descriptors.
103 104 105 106 |
# File 'lib/libusb/configuration.rb', line 103 def extra return if self[:extra].null? self[:extra].read_string(self[:extra_length]) end |
- (Object) iConfiguration
Index of string descriptor describing this configuration.
60 61 62 |
# File 'lib/libusb/configuration.rb', line 60 def iConfiguration self[:iConfiguration] end |
- (Object) inspect
128 129 130 131 132 133 134 135 136 |
# File 'lib/libusb/configuration.rb', line 128 def inspect attrs = [] attrs << self.bConfigurationValue.to_s attrs << "SelfPowered" if self_powered? attrs << "RemoteWakeup" if remote_wakeup? desc = self.description attrs << desc if desc != '?' "\#<#{self.class} #{attrs.join(' ')}>" end |
- (Object) interfaces
120 121 122 123 124 125 126 |
# File 'lib/libusb/configuration.rb', line 120 def interfaces ifs = [] self[:bNumInterfaces].times do |i| ifs << Interface.new(self, self[:interface] + i*Interface.size) end return ifs end |
- (Boolean) remote_wakeup?
85 86 87 |
# File 'lib/libusb/configuration.rb', line 85 def remote_wakeup? bmAttributes & 0b100000 != 0 end |
- (Boolean) self_powered?
80 81 82 |
# File 'lib/libusb/configuration.rb', line 80 def self_powered? bmAttributes & 0b1000000 != 0 end |
- (Object) settings
Return all interface decriptions of the configuration as Array of Settings.
145 |
# File 'lib/libusb/configuration.rb', line 145 def settings() self.interfaces.map {|d| d.settings }.flatten end |
- (Object) wTotalLength
Total length of data returned for this configuration.
45 46 47 |
# File 'lib/libusb/configuration.rb', line 45 def wTotalLength self[:wTotalLength] end |