libusb 0.2.0-x86-mingw32 → 0.2.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.2.1 / 2012-09-25
2
+
3
+ * Rename Configuration#maxPower to #bMaxPower as done in libusbx-1.0.13 and in ruby-usb.gem
4
+ * update to libusbx-1.0.13 for windows build (with support for libusbK and libusb0)
5
+
1
6
  === 0.2.0 / 2012-06-15
2
7
 
3
8
  * Divide up the libusb library across multiple files, required with autoload
data/Rakefile CHANGED
@@ -32,7 +32,7 @@ end
32
32
  # LIBUSB_TARBALL = STATIC_SOURCESDIR + "libusb-#{LIBUSB_VERSION}.tar.bz2"
33
33
 
34
34
  # Fetch tarball from libusbx
35
- LIBUSB_VERSION = ENV['LIBUSB_VERSION'] || '1.0.12'
35
+ LIBUSB_VERSION = ENV['LIBUSB_VERSION'] || '1.0.13'
36
36
  LIBUSB_SOURCE_URI = URI( "http://downloads.sourceforge.net/project/libusbx/releases/#{LIBUSB_VERSION[/^\d+\.\d+\.\d+/]}/source/libusbx-#{LIBUSB_VERSION}.tar.bz2" )
37
37
  LIBUSB_TARBALL = STATIC_SOURCESDIR + File.basename( LIBUSB_SOURCE_URI.path )
38
38
 
data/lib/libusb-1.0.dll CHANGED
Binary file
data/lib/libusb.rb CHANGED
@@ -14,7 +14,7 @@
14
14
  # along with Libusb for Ruby. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  module LIBUSB
17
- VERSION = "0.2.0"
17
+ VERSION = "0.2.1"
18
18
 
19
19
  require 'libusb/call'
20
20
  require 'libusb/constants'
data/lib/libusb/compat.rb CHANGED
@@ -175,7 +175,7 @@ module USB
175
175
  h = DevHandle.new(@dev.open)
176
176
  if block_given?
177
177
  begin
178
- r = yield h
178
+ yield h
179
179
  ensure
180
180
  h.usb_close
181
181
  end
@@ -200,7 +200,7 @@ module USB
200
200
  end
201
201
 
202
202
  def_delegators :@cd, :bLength, :bDescriptorType, :wTotalLength, :bNumInterfaces,
203
- :bConfigurationValue, :iConfiguration, :bmAttributes, :maxPower,
203
+ :bConfigurationValue, :iConfiguration, :bmAttributes, :bMaxPower,
204
204
  :inspect
205
205
 
206
206
  def <=>(o)
@@ -26,7 +26,7 @@ module LIBUSB
26
26
  :bConfigurationValue, :uint8,
27
27
  :iConfiguration, :uint8,
28
28
  :bmAttributes, :uint8,
29
- :maxPower, :uint8,
29
+ :bMaxPower, :uint8,
30
30
  :interface, :pointer,
31
31
  :extra, :pointer,
32
32
  :extra_length, :int
@@ -76,10 +76,14 @@ module LIBUSB
76
76
  # Maximum power consumption of the USB device from this bus in this configuration when the device is fully opreation.
77
77
  #
78
78
  # @return [Integer] Maximum Power Consumption in 2mA units
79
- def maxPower
80
- self[:maxPower]
79
+ def bMaxPower
80
+ self[:bMaxPower]
81
81
  end
82
82
 
83
+ # @deprecated Use {#bMaxPower} instead.
84
+ alias maxPower bMaxPower
85
+
86
+
83
87
  # Extra descriptors.
84
88
  #
85
89
  # @return [String]
@@ -56,7 +56,8 @@ class TestLibusbDescriptors < Test::Unit::TestCase
56
56
  assert_kind_of Integer, config_desc.bConfigurationValue
57
57
  assert_kind_of Integer, config_desc.iConfiguration
58
58
  assert_kind_of Integer, config_desc.bmAttributes
59
- assert_kind_of Integer, config_desc.maxPower
59
+ assert_kind_of Integer, config_desc.bMaxPower
60
+ assert_kind_of Integer, config_desc.maxPower # deprecated
60
61
  assert_kind_of String, config_desc.extra if config_desc.extra
61
62
 
62
63
  config_desc.interfaces.each do |interface|
@@ -0,0 +1,50 @@
1
+ # This test requires a connected, but not mounted mass storage device with
2
+ # read/write access allowed. Based on the following specifications:
3
+ # http://www.usb.org/developers/devclass_docs/usbmassbulk_10.pdf
4
+ # http://en.wikipedia.org/wiki/SCSI_command
5
+ #
6
+
7
+ require "test/unit"
8
+ require "libusb"
9
+
10
+ class TestLibusbKeyboard < Test::Unit::TestCase
11
+ include LIBUSB
12
+
13
+ attr_accessor :usb
14
+ attr_accessor :device
15
+ attr_accessor :dev
16
+ attr_accessor :endpoint_in
17
+ attr_accessor :endpoint_out
18
+
19
+ def setup
20
+ @usb = Context.new
21
+ @usb.debug = 3
22
+
23
+ @device = usb.devices( :bDeviceClass=>CLASS_HID, :bDeviceProtocol=>1 ).first
24
+ abort "no keyboard device found" unless @device
25
+
26
+ @endpoint_in = @device.endpoints.find{|ep| ep.bEndpointAddress&ENDPOINT_IN != 0 }.bEndpointAddress
27
+ @endpoint_out = @device.endpoints.find{|ep| ep.bEndpointAddress&ENDPOINT_IN == 0 }.bEndpointAddress
28
+
29
+ @dev = @device.open
30
+
31
+ if RUBY_PLATFORM=~/linux/i && dev.kernel_driver_active?(0)
32
+ dev.detach_kernel_driver(0)
33
+ end
34
+ dev.claim_interface(0)
35
+
36
+ # clear any pending data
37
+ dev.clear_halt(endpoint_in)
38
+ end
39
+
40
+ def teardown
41
+ dev.release_interface(0) if dev
42
+ dev.close if dev
43
+ end
44
+
45
+ def test_read
46
+ data_length = 8
47
+ recv = dev.interrupt_transfer(:endpoint=>endpoint_in, :dataIn=>data_length)
48
+ p recv
49
+ end
50
+ end
@@ -110,7 +110,7 @@ class TestLibusbMassStorage < Test::Unit::TestCase
110
110
  retries = 5
