libusb 0.6.4-x64-mingw32 → 0.7.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,13 +19,21 @@ module LIBUSB
19
19
  # A structure representing the superspeed endpoint companion descriptor.
20
20
  #
21
21
  # This descriptor is documented in section 9.6.7 of the USB 3.0 specification. All multiple-byte fields are represented in host-endian format.
22
- class SsCompanion < FFI::ManagedStruct
22
+ class SsCompanion < FFI::Struct
23
+ include ContextReference
24
+
23
25
  layout :bLength, :uint8,
24
26
  :bDescriptorType, :uint8,
25
27
  :bMaxBurst, :uint8,
26
28
  :bmAttributes, :uint8,
27
29
  :wBytesPerInterval, :uint16
28
30
 
31
+ def initialize(ctx, *args)
32
+ super(*args)
33
+
34
+ register_context(ctx, :libusb_free_ss_endpoint_companion_descriptor)
35
+ end
36
+
29
37
  # Size of this descriptor (in bytes)
30
38
  def bLength
31
39
  self[:bLength]
@@ -60,10 +68,5 @@ module LIBUSB
60
68
  def inspect
61
69
  "\#<#{self.class} burst: #{bMaxBurst} attrs: #{bmAttributes}>"
62
70
  end
63
-
64
- # @private
65
- def self.release(ptr)
66
- Call.libusb_free_ss_endpoint_companion_descriptor(ptr)
67
- end
68
71
  end
69
72
  end
@@ -28,16 +28,16 @@ module LIBUSB
28
28
  class ZeroCopyMemory < FFI::Pointer
29
29
  attr_reader :size
30
30
 
31
- def initialize(dev_handle, ptr, size)
32
- @dev_handle = dev_handle
31
+ def initialize(pDevhandle, ptr, size)
32
+ @pDevhandle = pDevhandle
33
33
  @size = size
34
34
  super(ptr)
35
35
  end
36
36
 
37
37
  def free(id=nil)
38
+ # puts format("libusb_dev_mem_free(%#x, %d)%s", address, @size||0, id ? " by GC" : '')
38
39
  return unless @size
39
- # puts format("libusb_dev_mem_free(%#x, %d)%s", address, @size, id ? " by GC" : '')
40
- res = Call.libusb_dev_mem_free( @dev_handle.pHandle, self, @size )
40
+ res = Call.libusb_dev_mem_free( @pDevhandle, self, @size )
41
41
  LIBUSB.raise_error res, "in libusb_dev_mem_free" if res!=0
42
42
  @size = nil
43
43
  end
@@ -60,6 +60,10 @@ module LIBUSB
60
60
  def dev_handle=(dev)
61
61
  @dev_handle = dev
62
62
  @transfer[:dev_handle] = @dev_handle.pHandle
63
+ # Now that the transfer is bound to a DevHandle, it must be registered in the Context.
64
+ # This ensures that the Call::Transfer is freed before libusb_exit, avoiding warnings about still referenced devices.
65
+ ctx = dev.device.context.instance_variable_get(:@ctx)
66
+ @transfer.pointer.instance_variable_set(:@ctx, ctx.ref_context)
63
67
  end
64
68
 
65
69
  # The handle for the device to communicate with.
@@ -163,7 +167,7 @@ module LIBUSB
163
167
  ptr = Call.libusb_dev_mem_alloc( @dev_handle.pHandle, len )
164
168
  # puts format("libusb_dev_mem_alloc(%d) => %#x", len, ptr.address)
165
169
  unless ptr.null?
166
- buffer = ZeroCopyMemory.new(@dev_handle, ptr, len)
170
+ buffer = ZeroCopyMemory.new(@dev_handle.pHandle, ptr, len)
167
171
  ObjectSpace.define_finalizer(self, buffer.method(:free))
168
172
  end
169
173
  end
@@ -252,7 +256,7 @@ module LIBUSB
252
256
  @dev_handle.device.context.handle_events nil, @completion_flag
253
257
  rescue ERROR_INTERRUPTED
254
258
  next
255
- rescue LIBUSB::Error
259
+ rescue Exception
256
260
  cancel!
257
261
  until @completion_flag.completed?
