libusb 0.6.3-x86-linux → 0.6.4-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e1f2c472ad25b55a9f2ba96d54684c27819d8cb7
4
- data.tar.gz: bedbd380e3a8e13a0512d31dcb93fa01676fda51
2
+ SHA256:
3
+ metadata.gz: 15a52d7a1ac643527705294538db63129406824b96f07c32ce721f29c06a9982
4
+ data.tar.gz: a7232bd8e66a6fbc8e75fdb37d0310ba099e986ea00a4eebf4450bc3fe226a8d
5
5
  SHA512:
6
- metadata.gz: 15d2d2b106ea13f77d69723153497e73567784170ef8ede16863aa06814a642bfb659ed35b41c0b89ed26f24821844904b45343bfb531bbe164e127d3a42cd33
7
- data.tar.gz: 65301733327eb1c04777254af3a766c8e31192054e3252ce89db1d538b219aa6abb754aa98e2ace191b67a0a774140cd06d5077c4e89d2d674ef654e4231acca
6
+ metadata.gz: 2c05978d69511d175bace99bfe35dbad8087d6927e5cbfa155d1256505e72a1496a10e4af58ffb1fd76e1ea1a2031b0d3120b1aa90398a7d00be652ceebd7ba3
7
+ data.tar.gz: 0f17e243b03bea35d67605268a86db17e032a3ab6cd0234f3ef5cb85fef62998c9b9d6814e103654e62c88f2ac4dc60c5f1c8a175f8b59be2902eb161e00caac
@@ -3,17 +3,19 @@ sudo: false
3
3
  dist: trusty
4
4
  matrix:
5
5
  include:
6
- - rvm: 2.4.1
6
+ - rvm: ruby-head
7
+ env:
8
+ - RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
9
+ - rvm: 2.4.3
7
10
  env:
8
11
  - RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
9
- - rvm: 1.9.3
10
12
  - rvm: 2.0
11
13
  - rvm: 2.1
12
14
  - rvm: 2.2.5
13
15
  - rvm: 2.3.1
14
- - rvm: jruby-1.7
15
16
  - rvm: jruby-9.1.5.0
16
17
  - rvm: rbx-3
17
18
  allow_failures:
18
19
  - rvm: rbx-3
20
+ - rvm: ruby-head
19
21
  script: bundle exec rake travis
data/Gemfile CHANGED
@@ -9,3 +9,8 @@ group :test do
9
9
  end
10
10
 
11
11
  gem 'rake-compiler-dock', '~> 0.6.0'
12
+
13
+ # For some reason this is required in addition to the gemspec
14
+ # when 'bundle config force_ruby_platform true' is active:
15
+ gem 'ffi'
16
+ gem 'mini_portile2'
data/History.md CHANGED
@@ -1,3 +1,22 @@
1
+ 0.6.4 / 2018-05-05
2
+ ------------------
3
+
4
+ Added:
5
+ * New function Context#set_option.
6
+ It is also available when running libusb < 1.0.22 and calls libusb_set_debug() in this case.
7
+ * Add definition for SUPER_SPEED_PLUS.
8
+ * Linux: Use system libusb even when only library but no dev package is installed.
9
+ * Add Transfer#dev_handle and #timeout
10
+ * Use system libusb even when no development package is installed.
11
+ Means "libusb-1.0-0" is enough, no need for "libusb-dev" on Ubuntu.
12
+
13
+ Changed:
14
+ * Update libusb to 1.0.22
15
+
16
+ Deprecated:
17
+ * Deprecate Context#debug= analogous to libusb_set_debug in libusb-1.0.22.
18
+
19
+
1
20
  0.6.3 / 2017-08-20
2
21
  ------------------
3
22
  * Fix compat with FreeBSD. #24
data/README.md CHANGED
@@ -65,7 +65,7 @@ Prerequisites
65
65
  * Debian or Ubuntu:
66
66
 
67
67
  ```
68
- $ sudo apt-get install libusb-1.0-0-dev
68
+ $ sudo apt-get install libusb-1.0-0
69
69
  ```
70
70
  * MacOS: install with homebrew:
71
71
 
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ task :test=>:compile do
21
21
  sh "ruby -w -W2 -I. -Ilib -e \"#{Dir["test/test_*.rb"].map{|f| "require '#{f}';"}.join}\" -- -v"
22
22
  end
23
23
 
