libusb 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/.gitignore +8 -0
  2. data/.travis.yml +10 -0
  3. data/.yardopts +6 -1
  4. data/Gemfile +16 -0
  5. data/{History.txt → History.md} +28 -16
  6. data/README.md +144 -0
  7. data/Rakefile +28 -24
  8. data/ext/extconf.rb +33 -0
  9. data/ext/libusbx-1.0.14/AUTHORS +50 -0
  10. data/ext/libusbx-1.0.14/COPYING +504 -0
  11. data/ext/libusbx-1.0.14/ChangeLog +139 -0
  12. data/ext/libusbx-1.0.14/INSTALL +234 -0
  13. data/ext/libusbx-1.0.14/Makefile.am +23 -0
  14. data/ext/libusbx-1.0.14/Makefile.in +803 -0
  15. data/ext/libusbx-1.0.14/NEWS +2 -0
  16. data/ext/libusbx-1.0.14/PORTING +94 -0
  17. data/ext/libusbx-1.0.14/README +28 -0
  18. data/ext/libusbx-1.0.14/THANKS +7 -0
  19. data/ext/libusbx-1.0.14/TODO +2 -0
  20. data/ext/libusbx-1.0.14/aclocal.m4 +9480 -0
  21. data/ext/libusbx-1.0.14/compile +143 -0
  22. data/ext/libusbx-1.0.14/config.guess +1501 -0
  23. data/ext/libusbx-1.0.14/config.h.in +116 -0
  24. data/ext/libusbx-1.0.14/config.sub +1705 -0
  25. data/ext/libusbx-1.0.14/configure +14818 -0
  26. data/ext/libusbx-1.0.14/configure.ac +230 -0
  27. data/ext/libusbx-1.0.14/depcomp +630 -0
  28. data/ext/libusbx-1.0.14/doc/Makefile.am +9 -0
  29. data/ext/libusbx-1.0.14/doc/Makefile.in +380 -0
  30. data/ext/libusbx-1.0.14/doc/doxygen.cfg.in +1288 -0
  31. data/ext/libusbx-1.0.14/examples/Makefile.am +18 -0
  32. data/ext/libusbx-1.0.14/examples/Makefile.in +596 -0
  33. data/ext/libusbx-1.0.14/examples/dpfp.c +506 -0
  34. data/ext/libusbx-1.0.14/examples/dpfp_threaded.c +544 -0
  35. data/ext/libusbx-1.0.14/examples/ezusb.c +616 -0
  36. data/ext/libusbx-1.0.14/examples/ezusb.h +107 -0
  37. data/ext/libusbx-1.0.14/examples/fxload.c +261 -0
  38. data/ext/libusbx-1.0.14/examples/getopt/getopt.c +1060 -0
  39. data/ext/libusbx-1.0.14/examples/getopt/getopt.h +180 -0
  40. data/ext/libusbx-1.0.14/examples/getopt/getopt1.c +188 -0
  41. data/ext/libusbx-1.0.14/examples/listdevs.c +63 -0
  42. data/ext/libusbx-1.0.14/examples/xusb.c +1036 -0
  43. data/ext/libusbx-1.0.14/install-sh +520 -0
  44. data/ext/libusbx-1.0.14/libusb-1.0.pc.in +11 -0
  45. data/ext/libusbx-1.0.14/libusb/Makefile.am +56 -0
  46. data/ext/libusbx-1.0.14/libusb/Makefile.in +721 -0
  47. data/ext/libusbx-1.0.14/libusb/core.c +1951 -0
  48. data/ext/libusbx-1.0.14/libusb/descriptor.c +731 -0
  49. data/ext/libusbx-1.0.14/libusb/io.c +2450 -0
  50. data/ext/libusbx-1.0.14/libusb/libusb-1.0.def +126 -0
  51. data/ext/libusbx-1.0.14/libusb/libusb-1.0.rc +59 -0
  52. data/ext/libusbx-1.0.14/libusb/libusb.h +1506 -0
  53. data/ext/libusbx-1.0.14/libusb/libusbi.h +910 -0
  54. data/ext/libusbx-1.0.14/libusb/os/darwin_usb.c +1807 -0
  55. data/ext/libusbx-1.0.14/libusb/os/darwin_usb.h +169 -0
  56. data/ext/libusbx-1.0.14/libusb/os/linux_usbfs.c +2569 -0
  57. data/ext/libusbx-1.0.14/libusb/os/linux_usbfs.h +149 -0
  58. data/ext/libusbx-1.0.14/libusb/os/openbsd_usb.c +727 -0
  59. data/ext/libusbx-1.0.14/libusb/os/poll_posix.h +10 -0
  60. data/ext/libusbx-1.0.14/libusb/os/poll_windows.c +747 -0
  61. data/ext/libusbx-1.0.14/libusb/os/poll_windows.h +114 -0
  62. data/ext/libusbx-1.0.14/libusb/os/threads_posix.c +80 -0
  63. data/ext/libusbx-1.0.14/libusb/os/threads_posix.h +50 -0
  64. data/ext/libusbx-1.0.14/libusb/os/threads_windows.c +211 -0
  65. data/ext/libusbx-1.0.14/libusb/os/threads_windows.h +87 -0
  66. data/ext/libusbx-1.0.14/libusb/os/windows_usb.c +4369 -0
  67. data/ext/libusbx-1.0.14/libusb/os/windows_usb.h +979 -0
  68. data/ext/libusbx-1.0.14/libusb/sync.c +321 -0
  69. data/ext/libusbx-1.0.14/libusb/version.h +18 -0
  70. data/ext/libusbx-1.0.14/libusb/version_nano.h +1 -0
  71. data/ext/libusbx-1.0.14/ltmain.sh +9636 -0
  72. data/ext/libusbx-1.0.14/missing +376 -0
  73. data/lib/libusb.rb +2 -3
  74. data/lib/libusb/call.rb +49 -7
  75. data/lib/libusb/compat.rb +15 -9
  76. data/lib/libusb/configuration.rb +15 -3
  77. data/lib/libusb/constants.rb +19 -6
  78. data/lib/libusb/context.rb +181 -3
  79. data/lib/libusb/dev_handle.rb +91 -40
  80. data/lib/libusb/endpoint.rb +41 -14
  81. data/lib/libusb/eventmachine.rb +183 -0
  82. data/lib/libusb/transfer.rb +21 -8
  83. data/lib/libusb/version_gem.rb +19 -0
  84. data/lib/libusb/{version.rb → version_struct.rb} +0 -0
  85. data/libusb.gemspec +31 -0
  86. data/test/test_libusb_compat.rb +1 -1
  87. data/test/test_libusb_compat_mass_storage.rb +2 -2
  88. data/test/test_libusb_descriptors.rb +1 -1
  89. data/test/test_libusb_event_machine.rb +118 -0
  90. data/test/test_libusb_iso_transfer.rb +6 -1
  91. data/test/test_libusb_mass_storage.rb +9 -3
  92. data/test/test_libusb_mass_storage2.rb +1 -1
  93. data/test/test_libusb_structs.rb +45 -0
  94. data/test/test_libusb_threads.rb +89 -0
  95. data/test/test_libusb_version.rb +4 -0
  96. metadata +109 -44
  97. data/.autotest +0 -23
  98. data/.gemtest +0 -0
  99. data/Manifest.txt +0 -3
  100. data/README.rdoc +0 -115
  101. data/test/test_libusb_keyboard.rb +0 -50