258
262
  @dev_handle.device.context.handle_events nil, @completion_flag
@@ -15,5 +15,5 @@
15
15
 
16
16
  module LIBUSB
17
17
  # Library version of libusb for Ruby
18
- VERSION = "0.6.4"
18
+ VERSION = "0.7.1"
19
19
  end
data/lib/libusb-1.0.dll CHANGED
Binary file
data/lib/libusb.rb CHANGED
@@ -20,6 +20,7 @@ module LIBUSB
20
20
  autoload :VERSION, 'libusb/version_gem'
21
21
  autoload :Version, 'libusb/version_struct'
22
22
  autoload :Configuration, 'libusb/configuration'
23
+ autoload :ContextReference, 'libusb/context_reference'
23
24
  autoload :DevHandle, 'libusb/dev_handle'
24
25
  autoload :Device, 'libusb/device'
25
26
  autoload :Endpoint, 'libusb/endpoint'
@@ -32,27 +33,114 @@ module LIBUSB
32
33
  autoload klass, 'libusb/transfer'
33
34
  end
34
35
 
35
- if Call.respond_to?(:libusb_get_version)
36
- # Get version of the underlying libusb library.
37
- # Available since libusb-1.0.10.
38
- # @return [Version] version object
39
- def self.version
40
- Version.new(Call.libusb_get_version)
36
+ class << self
37
+ if Call.respond_to?(:libusb_get_version)
38
+ # Get version of the underlying libusb library.
39
+ # Available since libusb-1.0.10.
40
+ # @return [Version] version object
41
+ def version
42
+ Version.new(Call.libusb_get_version)
43
+ end
44
+ end
45
+
46
+ if Call.respond_to?(:libusb_has_capability)
47
+ # Check at runtime if the loaded library has a given capability.
48
+ # Available since libusb-1.0.9.
49
+ # @param [Symbol] capability the {Call::Capabilities Capabilities} symbol to check for
50
+ # @return [Boolean] +true+ if the running library has the capability, +false+ otherwise
51
+ def has_capability?(capability)
52
+ r = Call.libusb_has_capability(capability)
53
+ return r != 0
54
+ end
55
+ else
56
+ def has_capability?(capability)
57
+ false
58
+ end
59
+ end
60
+
61
+ private def expect_option_args(exp, is)
62
+ raise ArgumentError, "wrong number of arguments (given #{is+1}, expected #{exp+1})" if is != exp
41
63
  end
42
- end
43
64
 
44
- if Call.respond_to?(:libusb_has_capability)
45
- # Check at runtime if the loaded library has a given capability.
46
- # Available since libusb-1.0.9.
47
- # @param [Symbol] capability the {Call::Capabilities Capabilities} symbol to check for
48
- # @return [Boolean] +true+ if the running library has the capability, +false+ otherwise
49
- def self.has_capability?(capability)
50
- r = Call.libusb_has_capability(capability)
51
- return r != 0
65
+ private def wrap_log_cb(block, mode)
66
+ if block
67
+ cb_proc = proc do |p_ctx, lev, str|
68
+ ctx = case p_ctx
69
+ when FFI::Pointer::NULL then nil
70
+ else p_ctx.to_i
71
+ end
72
+ block.call(ctx, lev, str)
73
+ end
74
+ end
75
+
76
+ # Avoid garbage collection of the proc, since only the function pointer is given to libusb
77
+ if Call::LogCbMode.to_native(mode, nil) & LOG_CB_GLOBAL != 0
78
+ @log_cb_global_proc = cb_proc
79
+ end
80
+ if Call::LogCbMode.to_native(mode, nil) & LOG_CB_CONTEXT != 0
81
+ @log_cb_context_proc = cb_proc
82
+ end
83
+ cb_proc
84
+ end
85
+
86
+ private def option_args_to_ffi(option, args, ctx)
87
+ case option
88
+ when :OPTION_LOG_LEVEL, LIBUSB::OPTION_LOG_LEVEL
89
+ expect_option_args(1, args.length)
90
+ [:libusb_log_level, args[0]]
91
+ when :OPTION_USE_USBDK, LIBUSB::OPTION_USE_USBDK
92
+ expect_option_args(0, args.length)
93
+ []
94
+ when :OPTION_NO_DEVICE_DISCOVERY, LIBUSB::OPTION_NO_DEVICE_DISCOVERY
95
+ expect_option_args(0, args.length)
96
+ []
97
+ when :OPTION_LOG_CB, LIBUSB::OPTION_LOG_CB
98
+ expect_option_args(1, args.length)
99
+ cb_proc = ctx.send(:wrap_log_cb, args[0], LOG_CB_CONTEXT)
100
+ [:libusb_log_cb, cb_proc]
101
+ else
102
+ raise ArgumentError, "unknown option #{option.inspect}"
103
+ end
52
104
  end
