Class: LIBUSB::Configuration
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- LIBUSB::Configuration
- Includes:
- Comparable
- Defined in:
- lib/libusb/configuration.rb
Instance Attribute Summary collapse
-
#device ⇒ Device
readonly
The device this configuration belongs to.
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.
-
#bMaxPower ⇒ Integer
(also: #maxPower)
Maximum power consumption of the USB device from this bus in this configuration when the device is fully opreation.
-
#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
- #remote_wakeup? ⇒ Boolean
- #self_powered? ⇒ Boolean
-
#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.
109 110 111 112 113 114 |
# File 'lib/libusb/configuration.rb', line 109 def initialize(device, *args) @device = device super(*args) register_context(device.context.instance_variable_get(:@ctx), :libusb_free_config_descriptor) end |
Instance Attribute Details
#device ⇒ Device (readonly)
Returns the device this configuration belongs to.
117 118 119 |
# File 'lib/libusb/configuration.rb', line 117 def device @device end |
Instance Method Details
#<=>(o) ⇒ Object
148 149 150 151 152 |
# File 'lib/libusb/configuration.rb', line 148 def <=>(o) t = device<=>o.device t = bConfigurationValue<=>o.bConfigurationValue if t==0 t end |
#bConfigurationValue ⇒ Object
Identifier value for this configuration.
56 57 58 |
# File 'lib/libusb/configuration.rb', line 56 def bConfigurationValue self[:bConfigurationValue] end |
#bDescriptorType ⇒ Object
Descriptor type (0x02)
41 42 43 |
# File 'lib/libusb/configuration.rb', line 41 def bDescriptorType self[:bDescriptorType] end |
#bLength ⇒ Object
Size of this descriptor (in bytes).
36 37 38 |
# File 'lib/libusb/configuration.rb', line 36 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.
76 77 78 |
# File 'lib/libusb/configuration.rb', line 76 def bmAttributes self[:bmAttributes] end |
#bMaxPower ⇒ Integer Also known as: maxPower
Maximum power consumption of the USB device from this bus in this configuration when the device is fully opreation.
93 94 95 |
# File 'lib/libusb/configuration.rb', line 93 def bMaxPower self[:bMaxPower] end |
#bNumInterfaces ⇒ Object
Number of interfaces supported by this configuration.
51 52 53 |
# File 'lib/libusb/configuration.rb', line 51 def bNumInterfaces self[:bNumInterfaces] end |
#description ⇒ Object
Return name of this configuration as String.
138 139 140 141 |
# File 'lib/libusb/configuration.rb', line 138 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.
146 |
# File 'lib/libusb/configuration.rb', line 146 def endpoints() self.settings.map {|d| d.endpoints }.flatten end |
#extra ⇒ String
Extra descriptors.
104 105 106 107 |
# File 'lib/libusb/configuration.rb', line 104 def extra return if self[:extra].null? self[:extra].read_string(self[:extra_length]) end |
#iConfiguration ⇒ Object
Index of string descriptor describing this configuration.
61 62 63 |
# File 'lib/libusb/configuration.rb', line 61 def iConfiguration self[:iConfiguration] end |
#inspect ⇒ Object
127 128 129 130 131 132 133 134 135 |
# File 'lib/libusb/configuration.rb', line 127 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 |
#interfaces ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/libusb/configuration.rb', line 119 def interfaces ifs = [] self[:bNumInterfaces].times do |i| ifs << Interface.new(self, self[:interface] + i*Interface.size) end return ifs end |
#remote_wakeup? ⇒ Boolean
86 87 88 |
# File 'lib/libusb/configuration.rb', line 86 def remote_wakeup? bmAttributes & 0b100000 != 0 end |
#self_powered? ⇒ Boolean
81 82 83 |
# File 'lib/libusb/configuration.rb', line 81 def self_powered? bmAttributes & 0b1000000 != 0 end |
#settings ⇒ Object
Return all interface decriptions of the configuration as Array of Settings.
144 |
# File 'lib/libusb/configuration.rb', line 144 def settings() self.interfaces.map {|d| d.settings }.flatten end |
#wTotalLength ⇒ Object
Total length of data returned for this configuration.
46 47 48 |
# File 'lib/libusb/configuration.rb', line 46 def wTotalLength self[:wTotalLength] end |