data/.gemtest DELETED
File without changes
@@ -1,3 +0,0 @@
1
- # List of files is auto generated by 'git ls-files',
2
- # but let Hoe find the VERSION string:
3
- lib/libusb.rb
@@ -1,115 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- = Access USB devices from Ruby via libusb-1.0.
4
-
5
- * http://github.com/larskanis/libusb
6
-
7
- == DESCRIPTION:
8
-
9
- LIBUSB is a Ruby binding that gives Ruby programmers access to arbitrary USB devices.
10
-
11
- * libusb[http://libusbx.org] is a library that gives full access to devices connected via the USB bus. No special kernel driver is thus necessary for accessing USB devices.
12
- * This Ruby binding supports the API version 1.0 of libusb[http://libusbx.org]. Note that the old "legacy" version 0.1.x of libusb uses a completely different API that is covered by the ruby extension ruby-usb[http://www.a-k-r.org/ruby-usb/] .
13
-
14
-
15
- LIBUSB for Ruby is covered by the GNU Lesser General Public License version 3.
16
-
17
- == FEATURES:
18
- * Access to descriptors of devices, configurations, interfaces, settings and endpoints
19
- * Synchronous and asynchronous communication for bulk, control, interrupt and isochronous transfers
20
- * Compatibility layer for ruby-usb[http://www.a-k-r.org/ruby-usb/] (API based on libusb-0.1). See {::USB} for description.
21
-
22
- == SYNOPSIS:
23
-
24
- require "libusb"
25
-
26
- usb = LIBUSB::Context.new
27
- device = usb.devices(:idVendor => 0x04b4, :idProduct => 0x8613).first
28
- device.open_interface(0) do |handle|
29
- handle.control_transfer(:bmRequestType => 0x40, :bRequest => 0xa0, :wValue => 0xe600, :wIndex => 0x0000, :dataOut => 1.chr)
30
- end
31
- {LIBUSB::Context#devices} is used to get all or only particular devices.
32
- After {LIBUSB::Device#open_interface opening and claiming} the {LIBUSB::Device} the resulting {LIBUSB::DevHandle} can be
33
- used to communicate with the connected USB device
34
- by {LIBUSB::DevHandle#control_transfer}, {LIBUSB::DevHandle#bulk_transfer},
35
- {LIBUSB::DevHandle#interrupt_transfer} or by using the {LIBUSB::Transfer} classes.
36
-
37
- A {LIBUSB::Device} can also be used to retrieve information about it,
38
- by using the device descriptor attributes.
39
- A {LIBUSB::Device} could have several configurations. You can then decide of which
40
- configuration to enable. You can only enable one configuration at a time.
41
-
42
- Each {LIBUSB::Configuration} has one or more interfaces. These can be seen as functional group
43
- performing a single feature of the device.
44
-
45
- Each {LIBUSB::Interface} has at least one {LIBUSB::Setting}. The first setting is always default.
46
- An alternate setting can be used independent on each interface.
47
-
48
- Each {LIBUSB::Setting} specifies it's own set of communication endpoints.
49
- Each {LIBUSB::Endpoint} specifies the type of transfer, direction, polling interval and
50
- maximum packet size.
51
-
52
-
53
- == REQUIREMENTS:
54
-
55
- * Linux, MacOSX or Windows system with Ruby MRI 1.8.7/1.9.x or JRuby
56
-
57
- == INSTALL:
58
-
59
- gem install libusb
60
-
61
- In order to use LIBUSB, you also need the libusb-1.0[http://libusbx.org] library (but not necessarily its header files).
62
- * Debian or Ubuntu:
63
- sudo apt-get install libusb-1.0-0-dev
64
- * OS-X: install with homebrew:
65
- brew install libusb
66
- or macports:
67
- port install libusb
68
- * Windows: libusb.gem comes with a precompiled +libusb.dll+, but you need to install a device driver (see below)
69
-
70
- Latest code can be used in this way:
71
-
72
- git clone git://github.com/larskanis/libusb.git
73
- rake install_gem
74
-
75
-
76
- == Usage on Windows
77
-
78
- In contrast to Linux, any access to an USB device by LIBUSB on Windows requires a proper driver
79
- installed in the system. Fortunately creating such a driver is quite easy with
80
- Zadig[http://sourceforge.net/projects/libwdi/files/zadig/]. Select the interesting USB device,
81
- choose WinUSB driver and press "Install Driver". That's it. You may take the generated output directory
82
- with it's INI-file and use it for driver installation on other 32 or 64 bit Windows
83
- systems.
84
-
85
-
86
- == Cross compiling for Windows
87
-
88
- Libusb-gem can be build on a linux or darwin host for the win32 platform,
89
- using the mingw cross compiler collection. Libusb is downloaded from source
90
- git repo, cross compiled and included in the generated libusb.gem.
91
-
92
- Install mingw32. On a debian based system this should work:
93
-
94
- apt-get install mingw32
95
-
96
- On MacOS X, if you have MacPorts installed:
97
-
98
- port install i386-mingw32-gcc
99
-
100
- Download and cross compile libusb for win32:
101
-
102
- rake cross gem
103
-
104
- If everything works, there should be libusb-VERSION-x86-mingw32.gem in the pkg
105
- directory.
106
-
107
- == Resources
108
-
109
- * API documentation of Libusb for Ruby: http://rubydoc.info/gems/libusb/frames
110
- * Mailinglist: http://rubyforge.org/mailman/listinfo/libusb-hackers
111
- * Overall introduction to USB: http://www.usbmadesimple.co.uk
112
-
113
- == Todo
114
-
115
- * add proper handling for polling and timing: http://libusb.sourceforge.net/api-1.0/group__poll.html
@@ -1,50 +0,0 @@
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