53
- else
54
- def self.has_capability?(capability)
55
- false
105
+
106
+ if Call.respond_to?(:libusb_set_option)
107
+ # Set an default option in the libusb library.
108
+ #
109
+ # Use this function to configure a specific option within the library.
110
+ # See {Call::Options option list}.
111
+ #
112
+ # Some options require one or more arguments to be provided.
113
+ # Consult each option's documentation for specific requirements.
114
+ #
115
+ # The option will be added to a list of default options that will be applied to all subsequently created contexts.
116
+ #
117
+ # Available since libusb-1.0.22, LIBUSB_API_VERSION >= 0x01000106
118
+ #
119
+ # @param [Symbol, Fixnum] option
120
+ # @param args Zero or more arguments depending on +option+
121
+ #
122
+ # Available since libusb-1.0.22
123
+ def set_option(option, *args)
124
+ ffi_args = option_args_to_ffi(option, args, self)
125
+ res = Call.libusb_set_option(nil, option, *ffi_args)
126
+ LIBUSB.raise_error res, "in libusb_set_option" if res<0
127
+ end
128
+
129
+ # Convenience function to set default options in the libusb library.
130
+ #
131
+ # Use this function to configure any number of options within the library.
132
+ # It takes a Hash the same way as given to {Context.initialize}.
133
+ # See also {Call::Options option list}.
134
+ #
135
+ # Available since libusb-1.0.22, LIBUSB_API_VERSION >= 0x01000106
136
+ #
137
+ # @param [Hash{Call::Options => Object}] options Option hash
138
+ # @see set_option
139
+ def set_options(options={})
140
+ options.each do |k, v|
141
+ set_option(k, *Array(v))
142
+ end
143
+ end
56
144
  end
57
145
  end
58
146
  end
data/libusb.gemspec CHANGED
@@ -22,11 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.extensions = ['ext/extconf.rb']
23
23
  s.metadata["yard.run"] = "yri"
24
24
 
25
- s.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
25
+ s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
26
26
  s.add_runtime_dependency 'ffi', '~> 1.0'
27
27
  s.add_runtime_dependency 'mini_portile2', LIBUSB::MINI_PORTILE_VERSION
28
- s.add_development_dependency 'rake-compiler', '~> 1.0'
29
- s.add_development_dependency 'rake-compiler-dock', '~> 0.2'
30
- s.add_development_dependency 'bundler', '~> 1.0'
31
- s.add_development_dependency 'yard', '~> 0.6'
32
28
  end
@@ -53,6 +53,23 @@ class TestLibusbBos < Minitest::Test
53
53
  :BT_USB_2_0_EXTENSION,
54
54
  :BT_SS_USB_DEVICE_CAPABILITY,
55
55
  :BT_CONTAINER_ID,
56
+ :BT_WIRELESS_USB_DEVICE_CAPABILITY,
57
+ :BT_USB_2_0_EXTENSION,
58
+ :BT_SS_USB_DEVICE_CAPABILITY,
59
+ :BT_CONTAINER_ID,
60
+ :BT_PLATFORM_DESCRIPTOR,
61
+ :BT_POWER_DELIVERY_CAPABILITY,
62
+ :BT_BATTERY_INFO_CAPABILITY,
63
+ :BT_PD_CONSUMER_PORT_CAPABILITY,
64
+ :BT_PD_PROVIDER_PORT_CAPABILITY,
65
+ :BT_SUPERSPEED_PLUS,
66
+ :BT_PRECISION_TIME_MEASUREMENT,
67
+ :BT_Wireless_USB_Ext,
68
+ :BT_BILLBOARD,
69
+ :BT_AUTHENTICATION,
70
+ :BT_BILLBOARD_EX,
71
+ :BT_CONFIGURATION_SUMMARY,
72
+ :BT_FWStatus_Capability,
56
73
  ], :include?, cap_type