24
- travis_tests = %w[test_libusb_capability.rb test_libusb_structs.rb test_libusb_version.rb]
24
+ travis_tests = %w[test_libusb.rb test_libusb_structs.rb]
25
25
  task :travis=>:compile do
26
26
  sh "ruby -w -W2 -I. -Ilib -e \"#{travis_tests.map{|f| "require 'test/#{f}';"}.join}\" -- -v"
27
27
  end
@@ -2,6 +2,11 @@ init:
2
2
  - SET PATH=C:/Ruby%ruby_version%/bin;%PATH%
3
3
  - SET RAKEOPT=-rdevkit
4
4
  install:
5
+ - ps: |
6
+ if ($env:ruby_version -like "*head*") {
7
+ $(new-object net.webclient).DownloadFile("https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-$env:ruby_version.exe", "$pwd/ruby-setup.exe")
8
+ cmd /c ruby-setup.exe /verysilent /dir=C:/Ruby$env:ruby_version
9
+ }
5
10
  - ruby --version
6
11
  - gem --version
7
12
  - ps: |
@@ -10,6 +15,8 @@ install:
10
15
  $env:SSL_CERT_FILE = "$env:TMP/ca-bundle.crt"
11
16
  Write-Host "Using SSL CA list $env:SSL_CERT_FILE" -foreground Green
12
17
  }
18
+ - gem install bundler --conservative
19
+ - bundle config force_ruby_platform true
13
20
  - bundle install
14
21
  build_script:
15
22
  - bundle exec rake compile
@@ -17,21 +24,13 @@ test_script:
17
24
  - bundle exec rake travis
18
25
  environment:
19
26
  matrix:
20
- - ruby_version: "24-x64"
27
+ - ruby_version: "head-x64"
21
28
  - ruby_version: "200"
22
29
  BROKEN_SSL: true
23
- - ruby_version: "200-x64"
24
- BROKEN_SSL: true
25
- - ruby_version: "21"
26
- BROKEN_SSL: true
27
30
  - ruby_version: "21-x64"
28
31
  BROKEN_SSL: true
29
32
  - ruby_version: "22"
30
33
  BROKEN_SSL: true
31
- - ruby_version: "22-x64"
32
- BROKEN_SSL: true
33
- - ruby_version: "23"
34
- BROKEN_SSL: true
35
34
  - ruby_version: "23-x64"
36
35
  BROKEN_SSL: true
37
36
  - ruby_version: "24"
@@ -28,7 +28,7 @@ module LIBUSB
28
28
  prefix = FFI::Platform::LIBPREFIX.empty? ? 'lib' : FFI::Platform::LIBPREFIX
29
29
  bundled_dll = File.join(root_path, "lib/#{prefix}usb-1.0.#{ext}")
30
30
  bundled_dll_cygwin = File.join(root_path, "bin/#{prefix}usb-1.0.#{ext}")
31
- ffi_lib([bundled_dll, bundled_dll_cygwin, "#{prefix}usb-1.0", "#{prefix}usb"])
31
+ ffi_lib([bundled_dll, bundled_dll_cygwin, "#{prefix}usb-1.0.#{ext}.0", "#{prefix}usb-1.0", "#{prefix}usb"])
32
32
 
33
33
  ClassCodes = enum :libusb_class_code, [
34
34
  :CLASS_PER_INTERFACE, 0,
@@ -164,12 +164,21 @@ module LIBUSB
164
164
  :ISO_SYNC_TYPE_SYNC, 3,
165
165
  ]
166
166
 
167
+ # Speed codes. Indicates the speed at which the device is operating.
167
168
  Speeds = enum :libusb_speed, [
169
+ # The OS doesn't report or know the device speed.
168
170
  :SPEED_UNKNOWN, 0,
171
+ # The device is operating at low speed (1.5MBit/s).
169
172
  :SPEED_LOW, 1,
173
+ # The device is operating at full speed (12MBit/s).
170
174
  :SPEED_FULL, 2,
175
+ # The device is operating at high speed (480MBit/s).
171
176
  :SPEED_HIGH, 3,
177
+ # The device is operating at super speed (5000MBit/s).
172
178
  :SPEED_SUPER, 4,
179
+ # The device is operating at super speed plus (10000MBit/s).
180
+ # Available since libusb-1.0.22
181
+ :SPEED_SUPER_PLUS, 5,
173
182
  ]
174
183
 
175
184
  # Supported speeds (wSpeedSupported) bitfield. Indicates what