111
111
  buffer = begin
112
112
  bulk_transfer(:endpoint=>endpoint_in, :dataIn=>13)
113
- rescue LIBUSB::ERROR_PIPE => err
113
+ rescue LIBUSB::ERROR_PIPE
114
114
  if (retries-=1)>=0
115
115
  dev.clear_halt(endpoint_in)
116
116
  retry
@@ -122,6 +122,7 @@ class TestLibusbMassStorage < Test::Unit::TestCase
122
122
  dCSWSignature, dCSWTag, dCSWDataResidue, bCSWStatus = buffer.unpack('a4VVC')
123
123
 
124
124
  assert_equal 'USBS', dCSWSignature, "CSW should start with USBS"
125
+ assert_kind_of Integer, dCSWDataResidue
125
126
  assert_equal expected_tag, dCSWTag, "CSW-tag should be like CBW-tag"
126
127
  raise CSWError, "CSW returned error #{bCSWStatus}" unless bCSWStatus==0
127
128
  buffer
@@ -154,14 +155,14 @@ class TestLibusbMassStorage < Test::Unit::TestCase
154
155
  start, 0,
155
156
  nr_blocks, 0,
156
157
  ].pack('CCNCnC')
157
- data = send_mass_storage_command( cdb, expected_length )
158
+ send_mass_storage_command( cdb, expected_length )
158
159
  end
159
160
 
160
161
  def invalid_command
161
162
  expected_length = 0x100
162
163
  cdb = [ 0x26, 0, # invalid command
163
164
  ].pack('CC')
164
- data = send_mass_storage_command( cdb, expected_length )
165
+ send_mass_storage_command( cdb, expected_length )
165
166
  end
166
167
 
167
168
  def mass_storage_reset
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libusb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: x86-mingw32
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-15 00:00:00.000000000 Z
12
+ date: 2012-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
16
- requirement: &21755140 !ruby/object:Gem::Requirement
16
+ requirement: &11618720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,21 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21755140
24
+ version_requirements: *11618720
25
+ - !ruby/object:Gem::Dependency
26
+ name: rdoc
27
+ requirement: &11618240 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.10'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *11618240
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: rake-compiler
27
- requirement: &21777860 !ruby/object:Gem::Requirement
38
+ requirement: &11617760 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ! '>='
@@ -32,18 +43,18 @@ dependencies:
32
43
  version: '0.6'
33
44
  type: :development
34
45
  prerelease: false
35
- version_requirements: *21777860
46
+ version_requirements: *11617760
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: hoe
38
- requirement: &21777240 !ruby/object:Gem::Requirement
49
+ requirement: &11617280 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ~>
42
53
  - !ruby/object:Gem::Version
43
- version: '2.12'
54
+ version: '3.0'
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *21777240
57
+ version_requirements: *11617280
47
58
  description: LIBUSB is a Ruby binding that gives Ruby programmers access to arbitrary
48
59
  USB devices
49
60
  email:
@@ -83,8 +94,9 @@ files:
83
94
  - test/test_libusb_mass_storage.rb
84
95
  - test/test_libusb_mass_storage2.rb
85
96
  - test/test_libusb_version.rb
97
+ - test/test_libusb_keyboard.rb
86
98
  - lib/libusb-1.0.dll
87
- homepage: http://github.com/larskanis/libusb
99
+ homepage:
88
100
  licenses: []
89
101
  post_install_message:
90
102
  rdoc_options:
@@ -112,12 +124,13 @@ signing_key:
112
124
  specification_version: 3
113
125
  summary: Access USB devices from Ruby via libusb-1.0
114
126
  test_files:
115
- - test/test_libusb_compat.rb
127
+ - test/test_libusb_compat_mass_storage.rb
128
+ - test/test_libusb_gc.rb
116
129
  - test/test_libusb_iso_transfer.rb
117
- - test/test_libusb_mass_storage2.rb
118
- - test/test_libusb_descriptors.rb
119
- - test/test_libusb_mass_storage.rb
120
130
  - test/test_libusb_capability.rb
121
- - test/test_libusb_compat_mass_storage.rb
131
+ - test/test_libusb_descriptors.rb
132
+ - test/test_libusb_compat.rb
133
+ - test/test_libusb_keyboard.rb
134
+ - test/test_libusb_mass_storage2.rb
122
135
  - test/test_libusb_version.rb
123
- - test/test_libusb_gc.rb
136
+ - test/test_libusb_mass_storage.rb