57
74
  end
58
75
 
@@ -90,6 +107,11 @@ class TestLibusbBos < Minitest::Test
90
107
  assert_operator 0, :<=, cap.bReserved
91
108
  assert_operator 16, :==, cap.container_id.bytesize, "container_id should be 16 bytes long"
92
109
 
110
+ when Bos::PlatformDescriptor
111
+ assert_operator 0, :<=, cap.bReserved
112
+ assert_operator 16, :==, cap.platformCapabilityUUID.bytesize, "container_id should be 16 bytes long"
113
+ assert_kind_of String, cap.capabilityData
114
+
93
115
  else
94
116
  refute true, "invalid device capability class"
95
117
  end
@@ -21,11 +21,18 @@ class TestLibusbBulkStreamTransfer < Minitest::Test
21
21
 
22
22
  def setup
23
23
  c = Context.new
24
- begin
25
- @dev = c.devices.first.open
26
- rescue LIBUSB::ERROR_ACCESS
27
- @dev = nil
28
- skip "error opening device"
24
+ c.devices.each do |dev|
25
+ if [:SPEED_SUPER, :SPEED_SUPER_PLUS].include?(dev.device_speed)
26
+ dev.endpoints.each do |ep|
27
+ if ep.transfer_type == :bulk
28
+ ss = ep.ss_companion
29
+ if ss.bmAttributes & 0x1f > 0
30
+ @dev = dev.open
31
+ break
32
+ end
33
+ end
34
+ end
35
+ end
29
36
  end
30
37
  end
31
38
 
@@ -34,17 +41,21 @@ class TestLibusbBulkStreamTransfer < Minitest::Test
34
41
  end
35
42
 
36
43
  def test_alloc_streams
37
- assert_raises(ERROR_NOT_SUPPORTED, "TODO: test with a OS that supports bulk streams and against a real device") do
38
- nr_allocated = @dev.alloc_streams( 2, @dev.device.endpoints )
39
- end
44
+ skip "no device found with bulk stream support" unless @dev
40
45
 
41
- assert_raises(ERROR_NOT_SUPPORTED) do
42
- @dev.free_streams( [0x01,0x82] )
43
- end
46
+ nr_allocated = @dev.alloc_streams( 2, @dev.device.endpoints )
47
+ assert_equal 2, nr_allocated
48
+
49
+ # TODO: test with a OS that supports bulk streams and against a real device
50
+
51
+ @dev.free_streams( [0x01,0x82] )
44
52
  end
45
53
 
46
54
  def test_bulk_stream_transfer
47
- tr = BulkStreamTransfer.new dev_handle: @dev, stream_id: 123, buffer: ' '*100
55
+ c = Context.new
56
+ dev = c.devices.first.open
57
+ tr = BulkStreamTransfer.new dev_handle: dev, stream_id: 123, buffer: ' '*100
48
58
  assert_equal 123, tr.stream_id, "stream_id should match"
59
+ dev.close
49
60
  end
50
61
  end
@@ -38,4 +38,51 @@ class TestLibusbContext < Minitest::Test
38
38
  @c.debug = 4
39
39
  @c.debug = 0
40
40
  end
