libusb 0.6.4-x86-mingw32 → 0.7.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.appveyor.yml +33 -0
- data/.github/workflows/ci.yml +185 -0
- data/.gitignore +1 -0
- data/.travis.yml +12 -7
- data/Gemfile +4 -1
- data/History.md +38 -0
- data/README.md +29 -4
- data/Rakefile +41 -12
- data/lib/libusb/bos.rb +85 -29
- data/lib/libusb/call.rb +132 -16
- data/lib/libusb/configuration.rb +3 -4
- data/lib/libusb/constants.rb +4 -0
- data/lib/libusb/context.rb +176 -35
- data/lib/libusb/context_reference.rb +38 -0
- data/lib/libusb/dependencies.rb +2 -2
- data/lib/libusb/dev_handle.rb +34 -24
- data/lib/libusb/device.rb +50 -8
- data/lib/libusb/endpoint.rb +3 -2
- data/lib/libusb/eventmachine.rb +8 -4
- data/lib/libusb/gem_helper.rb +9 -6
- data/lib/libusb/libusb_recipe.rb +2 -3
- data/lib/libusb/ss_companion.rb +9 -6
- data/lib/libusb/transfer.rb +10 -6
- data/lib/libusb/version_gem.rb +1 -1
- data/lib/libusb-1.0.dll +0 -0
- data/lib/libusb.rb +106 -18
- data/libusb.gemspec +1 -5
- data/test/test_libusb_bos.rb +22 -0
- data/test/test_libusb_bulk_stream_transfer.rb +23 -12
- data/test/test_libusb_context.rb +47 -0
- data/test/test_libusb_descriptors.rb +44 -11
- data/test/test_libusb_gc.rb +15 -0
- data/test/test_libusb_hotplug.rb +3 -1
- data/test/test_libusb_iso_transfer.rb +6 -0
- data/test/test_libusb_mass_storage.rb +6 -6
- metadata +7 -62
- data/appveyor.yml +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f60f874061fbe4f26ca413e4b46b7d46cb51e8891309a25a4d04eec64799953a
|
4
|
+
data.tar.gz: f83b61c302763962891191cac0bcee9e01975481b6b7be685fd27603153fccf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94c9147db652ac78a9e67bc63139f79e3e32861b28a4cb2e409417ab974e8ebb7ed7c31f7cac46d5385b015a031cb83db36b79938bd03b18e5c5424c531358f7
|
7
|
+
data.tar.gz: 9982d014b7ddb3bb10780e988a3b33dd28f2dbf80e51eb9c33d761c1352d24d5eb2e8652bd4cfdc5a3cdca720f5b9c630a5de7d24af7685a24efdfbdfd28543b
|
data/.appveyor.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
image: Visual Studio 2019
|
2
|
+
|
3
|
+
clone_depth: 1
|
4
|
+
|
5
|
+
init:
|
6
|
+
- SET PATH=C:/Ruby%ruby_version%/bin;%PATH%
|
7
|
+
install:
|
8
|
+
- ps: |
|
9
|
+
if ($env:ruby_version -like "*head*") {
|
10
|
+
$(new-object net.webclient).DownloadFile("https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-$env:ruby_version.exe", "$pwd/ruby-setup.exe")
|
11
|
+
cmd /c ruby-setup.exe /verysilent /currentuser /dir=C:/Ruby$env:ruby_version
|
12
|
+
}
|
13
|
+
- ruby --version
|
14
|
+
- gem --version
|
15
|
+
- ridk version
|
16
|
+
- ridk enable
|
17
|
+
- c:/msys64/usr/bin/bash -lc "pacman -S --noconfirm --needed ${MINGW_PACKAGE_PREFIX}-gcc ${MINGW_PACKAGE_PREFIX}-openssl"
|
18
|
+
- gcc -v
|
19
|
+
- gem install bundler --conservative
|
20
|
+
- bundle install
|
21
|
+
|
22
|
+
build_script:
|
23
|
+
- bundle exec rake compile
|
24
|
+
|
25
|
+
test_script:
|
26
|
+
- bundle exec rake ci
|
27
|
+
|
28
|
+
environment:
|
29
|
+
matrix:
|
30
|
+
- ruby_version: "head-x64"
|
31
|
+
- ruby_version: "33"
|
32
|
+
- ruby_version: "30-x64"
|
33
|
+
- ruby_version: "25"
|
@@ -0,0 +1,185 @@
|
|
1
|
+
name: Build docker images
|
2
|
+
concurrency:
|
3
|
+
group: "${{github.workflow}}-${{github.ref}}"
|
4
|
+
cancel-in-progress: true
|
5
|
+
on:
|
6
|
+
workflow_dispatch:
|
7
|
+
schedule:
|
8
|
+
- cron: "0 5 * * 3" # At 05:00 on Wednesday # https://crontab.guru/#0_5_*_*_3
|
9
|
+
push:
|
10
|
+
branches:
|
11
|
+
- master
|
12
|
+
tags:
|
13
|
+
- "*.*.*"
|
14
|
+
pull_request:
|
15
|
+
types: [opened, synchronize]
|
16
|
+
branches:
|
17
|
+
- "*"
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
# These jobs use Buildx layer caching
|
21
|
+
docker_build:
|
22
|
+
name: Build
|
23
|
+
|
24
|
+
strategy:
|
25
|
+
fail-fast: false
|
26
|
+
matrix:
|
27
|
+
platform:
|
28
|
+
- x86-mingw32
|
29
|
+
- x64-mingw-ucrt
|
30
|
+
- x64-mingw32
|
31
|
+
- x86-linux
|
32
|
+
- x86_64-linux
|
33
|
+
|
34
|
+
runs-on: ubuntu-latest
|
35
|
+
env:
|
36
|
+
PLATFORM: ${{ matrix.platform }}
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v4
|
39
|
+
|
40
|
+
- uses: ruby/setup-ruby@v1
|
41
|
+
with:
|
42
|
+
ruby-version: "3.3"
|
43
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
44
|
+
|
45
|
+
- name: Build libusb.gem
|
46
|
+
run: |
|
47
|
+
bundle exec rake gem:native:${PLATFORM}
|
48
|
+
|
49
|
+
- name: Upload binary gem
|
50
|
+
uses: actions/upload-artifact@v4
|
51
|
+
with:
|
52
|
+
name: gem-${{ matrix.platform }}
|
53
|
+
path: pkg/*-*-*.gem
|
54
|
+
|
55
|
+
- if: matrix.platform == 'jruby'
|
56
|
+
name: Upload source gem
|
57
|
+
uses: actions/upload-artifact@v4
|
58
|
+
with:
|
59
|
+
name: gem-ruby
|
60
|
+
path: pkg/*-?.?.?.gem
|
61
|
+
|
62
|
+
job_test_native:
|
63
|
+
name: Bin (${{matrix.ruby}}, ${{matrix.os}}, ${{matrix.platform}})
|
64
|
+
needs: docker_build
|
65
|
+
strategy:
|
66
|
+
fail-fast: false
|
67
|
+
matrix:
|
68
|
+
include:
|
69
|
+
- os: windows
|
70
|
+
ruby: "2.5"
|
71
|
+
platform: x64-mingw32
|
72
|
+
- os: windows
|
73
|
+
ruby: "3.3"
|
74
|
+
platform: x64-mingw-ucrt
|
75
|
+
- os: ubuntu
|
76
|
+
ruby: "2.5"
|
77
|
+
platform: x86_64-linux
|
78
|
+
- os: ubuntu
|
79
|
+
ruby: "3.3"
|
80
|
+
platform: x86_64-linux
|
81
|
+
|
82
|
+
runs-on: ${{ matrix.os }}-latest
|
83
|
+
steps:
|
84
|
+
- uses: actions/checkout@v4
|
85
|
+
- uses: ruby/setup-ruby@v1
|
86
|
+
with:
|
87
|
+
ruby-version: ${{ matrix.ruby }}
|
88
|
+
- run: ruby --version
|
89
|
+
- name: Download gem-${{matrix.platform}}
|
90
|
+
uses: actions/download-artifact@v4
|
91
|
+
with:
|
92
|
+
name: gem-${{ matrix.platform }}
|
93
|
+
- name: Install gem-${{matrix.platform}}
|
94
|
+
run: gem install *.gem --verbose
|
95
|
+
- name: bundle install
|
96
|
+
run: bundle install
|
97
|
+
- name: Generate Gemfile_libusb_gem to ensure the installed gem is used
|
98
|
+
run: bundle exec rake gemfile_libusb_gem
|
99
|
+
- name: Run tests
|
100
|
+
env:
|
101
|
+
BUNDLE_GEMFILE: Gemfile_libusb_gem
|
102
|
+
run: |
|
103
|
+
bundle exec rake ci
|
104
|
+
|
105
|
+
# These jobs use Buildx layer caching
|
106
|
+
source_gem:
|
107
|
+
name: Source gem
|
108
|
+
|
109
|
+
strategy:
|
110
|
+
fail-fast: false
|
111
|
+
|
112
|
+
runs-on: ubuntu-latest
|
113
|
+
steps:
|
114
|
+
- uses: actions/checkout@v4
|
115
|
+
|
116
|
+
- uses: ruby/setup-ruby@v1
|
117
|
+
with:
|
118
|
+
ruby-version: "3.3"
|
119
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
120
|
+
|
121
|
+
- name: Build libusb.gem
|
122
|
+
run: |
|
123
|
+
bundle exec rake gem
|
124
|
+
|
125
|
+
- name: Upload binary gem
|
126
|
+
uses: actions/upload-artifact@v4
|
127
|
+
with:
|
128
|
+
name: gem-ruby
|
129
|
+
path: pkg/*.gem
|
130
|
+
|
131
|
+
job_test_source:
|
132
|
+
name: Src (${{matrix.ruby}}, ${{matrix.os}}, ${{matrix.extconfopts}})
|
133
|
+
needs: source_gem
|
134
|
+
strategy:
|
135
|
+
fail-fast: false
|
136
|
+
matrix:
|
137
|
+
os:
|
138
|
+
- windows
|
139
|
+
- ubuntu
|
140
|
+
- macos
|
141
|
+
ruby:
|
142
|
+
- "3.3"
|
143
|
+
- "2.5"
|
144
|
+
- "head"
|
145
|
+
- "jruby"
|
146
|
+
- "truffleruby"
|
147
|
+
extconfopts: [ --disable-system-libusb, --enable-system-libusb ]
|
148
|
+
exclude:
|
149
|
+
- os: windows
|
150
|
+
ruby: "truffleruby"
|
151
|
+
- os: windows
|
152
|
+
ruby: "jruby"
|
153
|
+
# Fails to install libusb from MSYS2
|
154
|
+
extconfopts: --enable-system-libusb
|
155
|
+
- os: windows
|
156
|
+
ruby: "jruby"
|
157
|
+
# configure: error: unrecognized option: `--prefix\=D:/jruby-9.4.6.0/lib/ruby/gems/shared/gems/libusb-0.6.4/ports/x86_64-w64-mingw32/libusb/1.0.27'
|
158
|
+
extconfopts: --disable-system-libusb
|
159
|
+
|
160
|
+
runs-on: ${{ matrix.os }}-latest
|
161
|
+
steps:
|
162
|
+
- uses: actions/checkout@v4
|
163
|
+
- uses: ruby/setup-ruby@v1
|
164
|
+
with:
|
165
|
+
ruby-version: ${{ matrix.ruby }}
|
166
|
+
- run: ruby --version
|
167
|
+
- name: Download gem
|
168
|
+
uses: actions/download-artifact@v4
|
169
|
+
with:
|
170
|
+
name: gem-ruby
|
171
|
+
- name: Install libusb on Windows
|
172
|
+
if: matrix.os == 'windows' && matrix.extconfopts == '--enable-system-libusb'
|
173
|
+
shell: cmd
|
174
|
+
run: C:/msys64/usr/bin/sh -c "pacman --sync --refresh --needed --noconfirm ${MINGW_PACKAGE_PREFIX}-libusb"
|
175
|
+
- name: Install gem
|
176
|
+
run: gem install *.gem --verbose -- ${{ matrix.extconfopts }}
|
177
|
+
- name: bundle install
|
178
|
+
run: bundle install
|
179
|
+
- name: Generate Gemfile_libusb_gem to ensure the installed gem is used
|
180
|
+
run: bundle exec rake gemfile_libusb_gem
|
181
|
+
- name: Run tests
|
182
|
+
env:
|
183
|
+
BUNDLE_GEMFILE: Gemfile_libusb_gem
|
184
|
+
run: |
|
185
|
+
bundle exec rake ci
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
2
3
|
sudo: false
|
3
|
-
|
4
|
+
|
5
|
+
dist: xenial
|
4
6
|
matrix:
|
5
7
|
include:
|
6
8
|
- rvm: ruby-head
|
@@ -9,13 +11,16 @@ matrix:
|
|
9
11
|
- rvm: 2.4.3
|
10
12
|
env:
|
11
13
|
- RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
|
12
|
-
- rvm:
|
13
|
-
|
14
|
-
|
14
|
+
- rvm: 3.0
|
15
|
+
env:
|
16
|
+
- RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
|
17
|
+
- rvm: 2.7
|
18
|
+
- rvm: 2.6
|
15
19
|
- rvm: 2.3.1
|
16
|
-
- rvm: jruby-9.
|
17
|
-
- rvm:
|
20
|
+
- rvm: jruby-9.2.14.0
|
21
|
+
- rvm: truffleruby
|
22
|
+
|
18
23
|
allow_failures:
|
19
|
-
- rvm: rbx-3
|
20
24
|
- rvm: ruby-head
|
25
|
+
|
21
26
|
script: bundle exec rake travis
|
data/Gemfile
CHANGED
@@ -8,7 +8,10 @@ group :test do
|
|
8
8
|
gem 'minitest'
|
9
9
|
end
|
10
10
|
|
11
|
-
gem 'rake-compiler-dock', '~>
|
11
|
+
gem 'rake-compiler-dock', '~> 1.1'
|
12
|
+
gem 'rake-compiler', '~> 1.0'
|
13
|
+
gem 'bundler', '>= 1', '< 3'
|
14
|
+
gem 'yard', '~> 0.6', '>= 0.9.36'
|
12
15
|
|
13
16
|
# For some reason this is required in addition to the gemspec
|
14
17
|
# when 'bundle config force_ruby_platform true' is active:
|
data/History.md
CHANGED
@@ -1,3 +1,41 @@
|
|
1
|
+
0.7.0 / 2024-04-18
|
2
|
+
------------------
|
3
|
+
|
4
|
+
Added:
|
5
|
+
* Garbage collect LIBUSB::Context objects. #47
|
6
|
+
Context objects were intentionally not garbage collected previously, since it led to segfauls, when the context was freed before other libusb objects.
|
7
|
+
Now refcounting all objects bound to a particular Context ensures that the underlying libusb context is always freed at last, avoiding any segfaults.
|
8
|
+
Registered log callback and pollfd callbacks are disabled before garbage collecting LIBUSB::Context.
|
9
|
+
* Cancel USB transfers on any exceptions not only LIBUSB::Error, but also Interrupt or IRB::Abort, etc.
|
10
|
+
Otherwise incomplete transfers lead to LIBUSB::ERROR_BUSY at the next command.
|
11
|
+
* Update Windows binary support for ruby up to 3.3.x
|
12
|
+
* Update bundled libusb version to 1.0.27.
|
13
|
+
* Add support for new functions of libusb-1.0.27
|
14
|
+
They are:
|
15
|
+
- libusb_init_context
|
16
|
+
- libusb_set_log_cb
|
17
|
+
- libusb_wrap_sys_device
|
18
|
+
* Add global Libusb.set_option and Libusb.set_options . #42
|
19
|
+
* Add LIBUSB::Device.max_alt_packet_size. #42
|
20
|
+
Introduced in libusb-1.0.27 as libusb_get_max_alt_packet_size()
|
21
|
+
* Add BOS platform descriptor introduced in libusb-1.0.27. #49
|
22
|
+
* Add enums for all BOS descripors of the USB-3.2-V1.1 spec. #49
|
23
|
+
|
24
|
+
Changed:
|
25
|
+
* Set minimum Ruby version requirement to 2.5.0.
|
26
|
+
* Fix a circular reference in ZeroCopyMemory.
|
27
|
+
This circular reference blocked all objects referenced by a LIBUSB::Transfer to be released by the garbage collector.
|
28
|
+
* Make ZeroCopyMemory an opt-in rather then enforcing it
|
29
|
+
In therory libusb_dev_mem_alloc shouldn't provide a pointer unless zero-copy-memory is supported by the linux kernel.
|
30
|
+
But in practice this has been a repeating cause of issues, since some kernels don't handle these transfers.
|
31
|
+
So it's better to enable it on request only.
|
32
|
+
For instance older raspberry pi kernels didn't handle zero-copy-memory.
|
33
|
+
* Fix struct member size in Bos::SsUsbDeviceCapability. #48
|
34
|
+
The bmAttributes member is defined as uint8_t not uint32_t.
|
35
|
+
* Fix context reference in device of hotplug notification callback.
|
36
|
+
* Deregister pollfd callbacks in eventmachine_unregister.
|
37
|
+
|
38
|
+
|
1
39
|
0.6.4 / 2018-05-05
|
2
40
|
------------------
|
3
41
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<!-- -*- coding: utf-8 -*- -->
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.
|
3
|
+
[![Build Status](https://travis-ci.com/larskanis/libusb.svg?branch=master)](https://travis-ci.com/larskanis/libusb)
|
4
4
|
[![Build status](https://ci.appveyor.com/api/projects/status/mdfnfdwu4mil42o3/branch/master?svg=true)](https://ci.appveyor.com/project/larskanis/libusb/branch/master)
|
5
5
|
|
6
6
|
Access USB devices from Ruby
|
@@ -59,7 +59,7 @@ See [the documentation](http://rubydoc.info/gems/libusb/frames) for a full API d
|
|
59
59
|
Prerequisites
|
60
60
|
-------------
|
61
61
|
|
62
|
-
* Linux, MacOS or Windows system with Ruby MRI
|
62
|
+
* Linux, MacOS or Windows system with Ruby MRI 2.x/3.x, JRuby or recent version of Rubinius
|
63
63
|
* Optionally: [libusb](http://libusb.info) C-library version 1.0.8 or any newer version.
|
64
64
|
The system libusb library can be installed like so:
|
65
65
|
* Debian or Ubuntu:
|
@@ -126,10 +126,15 @@ with it's INI-file and use it for driver installations on other 32 or 64 bit Win
|
|
126
126
|
systems.
|
127
127
|
|
128
128
|
|
129
|
-
|
129
|
+
Binary gems for Windows and Linux
|
130
130
|
---------------------------
|
131
131
|
|
132
|
-
Libusb
|
132
|
+
The Libusb gem is provided as source gem and as binary gems for Windows and Linux operating systems on [rubygems.org](https://rubygems.org/gems/libusb).
|
133
|
+
The binary version is usually preferred, but the source version of the gem can be enforced by:
|
134
|
+
|
135
|
+
$ gem install libusb --platform ruby
|
136
|
+
|
137
|
+
Libusb gem can be cross built for Windows and Linux, using the [rake-compiler-dock](https://github.com/larskanis/rake-compiler-dock) .
|
133
138
|
Just run:
|
134
139
|
|
135
140
|
$ rake gem:native
|
@@ -145,6 +150,26 @@ That API is currently proof of concept - see {LIBUSB::Context#eventmachine_regis
|
|
145
150
|
If you're experienced with EventMachine, please leave a comment.
|
146
151
|
|
147
152
|
|
153
|
+
Testing LIBUSB gem
|
154
|
+
------------------
|
155
|
+
|
156
|
+
Libusb for Ruby has a bundled test suite which verifies proper working of many functions of the library.
|
157
|
+
Only a small subset of these tests are executed on Github Actions due to the missing USB functions in the CI environments.
|
158
|
+
They just verify that the libusb library can be installed and called and that very basic functions are working.
|
159
|
+
|
160
|
+
To run the tests against real devices the following procedure should be done:
|
161
|
+
|
162
|
+
```sh
|
163
|
+
$ # Connect a USB mass strorage device. It is used read-only.
|
164
|
+
$ sudo chown $USER /dev/bus/usb/*/*
|
165
|
+
$ rake test
|
166
|
+
```
|
167
|
+
|
168
|
+
While the tests are running a second arbitrary USB device is requested to be connected and shortly after disconnected again.
|
169
|
+
There are only 5 seconds timeout for connecting and disconnecting, so that the device should have be ready.
|
170
|
+
Some USB mass storage devices are not compatible to the tests, so that it's best to try out different models to find some that doesn't fail.
|
171
|
+
|
172
|
+
|
148
173
|
Resources
|
149
174
|
---------
|
150
175
|
|
data/Rakefile
CHANGED
@@ -7,37 +7,51 @@ require 'pathname'
|
|
7
7
|
require 'uri'
|
8
8
|
require 'ostruct'
|
9
9
|
require 'rake/clean'
|
10
|
-
require 'rake_compiler_dock'
|
11
10
|
require_relative 'lib/libusb/libusb_recipe'
|
12
11
|
require_relative 'lib/libusb/gem_helper'
|
13
12
|
|
13
|
+
CLOBBER.include 'pkg'
|
14
|
+
CLEAN.include 'ports'
|
15
|
+
CLEAN.include 'tmp'
|
16
|
+
CLEAN.include 'ext/tmp'
|
17
|
+
CLEAN.include 'lib/*.a'
|
18
|
+
CLEAN.include 'lib/*.so*'
|
19
|
+
CLEAN.include 'lib/*.dll*'
|
20
|
+
|
21
|
+
task :build do
|
22
|
+
require_relative 'lib/libusb/libusb_recipe'
|
23
|
+
recipe = LIBUSB::LibusbRecipe.new
|
24
|
+
recipe.download
|
25
|
+
end
|
26
|
+
|
14
27
|
task :gem => :build
|
15
28
|
task :compile do
|
16
29
|
sh "ruby -C ext extconf.rb --disable-system-libusb"
|
17
30
|
sh "make -C ext install RUBYARCHDIR=../lib"
|
18
31
|
end
|
19
32
|
|
20
|
-
task :
|
21
|
-
|
33
|
+
task :gemfile_libusb_gem do
|
34
|
+
gf = File.read("Gemfile")
|
35
|
+
gf.gsub!(/^(gemspec)$/, "# \\1")
|
36
|
+
gf << "\ngem 'libusb'\n"
|
37
|
+
File.write("Gemfile_libusb_gem", gf)
|
38
|
+
puts "Gemfile_libusb_gem written"
|
22
39
|
end
|
23
40
|
|
24
|
-
|
25
|
-
|
26
|
-
sh "ruby -w -W2 -I. -Ilib -e \"#{travis_tests.map{|f| "require 'test/#{f}';"}.join}\" -- -v"
|
41
|
+
task :test do
|
42
|
+
sh "ruby -w -W2 -I.:lib -e \"#{Dir["test/test_*.rb"].map{|f| "require '#{f}';"}.join}\" -- -v"
|
27
43
|
end
|
28
44
|
task :default => :test
|
29
45
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
bundle --local &&
|
34
|
-
rake cross gem
|
35
|
-
EOT
|
46
|
+
ci_tests = %w[test_libusb.rb test_libusb_structs.rb]
|
47
|
+
task :ci do
|
48
|
+
sh "ruby -w -W2 -I. -e \"#{ci_tests.map{|f| "require 'test/#{f}';"}.join}\" -- -v"
|
36
49
|
end
|
37
50
|
|
38
51
|
CrossLibraries = [
|
39
52
|
['x86-mingw32', 'i686-w64-mingw32', 'bin/libusb-1.0.dll'],
|
40
53
|
['x64-mingw32', 'x86_64-w64-mingw32', 'bin/libusb-1.0.dll'],
|
54
|
+
['x64-mingw-ucrt', 'x86_64-w64-mingw32', 'bin/libusb-1.0.dll'],
|
41
55
|
['x86-linux', 'i686-linux-gnu', 'lib/libusb-1.0.so'],
|
42
56
|
['x86_64-linux', 'x86_64-linux-gnu', 'lib/libusb-1.0.so'],
|
43
57
|
].map do |ruby_platform, host_platform, libusb_dll|
|
@@ -47,4 +61,19 @@ end
|
|
47
61
|
LIBUSB::GemHelper.install_tasks
|
48
62
|
Bundler::GemHelper.instance.cross_platforms = CrossLibraries.map(&:ruby_platform)
|
49
63
|
|
64
|
+
CrossLibraries.map(&:ruby_platform).each do |platform|
|
65
|
+
desc "Build windows and linux fat binary gems"
|
66
|
+
multitask 'gem:native' => "gem:native:#{platform}"
|
67
|
+
|
68
|
+
task "gem:native:#{platform}" do
|
69
|
+
require 'rake_compiler_dock'
|
70
|
+
sh "bundle package"
|
71
|
+
RakeCompilerDock.sh <<-EOT, platform: platform
|
72
|
+
bundle --local &&
|
73
|
+
#{ "sudo yum install -y libudev-devel &&" if platform=~/linux/ }
|
74
|
+
bundle exec rake --trace cross:#{platform} gem "MAKE=make V=1 -j`nproc`" || cat tmp/*/ports/libusb/*/*.log
|
75
|
+
EOT
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
50
79
|
# vim: syntax=ruby
|
data/lib/libusb/bos.rb
CHANGED
@@ -19,7 +19,7 @@ module LIBUSB
|
|
19
19
|
# A structure representing the Binary Device Object Store (BOS) descriptor.
|
20
20
|
# This descriptor is documented in section 9.6.2 of the USB 3.0 specification.
|
21
21
|
# All multiple-byte fields are represented in host-endian format.
|
22
|
-
class Bos < FFI::
|
22
|
+
class Bos < FFI::Struct
|
23
23
|
|
24
24
|
module GenericMethods
|
25
25
|
# @return [Integer] Size of this descriptor (in bytes)
|
@@ -39,7 +39,7 @@ module LIBUSB
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def inspect
|
42
|
-
"\#<#{self.class} cap: #{bDevCapabilityType} data: #{dev_capability_data.
|
42
|
+
"\#<#{self.class} cap: #{bDevCapabilityType} data: #{dev_capability_data.unpack1("H*")}>"
|
43
43
|
end
|
44
44
|
|
45
45
|
# @return [String] Device Capability data (bLength - 3 bytes)
|
@@ -66,14 +66,21 @@ module LIBUSB
|
|
66
66
|
# A structure representing the USB 2.0 Extension descriptor
|
67
67
|
# This descriptor is documented in section 9.6.2.1 of the USB 3.0 specification.
|
68
68
|
# All multiple-byte fields are represented in host-endian format.
|
69
|
-
class Usb20Extension < FFI::
|
69
|
+
class Usb20Extension < FFI::Struct
|
70
70
|
include GenericMethods
|
71
|
+
include ContextReference
|
71
72
|
|
72
73
|
layout :bLength, :uint8,
|
73
74
|
:bDescriptorType, :uint8,
|
74
75
|
:bDevCapabilityType, :uint8,
|
75
76
|
:bmAttributes, :uint32
|
76
77
|
|
78
|
+
def initialize(ctx, *args)
|
79
|
+
super(*args)
|
80
|
+
|
81
|
+
register_context(ctx, :libusb_free_usb_2_0_extension_descriptor)
|
82
|
+
end
|
83
|
+
|
77
84
|
# Bitmap encoding of supported device level features.
|
78
85
|
# A value of one in a bit location indicates a feature is
|
79
86
|
# supported; a value of zero indicates it is not supported.
|
@@ -93,28 +100,30 @@ module LIBUSB
|
|
93
100
|
end
|
94
101
|
"\#<#{self.class} #{attrs.compact.join(",")}>"
|
95
102
|
end
|
96
|
-
|
97
|
-
# @private
|
98
|
-
def self.release(ptr)
|
99
|
-
Call.libusb_free_usb_2_0_extension_descriptor(ptr)
|
100
|
-
end
|
101
103
|
end
|
102
104
|
|
103
105
|
# A structure representing the SuperSpeed USB Device Capability descriptor
|
104
106
|
# This descriptor is documented in section 9.6.2.2 of the USB 3.0 specification.
|
105
107
|
# All multiple-byte fields are represented in host-endian format.
|
106
|
-
class SsUsbDeviceCapability < FFI::
|
108
|
+
class SsUsbDeviceCapability < FFI::Struct
|
107
109
|
include GenericMethods
|
110
|
+
include ContextReference
|
108
111
|
|
109
112
|
layout :bLength, :uint8,
|
110
113
|
:bDescriptorType, :uint8,
|
111
114
|
:bDevCapabilityType, :uint8,
|
112
|
-
:bmAttributes, :
|
115
|
+
:bmAttributes, :uint8,
|
113
116
|
:wSpeedSupported, :uint16,
|
114
117
|
:bFunctionalitySupport, :uint8,
|
115
118
|
:bU1DevExitLat, :uint8,
|
116
119
|
:bU2DevExitLat, :uint16
|
117
120
|
|
121
|
+
def initialize(ctx, *args)
|
122
|
+
super(*args)
|
123
|
+
|
124
|
+
register_context(ctx, :libusb_free_ss_usb_device_capability_descriptor)
|
125
|
+
end
|
126
|
+
|
118
127
|
# Bitmap encoding of supported device level features.
|
119
128
|
# A value of one in a bit location indicates a feature is
|
120
129
|
# supported; a value of zero indicates it is not supported.
|
@@ -178,18 +187,14 @@ module LIBUSB
|
|
178
187
|
def bU2DevExitLat
|
179
188
|
self[:bU2DevExitLat]
|
180
189
|
end
|
181
|
-
|
182
|
-
# @private
|
183
|
-
def self.release(ptr)
|
184
|
-
Call.libusb_free_ss_usb_device_capability_descriptor(ptr)
|
185
|
-
end
|
186
190
|
end
|
187
191
|
|
188
192
|
# A structure representing the Container ID descriptor.
|
189
193
|
# This descriptor is documented in section 9.6.2.3 of the USB 3.0 specification.
|
190
194
|
# All multiple-byte fields, except UUIDs, are represented in host-endian format.
|
191
|
-
class ContainerId < FFI::
|
195
|
+
class ContainerId < FFI::Struct
|
192
196
|
include GenericMethods
|
197
|
+
include ContextReference
|
193
198
|
|
194
199
|
layout :bLength, :uint8,
|
195
200
|
:bDescriptorType, :uint8,
|
@@ -197,6 +202,12 @@ module LIBUSB
|
|
197
202
|
:bReserved, :uint8,
|
198
203
|
:ContainerID, [:uint8, 16]
|
199
204
|
|
205
|
+
def initialize(ctx, *args)
|
206
|
+
super(*args)
|
207
|
+
|
208
|
+
register_context(ctx, :libusb_free_container_id_descriptor)
|
209
|
+
end
|
210
|
+
|
200
211
|
# Reserved field
|
201
212
|
def bReserved
|
202
213
|
self[:bReserved]
|
@@ -208,18 +219,65 @@ module LIBUSB
|
|
208
219
|
end
|
209
220
|
|
210
221
|
def inspect
|
211
|
-
"\#<#{self.class} #{container_id.
|
222
|
+
"\#<#{self.class} #{container_id.unpack1("H*")}>"
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
# A structure representing a Platform descriptor.
|
228
|
+
# This descriptor is documented in section 9.6.2.4 of the USB 3.2 specification.
|
229
|
+
class PlatformDescriptor < FFI::Struct
|
230
|
+
include GenericMethods
|
231
|
+
include ContextReference
|
232
|
+
|
233
|
+
layout :bLength, :uint8,
|
234
|
+
:bDescriptorType, :uint8,
|
235
|
+
# Capability type. Will have value
|
236
|
+
# libusb_capability_type::LIBUSB_BT_PLATFORM_DESCRIPTOR
|
237
|
+
# LIBUSB_BT_CONTAINER_ID in this context.
|
238
|
+
:bDevCapabilityType, :uint8,
|
239
|
+
# Reserved field
|
240
|
+
:bReserved, :uint8,
|
241
|
+
# 128 bit UUID
|
242
|
+
:PlatformCapabilityUUID, [:uint8, 16],
|
243
|
+
# Capability data (bLength - 20)
|
244
|
+
:CapabilityData, [:uint8, 0]
|
245
|
+
|
246
|
+
def initialize(ctx, *args)
|
247
|
+
super(*args)
|
248
|
+
|
249
|
+
register_context(ctx, :libusb_free_platform_descriptor)
|
250
|
+
end
|
251
|
+
|
252
|
+
# Reserved field
|
253
|
+
def bReserved
|
254
|
+
self[:bReserved]
|
255
|
+
end
|
256
|
+
|
257
|
+
# @return [String] 128 bit UUID
|
258
|
+
def platformCapabilityUUID
|
259
|
+
self[:PlatformCapabilityUUID].to_ptr.read_bytes(16)
|
212
260
|
end
|
213
261
|
|
214
|
-
#
|
215
|
-
|
216
|
-
|
262
|
+
# This is a variable-length field containing data associated with the platform specific capability.
|
263
|
+
# This field may be zero bytes in length.
|
264
|
+
# @return [String]
|
265
|
+
def capabilityData
|
266
|
+
self[:CapabilityData].to_ptr.read_bytes(bLength - 20)
|
267
|
+
end
|
268
|
+
|
269
|
+
def inspect
|
270
|
+
"\#<#{self.class} #{platformCapabilityUUID.unpack1("H*")} (#{capabilityData.unpack1("H*")})>"
|
217
271
|
end
|
218
272
|
end
|
219
273
|
|
220
|
-
|
274
|
+
include ContextReference
|
275
|
+
|
276
|
+
def initialize(ctx, *args)
|
221
277
|
@ctx = ctx
|
222
278
|
super(*args)
|
279
|
+
|
280
|
+
register_context(ctx, :libusb_free_bos_descriptor)
|
223
281
|
end
|
224
282
|
|
225
283
|
layout :bLength, :uint8,
|
@@ -265,13 +323,16 @@ module LIBUSB
|
|
265
323
|
# no struct defined in libusb -> use generic DeviceCapability
|
266
324
|
when LIBUSB::BT_USB_2_0_EXTENSION
|
267
325
|
res = Call.libusb_get_usb_2_0_extension_descriptor(@ctx, cap.pointer, pp_ext)
|
268
|
-
cap = Usb20Extension.new(pp_ext.read_pointer) if res==0
|
326
|
+
cap = Usb20Extension.new(@ctx, pp_ext.read_pointer) if res==0
|
269
327
|
when LIBUSB::BT_SS_USB_DEVICE_CAPABILITY
|
270
328
|
res = Call.libusb_get_ss_usb_device_capability_descriptor(@ctx, cap.pointer, pp_ext)
|
271
|
-
cap = SsUsbDeviceCapability.new(pp_ext.read_pointer) if res==0
|
329
|
+
cap = SsUsbDeviceCapability.new(@ctx, pp_ext.read_pointer) if res==0
|
272
330
|
when LIBUSB::BT_CONTAINER_ID
|
273
331
|
res = Call.libusb_get_container_id_descriptor(@ctx, cap.pointer, pp_ext)
|
274
|
-
cap = ContainerId.new(pp_ext.read_pointer) if res==0
|
332
|
+
cap = ContainerId.new(@ctx, pp_ext.read_pointer) if res==0
|
333
|
+
when LIBUSB::BT_PLATFORM_DESCRIPTOR
|
334
|
+
res = Call.libusb_get_platform_descriptor(@ctx, cap.pointer, pp_ext)
|
335
|
+
cap = PlatformDescriptor.new(@ctx, pp_ext.read_pointer) if res==0
|
275
336
|
else
|
276
337
|
# unknown capability -> use generic DeviceCapability
|
277
338
|
end
|
@@ -297,10 +358,5 @@ module LIBUSB
|
|
297
358
|
def inspect
|
298
359
|
"\#<#{self.class} #{device_capability_types.join(", ")}>"
|
299
360
|
end
|
300
|
-
|
301
|
-
# @private
|
302
|
-
def self.release(ptr)
|
303
|
-
Call.libusb_free_bos_descriptor(ptr)
|
304
|
-
end
|
305
361
|
end
|
306
362
|
end
|