Class: LIBUSB::Setting
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- LIBUSB::Setting
- Includes:
- Comparable
- Defined in:
- lib/libusb/setting.rb
Instance Attribute Summary collapse
-
#interface ⇒ Interface
readonly
The interface this setting belongs to.
Instance Method Summary collapse
- #<=>(o) ⇒ Object
-
#bAlternateSetting ⇒ Object
Value used to select this alternate setting for this interface.
-
#bDescriptorType ⇒ Object
Descriptor type (0x04).
-
#bInterfaceClass ⇒ Object
USB-IF class code for this interface.
-
#bInterfaceNumber ⇒ Object
Number of the interface this setting belongs to.
-
#bInterfaceProtocol ⇒ Object
USB-IF protocol code for this interface, qualified by the #bInterfaceClass and #bInterfaceSubClass values.
-
#bInterfaceSubClass ⇒ Object
USB-IF subclass code for this interface, qualified by the #bInterfaceClass value.
-
#bLength ⇒ Object
Size of this descriptor (in bytes).
-
#bNumEndpoints ⇒ Object
Number of endpoints used by this interface (excluding the control endpoint).
-
#configuration ⇒ Object
The Configuration this Setting belongs to.
-
#description ⇒ Object
Return name of this interface as String.
-
#device ⇒ Object
The Device this Setting belongs to.
- #endpoints ⇒ Object
-
#extra ⇒ String
Extra descriptors.
-
#iInterface ⇒ Object
Index of string descriptor describing this interface.
-
#initialize(interface, *args) ⇒ Setting
constructor
A new instance of Setting.
- #inspect ⇒ Object
Constructor Details
#initialize(interface, *args) ⇒ Setting
Returns a new instance of Setting.
88 89 90 91 |
# File 'lib/libusb/setting.rb', line 88 def initialize(interface, *args) @interface = interface super(*args) end |
Instance Attribute Details
#interface ⇒ Interface (readonly)
Returns the interface this setting belongs to.
94 95 96 |
# File 'lib/libusb/setting.rb', line 94 def interface @interface end |
Instance Method Details
#<=>(o) ⇒ Object
125 126 127 128 129 130 |
# File 'lib/libusb/setting.rb', line 125 def <=>(o) t = interface<=>o.interface t = bInterfaceNumber<=>o.bInterfaceNumber if t==0 t = bAlternateSetting<=>o.bAlternateSetting if t==0 t end |
#bAlternateSetting ⇒ Object
Value used to select this alternate setting for this interface.
51 52 53 |
# File 'lib/libusb/setting.rb', line 51 def bAlternateSetting self[:bAlternateSetting] end |
#bDescriptorType ⇒ Object
Descriptor type (0x04)
41 42 43 |
# File 'lib/libusb/setting.rb', line 41 def bDescriptorType self[:bDescriptorType] end |
#bInterfaceClass ⇒ Object
USB-IF class code for this interface.
61 62 63 |
# File 'lib/libusb/setting.rb', line 61 def bInterfaceClass self[:bInterfaceClass] end |
#bInterfaceNumber ⇒ Object
Number of the interface this setting belongs to.
46 47 48 |
# File 'lib/libusb/setting.rb', line 46 def bInterfaceNumber self[:bInterfaceNumber] end |
#bInterfaceProtocol ⇒ Object
USB-IF protocol code for this interface, qualified by the #bInterfaceClass and #bInterfaceSubClass values.
71 72 73 |
# File 'lib/libusb/setting.rb', line 71 def bInterfaceProtocol self[:bInterfaceProtocol] end |
#bInterfaceSubClass ⇒ Object
USB-IF subclass code for this interface, qualified by the #bInterfaceClass value.
66 67 68 |
# File 'lib/libusb/setting.rb', line 66 def bInterfaceSubClass self[:bInterfaceSubClass] end |
#bLength ⇒ Object
Size of this descriptor (in bytes).
36 37 38 |
# File 'lib/libusb/setting.rb', line 36 def bLength self[:bLength] end |
#bNumEndpoints ⇒ Object
Number of endpoints used by this interface (excluding the control endpoint).
56 57 58 |
# File 'lib/libusb/setting.rb', line 56 def bNumEndpoints self[:bNumEndpoints] end |
#configuration ⇒ Object
The Configuration this Setting belongs to.
123 |
# File 'lib/libusb/setting.rb', line 123 def configuration() self.interface.configuration end |
#description ⇒ Object
Return name of this interface as String.
115 116 117 118 |
# File 'lib/libusb/setting.rb', line 115 def description return @description if defined? @description @description = device.try_string_descriptor_ascii(self.iInterface) end |
#device ⇒ Object
The Device this Setting belongs to.
121 |
# File 'lib/libusb/setting.rb', line 121 def device() self.interface.configuration.device end |
#endpoints ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/libusb/setting.rb', line 96 def endpoints ifs = [] self[:bNumEndpoints].times do |i| ifs << Endpoint.new(self, self[:endpoint] + i*Endpoint.size) end return ifs end |
#extra ⇒ String
Extra descriptors.
83 84 85 86 |
# File 'lib/libusb/setting.rb', line 83 def extra return if self[:extra].null? self[:extra].read_string(self[:extra_length]) end |
#iInterface ⇒ Object
Index of string descriptor describing this interface.
76 77 78 |
# File 'lib/libusb/setting.rb', line 76 def iInterface self[:iInterface] end |
#inspect ⇒ Object
104 105 106 107 108 109 110 111 112 |
# File 'lib/libusb/setting.rb', line 104 def inspect attrs = [] attrs << self.bAlternateSetting.to_s devclass = LIBUSB.dev_string(self.bInterfaceClass, self.bInterfaceSubClass, self.bInterfaceProtocol) attrs << devclass desc = self.description attrs << desc if desc != '?' "\#<#{self.class} #{attrs.join(' ')}>" end |