libusb 0.2.2-x86-mingw32 → 0.3.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -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