@@ -250,6 +259,56 @@ module LIBUSB
250
259
  :HOTPLUG_ENUMERATE, 1,
251
260
  ]
252
261
 
262
+ # Log message levels.
263
+ #
264
+ # - :LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
265
+ # - :LOG_LEVEL_ERROR (1) : error messages are printed to stderr
266
+ # - :LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
267
+ # - :LOG_LEVEL_INFO (3) : informational messages are printed to stderr
268
+ # - :LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stderr
269
+ LogLevels = enum :libusb_log_level, [
270
+ :LOG_LEVEL_NONE, 0,
271
+ :LOG_LEVEL_ERROR, 1,
272
+ :LOG_LEVEL_WARNING, 2,
273
+ :LOG_LEVEL_INFO, 3,
274
+ :LOG_LEVEL_DEBUG, 4,
275
+ ]
276
+
277
+ # Available option values for {Context#set_option}.
278
+ Options = enum :libusb_option, [
279
+ # Set the log message verbosity.
280
+ #
281
+ # The default level is :LOG_LEVEL_NONE, which means no messages are ever
282
+ # printed. If you choose to increase the message verbosity level, ensure
283
+ # that your application does not close the stderr file descriptor.
284
+ #
285
+ # You are advised to use level :LOG_LEVEL_WARNING. libusb is conservative
286
+ # with its message logging and most of the time, will only log messages that
287
+ # explain error conditions and other oddities. This will help you debug
288
+ # your software.
289
+ #
290
+ # If the +LIBUSB_DEBUG+ environment variable was set when libusb was
291
+ # initialized, this function does nothing: the message verbosity is fixed
292
+ # to the value in the environment variable.
293
+ #
294
+ # If libusb was compiled without any message logging, this function does
295
+ # nothing: you'll never get any messages.
296
+ #
297
+ # If libusb was compiled with verbose debug message logging, this function
298
+ # does nothing: you'll always get messages from all levels.
299
+ :OPTION_LOG_LEVEL,
300
+
301
+ # Use the UsbDk backend for a specific context, if available.
302
+ #
303
+ # This option should be set immediately after calling {Context.new}, otherwise
304
+ # unspecified behavior may occur.
305
+ #
306
+ # Only valid on Windows.
307
+ #
308
+ # Available since libusb-1.0.22.
309
+ :OPTION_USE_USBDK,
310
+ ]
311
+
253
312
  typedef :pointer, :libusb_context
254
313
  typedef :pointer, :libusb_device
255
314
  typedef :pointer, :libusb_device_handle
@@ -266,7 +325,8 @@ module LIBUSB
266
325
 
267
326
  attach_function 'libusb_init', [ :pointer ], :int
268
327
  attach_function 'libusb_exit', [ :pointer ], :void
269
- attach_function 'libusb_set_debug', [:pointer, :int], :void
328
+ attach_function 'libusb_set_debug', [:pointer, :libusb_log_level], :void
329
+ try_attach_function 'libusb_set_option', [:libusb_context, :libusb_option, :varargs], :int
270
330
  try_attach_function 'libusb_has_capability', [:libusb_capability], :int
271
331
 
272
332
  attach_function 'libusb_get_device_list', [:pointer, :pointer], :ssize_t
@@ -16,22 +16,28 @@
16
16
  require 'libusb/call'
17
17
 
18
18
  module LIBUSB
