Class: LIBUSB::Endpoint
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- LIBUSB::Endpoint
- Includes:
- Comparable
- Defined in:
- lib/libusb/endpoint.rb
Constant Summary collapse
- TransferTypes =
[:control, :isochronous, :bulk, :interrupt]
- SynchronizationTypes =
[:no_synchronization, :asynchronous, :adaptive, :synchronous]
- UsageTypes =
[:data, :feedback, :implicit_feedback, :unknown]
Instance Attribute Summary collapse
-
#setting ⇒ Setting
readonly
The setting this endpoint belongs to.
Instance Method Summary collapse
- #<=>(o) ⇒ Object
-
#bDescriptorType ⇒ Object
Descriptor type (0x05).
-
#bEndpointAddress ⇒ Integer
The address of the endpoint described by this descriptor.
-
#bInterval ⇒ Object
Interval for polling endpoint data transfers.
-
#bLength ⇒ Object
Size of Descriptor in Bytes (7 bytes).
-
#bmAttributes ⇒ Integer
Attributes which apply to the endpoint when it is configured using the Configuration#bConfigurationValue.
-
#bRefresh ⇒ Object
For audio devices only: the rate at which synchronization feedback is provided.
-
#bSynchAddress ⇒ Object
For audio devices only: the address if the synch endpoint.
-
#configuration ⇒ Object
The Configuration this Endpoint belongs to.
-
#device ⇒ Object
The Device this Endpoint belongs to.
-
#direction ⇒ Symbol
Either
:in
or:out
. - #endpoint_number ⇒ Integer
-
#extra ⇒ String
Extra descriptors.
-
#initialize(setting, *args) ⇒ Endpoint
constructor
A new instance of Endpoint.
- #inspect ⇒ Object
-
#interface ⇒ Object
The Interface this Endpoint belongs to.
-
#ss_companion ⇒ SsCompanion
Get the endpoints superspeed endpoint companion descriptor (if any).
-
#synchronization_type ⇒ Symbol
One of SynchronizationTypes.
-
#transfer_type ⇒ Symbol
One of TransferTypes.
-
#usage_type ⇒ Symbol
One of UsageTypes.
-
#wMaxPacketSize ⇒ Object
Maximum Packet Size this endpoint is capable of sending or receiving.
Constructor Details
#initialize(setting, *args) ⇒ Endpoint
Returns a new instance of Endpoint.
148 149 150 151 |
# File 'lib/libusb/endpoint.rb', line 148 def initialize(setting, *args) @setting = setting super(*args) end |
Instance Attribute Details
#setting ⇒ Setting (readonly)
Returns the setting this endpoint belongs to.
154 155 156 |
# File 'lib/libusb/endpoint.rb', line 154 def setting @setting end |
Instance Method Details
#<=>(o) ⇒ Object
168 169 170 171 172 |
# File 'lib/libusb/endpoint.rb', line 168 def <=>(o) t = setting<=>o.setting t = bEndpointAddress<=>o.bEndpointAddress if t==0 t end |
#bDescriptorType ⇒ Object
Descriptor type (0x05)
39 40 41 |
# File 'lib/libusb/endpoint.rb', line 39 def bDescriptorType self[:bDescriptorType] end |
#bEndpointAddress ⇒ Integer
The address of the endpoint described by this descriptor.
-
Bits 0..3: Endpoint Number.
-
Bits 4..6: Reserved. Set to Zero
-
Bits 7: Direction 0 = Out, 1 = In (Ignored for Control Endpoints)
53 54 55 |
# File 'lib/libusb/endpoint.rb', line 53 def bEndpointAddress self[:bEndpointAddress] end |
#bInterval ⇒ Object
Interval for polling endpoint data transfers. Value in frame counts. Ignored for Bulk & Control Endpoints. Isochronous must equal 1 and field may range from 1 to 255 for interrupt endpoints.
The interval is respected by the kernel driver, so user mode processes using libusb don’t need to care about it.
126 127 128 |
# File 'lib/libusb/endpoint.rb', line 126 def bInterval self[:bInterval] end |
#bLength ⇒ Object
Size of Descriptor in Bytes (7 bytes)
34 35 36 |
# File 'lib/libusb/endpoint.rb', line 34 def bLength self[:bLength] end |
#bmAttributes ⇒ Integer
Attributes which apply to the endpoint when it is configured using the Configuration#bConfigurationValue.
-
Bits 1..0: Transfer Type
-
00 = Control
-
01 = Isochronous
-
10 = Bulk
-
11 = Interrupt
-
-
Bits 7..2: are reserved. If Isochronous endpoint,
-
Bits 3..2: Synchronisation Type (Iso Mode)
-
00 = No Synchonisation
-
01 = Asynchronous
-
10 = Adaptive
-
11 = Synchronous
-
-
Bits 5..4: Usage Type (Iso Mode)
-
00 = Data Endpoint
-
01 = Feedback Endpoint
-
10 = Explicit Feedback Data Endpoint
-
11 = Reserved
-
91 92 93 |
# File 'lib/libusb/endpoint.rb', line 91 def bmAttributes self[:bmAttributes] end |
#bRefresh ⇒ Object
For audio devices only: the rate at which synchronization feedback is provided.
131 132 133 |
# File 'lib/libusb/endpoint.rb', line 131 def bRefresh self[:bRefresh] end |
#bSynchAddress ⇒ Object
For audio devices only: the address if the synch endpoint.
136 137 138 |
# File 'lib/libusb/endpoint.rb', line 136 def bSynchAddress self[:bSynchAddress] end |
#configuration ⇒ Object
The Configuration this Endpoint belongs to.
164 |
# File 'lib/libusb/endpoint.rb', line 164 def configuration() self.setting.interface.configuration end |
#device ⇒ Object
The Device this Endpoint belongs to.
162 |
# File 'lib/libusb/endpoint.rb', line 162 def device() self.setting.interface.configuration.device end |
#direction ⇒ Symbol
Returns Either :in
or :out
.
63 64 65 |
# File 'lib/libusb/endpoint.rb', line 63 def direction bEndpointAddress & ENDPOINT_IN == 0 ? :out : :in end |
#endpoint_number ⇒ Integer
58 59 60 |
# File 'lib/libusb/endpoint.rb', line 58 def endpoint_number bEndpointAddress & 0b1111 end |
#extra ⇒ String
Extra descriptors.
143 144 145 146 |
# File 'lib/libusb/endpoint.rb', line 143 def extra return if self[:extra].null? self[:extra].read_string(self[:extra_length]) end |
#inspect ⇒ Object
156 157 158 159 |
# File 'lib/libusb/endpoint.rb', line 156 def inspect type = [transfer_type, synchronization_type, usage_type].compact "\#<#{self.class} #{endpoint_number} #{direction} #{type.join(" ")}>" end |
#interface ⇒ Object
The Interface this Endpoint belongs to.
166 |
# File 'lib/libusb/endpoint.rb', line 166 def interface() self.setting.interface end |
#ss_companion ⇒ SsCompanion
Get the endpoints superspeed endpoint companion descriptor (if any).
Since libusb version 1.0.16.
182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/libusb/endpoint.rb', line 182 def ss_companion ep_comp = FFI::MemoryPointer.new :pointer ctx = device.context.instance_variable_get(:@ctx) res = Call.libusb_get_ss_endpoint_companion_descriptor( ctx, pointer, ep_comp ) LIBUSB.raise_error res, "in libusb_get_ss_endpoint_companion_descriptor" if res!=0 SsCompanion.new ctx, ep_comp.read_pointer end |
#synchronization_type ⇒ Symbol
Returns One of SynchronizationTypes.
103 104 105 106 |
# File 'lib/libusb/endpoint.rb', line 103 def synchronization_type return unless transfer_type == :isochronous SynchronizationTypes[(bmAttributes & 0b1100) >> 2] end |
#transfer_type ⇒ Symbol
Returns One of TransferTypes.
97 98 99 |
# File 'lib/libusb/endpoint.rb', line 97 def transfer_type TransferTypes[bmAttributes & 0b11] end |
#usage_type ⇒ Symbol
Returns One of UsageTypes.
110 111 112 113 |
# File 'lib/libusb/endpoint.rb', line 110 def usage_type return unless transfer_type == :isochronous UsageTypes[(bmAttributes & 0b110000) >> 4] end |
#wMaxPacketSize ⇒ Object
Maximum Packet Size this endpoint is capable of sending or receiving
116 117 118 |
# File 'lib/libusb/endpoint.rb', line 116 def wMaxPacketSize self[:wMaxPacketSize] end |