41
+
42
+ def test_left_references
43
+ @test_devs = @c.devices
44
+ assert_raises(LIBUSB::RemainingReferencesError) do
45
+ @c.exit
46
+ end
47
+ @c = nil
48
+ end
49
+
50
+ def test_double_exit
51
+ @c.exit
52
+ end
53
+
54
+ def test_log_callback
55
+ skip "only supported on Linux" unless RUBY_PLATFORM=~/linux/
56
+ skip "libusb version older than 1.0.27" if Gem::Version.new(LIBUSB.version) < Gem::Version.new("1.0.27")
57
+
58
+ LIBUSB.set_options OPTION_LOG_CB: [nil], OPTION_LOG_LEVEL: LIBUSB::LOG_LEVEL_NONE
59
+ begin
60
+ called = Hash.new { |h, k| h[k] = [] }
61
+ LIBUSB.set_options OPTION_LOG_CB: proc{|*a| called[:global] << a }, OPTION_LOG_LEVEL: LIBUSB::LOG_LEVEL_DEBUG
62
+
63
+ c = LIBUSB::Context.new OPTION_LOG_CB: proc{|*a| called[:ctx1] << a }, OPTION_NO_DEVICE_DISCOVERY: nil
64
+ c.devices
65
+ c.set_log_cb(LIBUSB::LOG_CB_CONTEXT){|*a| called[:ctx2] << a }
66
+ c.devices
67
+
68
+ #pp called
69
+ assert_nil called[:global][0][0]
70
+ assert_equal :LOG_LEVEL_DEBUG, called[:global][0][1], called[:global][0][2]
71
+ assert_match(/libusb_init_context/, called[:global].join)
72
+ assert_match(/no device discovery/, called[:global].join)
73
+
74
+ assert_operator called[:ctx1].size, :>, called[:ctx2].size
75
+ assert_equal c, called[:ctx1][-1][0]
76
+ assert_equal :LOG_LEVEL_DEBUG, called[:ctx1][-1][1]
77
+ assert_match(/libusb_get_device_list/, called[:ctx1][-1][2])
78
+ assert_match(/no device discovery/, called[:ctx1].join)
79
+
80
+ assert_equal c, called[:ctx2][-1][0]
81
+ assert_equal :LOG_LEVEL_DEBUG, called[:ctx2][-1][1]
82
+ assert_match(/libusb_get_device_list/, called[:ctx2][-1][2])
83
+
84
+ ensure
85
+ LIBUSB.set_options OPTION_LOG_CB: [nil], OPTION_LOG_LEVEL: LIBUSB::LOG_LEVEL_NONE
86
+ end
87
+ end
41
88
  end
@@ -119,7 +119,7 @@ class TestLibusbDescriptors < Minitest::Test
119
119
 
120
120
  usb.devices.each do |dev|
121
121
  dev.endpoints.each do |ep|
122
- if dev.device_speed == :SPEED_SUPER
122
+ if [:SPEED_SUPER, :SPEED_SUPER_PLUS].include?(dev.device_speed)
123
123
  ss = ep.ss_companion
124
124
  assert_match(/SsCompanion/, ss.inspect, "SsCompanion#inspect should work")
125
125
 
@@ -172,14 +172,19 @@ class TestLibusbDescriptors < Minitest::Test
172
172
  def test_device_filter_hubs
173
173
  devs1 = []
174
174
  usb.devices.each do |dev|
175
- dev.settings.each do |if_desc|
176
- if if_desc.bInterfaceClass == CLASS_HUB
177
- devs1 << dev
175
+ if dev.bDeviceClass==CLASS_PER_INTERFACE
176
+ dev.settings.each do |if_desc|
177
+ if if_desc.bInterfaceClass==CLASS_HUB
178
+ devs1 << dev
179
+ end
178
180
  end
181
+ else
182
+ devs1 << dev if dev.bDeviceClass == CLASS_HUB
179
183
  end
180
184
  end
181
185
 
182
186
  devs2 = usb.devices( bClass: CLASS_HUB )
187
+
183
188
  assert_equal devs1.sort, devs2.sort, "devices and devices with filter should deliver the same device"
184
189
  end
185
190
 
@@ -189,11 +194,11 @@ class TestLibusbDescriptors < Minitest::Test
189
194
  if ep
190
195
  assert_operator dev.max_packet_size(ep), :>, 0, "#{dev.inspect} should have a usable packet size"
191
196
  assert_operator dev.max_packet_size(ep.bEndpointAddress), :>, 0, "#{dev.inspect} should have a usable packet size"
192
- assert_operator dev.max_iso_packet_size(ep), :>, 0, "#{dev.inspect} should have a usable iso packet size"
193
- assert_operator dev.max_iso_packet_size(ep.bEndpointAddress), :>, 0, "#{dev.inspect} should have a usable iso packet size"
197
+ assert_operator dev.max_iso_packet_size(ep), :>=, 0, "#{dev.inspect} should have a usable iso packet size"
198
+ assert_operator dev.max_iso_packet_size(ep.bEndpointAddress), :>=, 0, "#{dev.inspect} should have a usable iso packet size"
194
199
  assert_operator dev.bus_number, :>=, 0, "#{dev.inspect} should have a bus_number"