19
- Call::ClassCodes.to_h.each{|k,v| const_set(k,v) }
20
- Call::TransferTypes.to_h.each{|k,v| const_set(k,v) }
21
- Call::StandardRequests.to_h.each{|k,v| const_set(k,v) }
22
- Call::RequestTypes.to_h.each{|k,v| const_set(k,v) }
23
- Call::DescriptorTypes.to_h.each{|k,v| const_set(k,v) }
24
- Call::EndpointDirections.to_h.each{|k,v| const_set(k,v) }
25
- Call::RequestRecipients.to_h.each{|k,v| const_set(k,v) }
26
- Call::IsoSyncTypes.to_h.each{|k,v| const_set(k,v) }
27
- Call::Speeds.to_h.each{|k,v| const_set(k,v) }
28
- Call::Capabilities.to_h.each{|k,v| const_set(k,v) }
29
- Call::SupportedSpeeds.to_h.each{|k,v| const_set(k,v) }
30
- Call::Usb20ExtensionAttributes.to_h.each{|k,v| const_set(k,v) }
31
- Call::SsUsbDeviceCapabilityAttributes.to_h.each{|k,v| const_set(k,v) }
32
- Call::BosTypes.to_h.each{|k,v| const_set(k,v) }
33
- Call::HotplugEvents.to_h.each{|k,v| const_set(k,v) }
34
- Call::HotplugFlags.to_h.each{|k,v| const_set(k,v) }
19
+ [
20
+ Call::ClassCodes,
21
+ Call::TransferTypes,
22
+ Call::StandardRequests,
23
+ Call::RequestTypes,
24
+ Call::DescriptorTypes,
25
+ Call::EndpointDirections,
26
+ Call::RequestRecipients,
27
+ Call::IsoSyncTypes,
28
+ Call::Speeds,
29
+ Call::Capabilities,
30
+ Call::SupportedSpeeds,
31
+ Call::Usb20ExtensionAttributes,
32
+ Call::SsUsbDeviceCapabilityAttributes,
33
+ Call::BosTypes,
34
+ Call::HotplugEvents,
35
+ Call::HotplugFlags,
36
+ Call::LogLevels,
37
+ Call::Options,
38
+ ].each do |enum|
39
+ enum.to_h.each{|k,v| const_set(k,v) }
40
+ end
35
41
 
36
42
  # Base class of libusb errors
37
43
  class Error < RuntimeError
@@ -114,37 +114,46 @@ module LIBUSB
114
114
  Call.libusb_exit(@ctx)
115
115
  end
116
116
 
117
- # Set message verbosity.
118
- #
119
- # * Level 0: no messages ever printed by the library (default)
120
- # * Level 1: error messages are printed to stderr
121
- # * Level 2: warning and error messages are printed to stderr
122
- # * Level 3: informational messages are printed to stdout, warning and
123
- # error messages are printed to stderr
124
- #
125
- # The default level is 0, which means no messages are ever printed. If you
126
- # choose to increase the message verbosity level, ensure that your
127
- # application does not close the stdout/stderr file descriptors.
128
- #
129
- # You are advised to set level 3. libusb is conservative with its message
130
- # logging and most of the time, will only log messages that explain error
131
- # conditions and other oddities. This will help you debug your software.
132
- #
133
- # If the LIBUSB_DEBUG environment variable was set when libusb was
134
- # initialized, this method does nothing: the message verbosity is
135
- # fixed to the value in the environment variable.
136
- #
137
- # If libusb was compiled without any message logging, this method
138
- # does nothing: you'll never get any messages.
139
- #
140
- # If libusb was compiled with verbose debug message logging, this
141
- # method does nothing: you'll always get messages from all levels.
142
- #
143
- # @param [Fixnum] level debug level to set
117
+ # @deprecated Use {Context#set_option} instead using the +:OPTION_LOG_LEVEL+ option.
144
118
  def debug=(level)
145
119
  Call.libusb_set_debug(@ctx, level)
146
120
  end
147
121
 
122
+ def expect_option_args(exp, is)
123
+ raise ArgumentError, "wrong number of arguments (given #{is+1}, expected #{exp+1})" if is != exp
124
+ end
125
+ private :expect_option_args
126
+
127
+ # Set a libusb option from the {Call::Options option list}.
128
+ #
129
+ # @param [Symbol, Fixnum] option
130
+ # @param args Zero or more arguments depending on +option+
131
+ def set_option(option, *args)
132
+ if Call.respond_to?(:libusb_set_option)
133
+ # Available since libusb-1.0.22
134
+
135
+ ffi_args = case option
136
+ when :OPTION_LOG_LEVEL, LIBUSB::OPTION_LOG_LEVEL
137
+ expect_option_args(1, args.length)
138
+ [:libusb_log_level, args[0]]
139
+ when :OPTION_USE_USBDK, LIBUSB::OPTION_USE_USBDK
140
+ expect_option_args(0, args.length)
141
+ []
142
+ else
143
+ raise ArgumentError, "unknown option #{option.inspect}"
144
+ end
145
+
146
+ res = Call.libusb_set_option(@ctx, option, *ffi_args)
147
+ LIBUSB.raise_error res, "in libusb_set_option" if res<0
148
+
149
+ else
150
+ # Fallback to deprecated function, if the gem is linked to an older libusb.
151
+
152
+ raise ArgumentError, "unknown option #{option.inspect}" unless [:OPTION_LOG_LEVEL, LIBUSB::OPTION_LOG_LEVEL].include?(option)
153
+ Call.libusb_set_debug(@ctx, *args)
154
+ end
155
+ end
156
+
148
157
  def device_list
149
158
  pppDevs = FFI::MemoryPointer.new :pointer
150
159
  size = Call.libusb_get_device_list(@ctx, pppDevs)
@@ -1,7 +1,7 @@
1
1
  module LIBUSB
2
- LIBUSB_VERSION = ENV['LIBUSB_VERSION'] || '1.0.21'
2
+ LIBUSB_VERSION = ENV['LIBUSB_VERSION'] || '1.0.22'
3
3
  LIBUSB_SOURCE_URI = "https://github.com/libusb/libusb/releases/download/v#{LIBUSB_VERSION}/libusb-#{LIBUSB_VERSION}.tar.bz2"
4
- LIBUSB_SOURCE_SHA1 = '54d71841542eb1a6f0b0420878a4d5434efe8d28'
4
+ LIBUSB_SOURCE_SHA1 = '10116aa265aac4273a0c894faa089370262ec0dc'
5
5
 
6
6
  MINI_PORTILE_VERSION = '~> 2.1'
7
7
  end
@@ -43,10 +43,15 @@ module LIBUSB
43
43
  end
44
44
  end
45
45
 
46
+ class << self
47
+ private :new
48
+ end
49
+
46
50
  def initialize(args={})
47
51
  @buffer = nil
48
52
  @completion_flag = Context::CompletionFlag.new
49
53
  @allow_device_memory = false
54
+ @dev_handle = nil
50
55
  args.each{|k,v| send("#{k}=", v) }
51
56
  end
52
57
  private :initialize
@@ -57,13 +62,23 @@ module LIBUSB
57
62
  @transfer[:dev_handle] = @dev_handle.pHandle
58
63
  end
59
64
 
60
- # Timeout for this transfer in millseconds.
65
+ # The handle for the device to communicate with.
66
+ attr_reader :dev_handle
67
+
68
+ # Set timeout for this transfer in millseconds.
61
69
  #
62
70
  # A value of 0 indicates no timeout.
63
71
  def timeout=(value)
64
72
  @transfer[:timeout] = value
65
73
  end
66
74
 
75
+ # Get timeout for this transfer in millseconds.
76
+ #
77
+ # A value of 0 indicates no timeout.
78
+ def timeout
79
+ @transfer[:timeout]
80
+ end
81
+
67
82
  # Set the address of a valid endpoint to communicate with.
68
83
  def endpoint=(endpoint)
69
84
  endpoint = endpoint.bEndpointAddress if endpoint.respond_to? :bEndpointAddress
@@ -225,6 +240,8 @@ module LIBUSB
225
240
  #
226
241
  # Inspect {#status} to check for transfer errors.
227
242
  def submit_and_wait
243
+ raise ArgumentError, "#{self.class}#dev_handle not set" unless @dev_handle
244
+
228
245
  @completion_flag.completed = false
229
246
  submit! do |tr2|
230
247
  @completion_flag.completed = true
@@ -256,6 +273,10 @@ module LIBUSB
256
273
  end
257
274
 
258
275
  class BulkTransfer < Transfer
276
+ def self.new(*)
277
+ super
278
+ end
279
+
259
280
  def initialize(args={})
260
281
  @transfer = Call::Transfer.new Call.libusb_alloc_transfer(0)
261
282
  @transfer[:type] = TRANSFER_TYPE_BULK
@@ -272,6 +293,10 @@ module LIBUSB
272
293
  #
273
294
  # Available since libusb-1.0.19.
274
295
  class BulkStreamTransfer < Transfer
296
+ def self.new(*)
297
+ super
298
+ end
299
+
275
300
  def initialize(args={})
276
301
  @transfer = Call::Transfer.new Call.libusb_alloc_transfer(0)
277
302
  @transfer[:type] = TRANSFER_TYPE_BULK_STREAM
@@ -299,6 +324,10 @@ module LIBUSB
299
324
  end
300
325
 
301
326
  class ControlTransfer < Transfer
327
+ def self.new(*)
328
+ super
329
+ end
330
+
302
331
  def initialize(args={})
303
332
  @transfer = Call::Transfer.new Call.libusb_alloc_transfer(0)
304
333
  @transfer[:type] = TRANSFER_TYPE_CONTROL
@@ -308,6 +337,10 @@ module LIBUSB
308
337
  end