195
200
  assert_operator dev.device_address, :>=, 0, "#{dev.inspect} should have a device_address"
196
- assert_operator([:SPEED_UNKNOWN, :SPEED_LOW, :SPEED_FULL, :SPEED_HIGH, :SPEED_SUPER], :include?, dev.device_speed, "#{dev.inspect} should have a device_speed")
201
+ assert_operator([:SPEED_UNKNOWN, :SPEED_LOW, :SPEED_FULL, :SPEED_HIGH, :SPEED_SUPER, :SPEED_SUPER_PLUS], :include?, dev.device_speed, "#{dev.inspect} should have a device_speed")
197
202
  path = dev.port_numbers
198
203
  assert_kind_of Array, path, "#{dev.inspect} should have port_numbers"
199
204
  path = dev.port_path
@@ -201,12 +206,40 @@ class TestLibusbDescriptors < Minitest::Test
201
206
  path.each do |port|
202
207
  assert_operator port, :>, 0, "#{dev.inspect} should have proper port_path entries"
203
208
  end
204
- assert_equal path[-1], dev.port_number, "#{dev.inspect} should have a port number out of the port_path"
205
- if parent=dev.parent
206
- assert_kind_of Device, parent, "#{dev.inspect} should have a parent"
207
- assert_equal path[-2], parent.port_number, "#{dev.inspect} should have a parent port number out of the port_path"
209
+ if path.empty?
210
+ assert_nil dev.port_number
211
+ else
212
+ assert_equal path[-1], dev.port_number, "#{dev.inspect} should have a port number out of the port_path"
213
+ if parent=dev.parent
214
+ assert_kind_of Device, parent, "#{dev.inspect} should have a parent"
215
+ assert_equal path[-2], parent.port_number, "#{dev.inspect} should have a parent port number out of the port_path" if parent.port_number
216
+ end
208
217
  end
209
218
  end
210
219
  end
211
220
  end
221
+
222
+ def test_wrap_sys_device
223
+ skip unless RUBY_PLATFORM =~ /linux/
224
+ d = usb.devices[0]
225
+ File.open(format("/dev/bus/usb/%03d/%03d", d.bus_number, d.device_address), "w+") do |io|
226
+ devh = usb.wrap_sys_device(io)
227
+ devh.kernel_driver_active?(0)
228
+ devh.close
229
+
230
+ usb.wrap_sys_device(io) do |devh|
231
+ devh.kernel_driver_active?(0)
232
+ end
233
+ end
234
+ end
235
+
236
+ def test_wrap_sys_device_failure
237
+ skip unless RUBY_PLATFORM =~ /linux/
238
+ d = usb.devices[0]
239
+ assert_raises(LIBUSB::ERROR_OTHER) do
240
+ File.open(format("/dev/bus/usb/%03d/%03d", d.bus_number, d.device_address), "r") do |io|
241
+ usb.wrap_sys_device(io).kernel_driver_active?(0)
242
+ end
243
+ end
244
+ end
212
245
  end
@@ -34,4 +34,19 @@ class TestLibusbGc < Minitest::Test
34
34
  GC.start
35
35
  assert_equal ps, ep.wMaxPacketSize, "GC should not free EndpointDescriptor"
36
36
  end
37
+
38
+ def test_log_cb
39
+ LIBUSB.set_options OPTION_LOG_CB: proc{}, OPTION_LOG_LEVEL: LIBUSB::LOG_LEVEL_DEBUG
40
+
41
+ c = LIBUSB::Context.new OPTION_LOG_CB: proc{}, OPTION_NO_DEVICE_DISCOVERY: nil
42
+ GC.start
43
+ c.devices
44
+ c.set_log_cb(LIBUSB::LOG_CB_CONTEXT){}
45
+ c.devices
46
+ GC.start
47
+ c.devices
48
+
49
+ ensure
50
+ LIBUSB.set_options OPTION_LOG_CB: [nil], OPTION_LOG_LEVEL: LIBUSB::LOG_LEVEL_NONE
51
+ end
37
52
  end