309
338
 
310
339
  class InterruptTransfer < Transfer
340
+ def self.new(*)
341
+ super
342
+ end
343
+
311
344
  def initialize(args={})
312
345
  @transfer = Call::Transfer.new Call.libusb_alloc_transfer(0)
313
346
  @transfer[:type] = TRANSFER_TYPE_INTERRUPT
@@ -339,6 +372,10 @@ module LIBUSB
339
372
  end
340
373
 
341
374
  class IsochronousTransfer < Transfer
375
+ def self.new(*)
376
+ super
377
+ end
378
+
342
379
  def initialize(num_packets, args={})
343
380
  @ptr = Call.libusb_alloc_transfer(num_packets)
344
381
  @transfer = Call::Transfer.new @ptr
@@ -15,5 +15,5 @@
15
15
 
16
16
  module LIBUSB
17
17
  # Library version of libusb for Ruby
18
- VERSION = "0.6.3"
18
+ VERSION = "0.6.4"
19
19
  end
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
  s.extensions = ['ext/extconf.rb']
23
+ s.metadata["yard.run"] = "yri"
23
24
 
24
25
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
25
26
  s.add_runtime_dependency 'ffi', '~> 1.0'
@@ -27,4 +28,5 @@ Gem::Specification.new do |s|
27
28
  s.add_development_dependency 'rake-compiler', '~> 1.0'
28
29
  s.add_development_dependency 'rake-compiler-dock', '~> 0.2'
29
30
  s.add_development_dependency 'bundler', '~> 1.0'
31
+ s.add_development_dependency 'yard', '~> 0.6'
30
32
  end
@@ -16,22 +16,24 @@
16
16
  require "minitest/autorun"
17
17
  require "libusb"
18
18
 
19
- class TestLibusbVersion < Minitest::Test
20
- def setup
21
- @v = LIBUSB.version
19
+ class TestLibusb < Minitest::Test
20
+ def test_has_capability
21
+ assert LIBUSB.has_capability?(:CAP_HAS_CAPABILITY)
22
22
  end
23
23
 
24
24
  def test_version_parts
25
- assert_operator @v.major, :>=, 0
26
- assert_operator @v.minor, :>=, 0
27
- assert_operator @v.micro, :>=, 0
28
- assert_operator @v.nano, :>=, 0
29
- assert_kind_of String, @v.rc
25
+ v = LIBUSB.version
26
+ assert_operator v.major, :>=, 0
27
+ assert_operator v.minor, :>=, 0
28
+ assert_operator v.micro, :>=, 0
29
+ assert_operator v.nano, :>=, 0
30
+ assert_kind_of String, v.rc
30
31
  end
31
32
 
32
33
  def test_version_string