@@ -26,7 +26,9 @@ class TestLibusbHotplug < Minitest::Test
26
26
  end
27
27
 
28
28
  def teardown
29
- @ctx.exit
29
+ # No need to release the LIBUSB::Context any longer.
30
+ # It is cleaned up by the GC.
31
+ # @ctx.exit
30
32
  end
31
33
 
32
34
  def test_enumerate
@@ -47,4 +47,10 @@ class TestLibusbIsoTransfer < Minitest::Test
47
47
  tr.submit!
48
48
  end
49
49
  end
50
+
51
+ def test_max_alt_packet_size
52
+ d = Context.new.devices[0]
53
+ size = d.max_alt_packet_size d.interfaces[0], d.settings[0], d.endpoints[0]
54
+ assert_operator 0, :<=, size
55
+ end
50
56
  end
@@ -61,7 +61,7 @@ class TestLibusbMassStorage < Minitest::Test
61
61
  dev.close if dev
62
62
  end
63
63
 
64
- def do_transfer(method, args)
64
+ def do_transfer(method, **args)
65
65
  if @asynchron
66
66
  stop = false
67
67
  transfer = dev.send(method, args) do |tr|
@@ -78,14 +78,14 @@ class TestLibusbMassStorage < Minitest::Test
78
78
  end
79
79
  transfer.result
80
80
  else
81
- dev.send(method, args)
81
+ dev.send(method, **args)
82
82
  end
83
83
  end
84
- def control_transfer(args)
85
- do_transfer(:control_transfer, args)
84
+ def control_transfer(**args)
85
+ do_transfer(:control_transfer, **args)
86
86
  end
87
- def bulk_transfer(args)
88
- do_transfer(:bulk_transfer, args)
87
+ def bulk_transfer(**args)
88
+ do_transfer(:bulk_transfer, **args)
89
89
  end
90
90
 
91
91
  def send_mass_storage_command(cdb, data_length, direction=ENDPOINT_IN)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libusb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.1
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Lars Kanis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-05 00:00:00.000000000 Z
11
+ date: 2024-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -24,62 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake-compiler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake-compiler-dock
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.2'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0.2'
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.0'
69
- - !ruby/object:Gem::Dependency
70
- name: yard
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.6'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.6'
83
27
  description: LIBUSB is a Ruby binding that gives Ruby programmers access to arbitrary
84
28
  USB devices
85
29
  email:
@@ -88,6 +32,8 @@ executables: []
88
32
  extensions: []
89
33
  extra_rdoc_files: []
90
34
  files:
35
+ - ".appveyor.yml"
36
+ - ".github/workflows/ci.yml"
91
37
  - ".gitignore"
92
38
  - ".travis.yml"
93
39
  - ".yardopts"
@@ -96,7 +42,6 @@ files:
96
42
  - History.md
97
43
  - README.md
98
44
  - Rakefile
99
- - appveyor.yml
100
45
  - lib/libusb-1.0.dll
101
46
  - lib/libusb.rb
102
47
  - lib/libusb/bos.rb
@@ -105,6 +50,7 @@ files:
105
50
  - lib/libusb/configuration.rb
106
51
  - lib/libusb/constants.rb
107
52
  - lib/libusb/context.rb
53
+ - lib/libusb/context_reference.rb
108
54
  - lib/libusb/dependencies.rb
109
55
  - lib/libusb/dev_handle.rb
110
56
  - lib/libusb/device.rb
@@ -152,15 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
98
  requirements:
153
99
  - - ">="
154
100
  - !ruby/object:Gem::Version
155
- version: 1.9.3
101
+ version: 2.5.0
156
102
  required_rubygems_version: !ruby/object:Gem::Requirement
157
103
  requirements:
158
104
  - - ">="
159
105
  - !ruby/object:Gem::Version
160
106
  version: '0'
161
107
  requirements: []
162
- rubyforge_project:
163
- rubygems_version: 2.7.3
108
+ rubygems_version: 3.3.26
164
109
  signing_key:
165
110
  specification_version: 4
166
111
  summary: Access USB devices from Ruby via libusb-1.0