33
- assert_match(/^\d+\.\d+\.\d+/, @v.to_s)
34
- assert_match(/^#<LIBUSB::Version \d+\.\d+\.\d+/, @v.inspect)
34
+ v = LIBUSB.version
35
+ assert_match(/^\d+\.\d+\.\d+/, v.to_s)
36
+ assert_match(/^#<LIBUSB::Version \d+\.\d+\.\d+/, v.inspect)
35
37
  end
36
38
 
37
39
  def test_gem_version_string
@@ -16,8 +16,26 @@
16
16
  require "minitest/autorun"
17
17
  require "libusb"
18
18
 
19
- class TestLibusbCapability < Minitest::Test
20
- def test_version_parts
21
- assert LIBUSB.has_capability?(:CAP_HAS_CAPABILITY)
19
+ class TestLibusbContext < Minitest::Test
20
+ def setup
21
+ @c = LIBUSB::Context.new
22
+ end
23
+
24
+ def teardown
25
+ @c.exit if @c
26
+ end
27
+
28
+ def test_set_option
29
+ @c.set_option LIBUSB::OPTION_LOG_LEVEL, LIBUSB::LOG_LEVEL_NONE
30
+ @c.set_option LIBUSB::OPTION_LOG_LEVEL, LIBUSB::LOG_LEVEL_ERROR
31
+ @c.set_option LIBUSB::OPTION_LOG_LEVEL, LIBUSB::LOG_LEVEL_WARNING
32
+ @c.set_option LIBUSB::OPTION_LOG_LEVEL, LIBUSB::LOG_LEVEL_INFO
33
+ @c.set_option LIBUSB::OPTION_LOG_LEVEL, LIBUSB::LOG_LEVEL_DEBUG
34
+ @c.set_option :OPTION_LOG_LEVEL, :LOG_LEVEL_NONE
35
+ end
36
+
37
+ def test_set_debug
38
+ @c.debug = 4
39
+ @c.debug = 0
22
40
  end
23
41
  end
@@ -43,16 +43,45 @@ class TestLibusbStructs < Minitest::Test
43
43
  assert_equal 0, s[:completed]
44
44
  end
45
45
 
46
- def test_Transfer
46
+ def test_Transfer_buffer
47
47
  t = LIBUSB::InterruptTransfer.new allow_device_memory: true
48
48
  assert_equal :TRANSFER_COMPLETED, t.status
49
49
  assert_equal true, t.allow_device_memory
50
- assert_equal nil, t.memory_type
50
+ assert_nil t.memory_type
51
51
 
52
52
  t.alloc_buffer(10)
53
53
  assert_equal :user_space, t.memory_type, "no device assigned -> should use memory from user space"
54
54
 
55
55
  t.free_buffer
56
- assert_equal nil, t.memory_type
56
+ assert_nil t.memory_type
57
+ end
58
+
59
+ def test_Transfer_new
60
+ assert_raises(NoMethodError){ LIBUSB::Transfer.new }
61
+ LIBUSB::BulkStreamTransfer.new
62
+ LIBUSB::BulkTransfer.new
63
+ LIBUSB::ControlTransfer.new
64
+ LIBUSB::InterruptTransfer.new
65
+ LIBUSB::IsochronousTransfer.new(0)
66
+ end
67
+
68
+ def test_ControlTransfer_attributes
69
+ t = LIBUSB::ControlTransfer.new
70
+ t.timeout = 123
71
+ assert_equal 123, t.timeout
72
+ t.allow_device_memory = true
73
+ assert_equal true, t.allow_device_memory
74
+ assert_nil t.dev_handle
75
+ end
76
+
77
+ def test_ControlTransfer_new_args
78
+ t = LIBUSB::ControlTransfer.new allow_device_memory: false, timeout: 444
79
+ assert_equal false, t.allow_device_memory
80
+ assert_equal 444, t.timeout
81
+ end
82
+
83
+ def test_Transfer_no_dev_handle
84
+ t = LIBUSB::ControlTransfer.new
85
+ assert_raises(ArgumentError){ t.submit_and_wait }
57
86
  end
58
87
  end
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.3
4
+ version: 0.6.4
5
5
  platform: x86-linux
6
6
  authors:
7
7
  - Lars Kanis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-20 00:00:00.000000000 Z
11
+ date: 2018-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
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'
69
83
  description: LIBUSB is a Ruby binding that gives Ruby programmers access to arbitrary
70
84
  USB devices
71
85
  email:
@@ -106,11 +120,12 @@ files:
106
120
  - lib/libusb/version_gem.rb
107
121
  - lib/libusb/version_struct.rb
108
122
  - libusb.gemspec
123
+ - test/test_libusb.rb
109
124
  - test/test_libusb_bos.rb
110
125
  - test/test_libusb_bulk_stream_transfer.rb
111
- - test/test_libusb_capability.rb
112
126
  - test/test_libusb_compat.rb
113
127
  - test/test_libusb_compat_mass_storage.rb
128
+ - test/test_libusb_context.rb
114
129
  - test/test_libusb_descriptors.rb
115
130
  - test/test_libusb_event_machine.rb
116
131
  - test/test_libusb_gc.rb
@@ -120,12 +135,12 @@ files:
120
135
  - test/test_libusb_mass_storage2.rb
121
136
  - test/test_libusb_structs.rb
122
137
  - test/test_libusb_threads.rb
123
- - test/test_libusb_version.rb
124
138
  - wireshark-usb-sniffer.png
125
139
  homepage: http://github.com/larskanis/libusb
126
140
  licenses:
127
141
  - LGPL-3.0
128
- metadata: {}
142
+ metadata:
143
+ yard.run: yri
129
144
  post_install_message:
130
145
  rdoc_options:
131
146
  - "--main"
@@ -145,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
160
  version: '0'
146
161
  requirements: []
147
162
  rubyforge_project:
148
- rubygems_version: 2.6.12
163
+ rubygems_version: 2.7.3
149
164
  signing_key:
150
165
  specification_version: 4
151
166
  summary: Access USB devices from Ruby via libusb-1.0