Sha256: f35fe12d44d125d3391cc61b68f46d55f8ef274dea3207b844bf2bf7ef2a76b0
Contents?: true
Size: 1.3 KB
Versions: 8
Compression:
Stored size: 1.3 KB
Contents
# This test requires a connected, but not mounted mass storage device with # read/write access allowed. Based on the following specifications: # http://www.usb.org/developers/devclass_docs/usbmassbulk_10.pdf # http://en.wikipedia.org/wiki/SCSI_command # require "test/unit" require "libusb" class TestLibusbKeyboard < Test::Unit::TestCase include LIBUSB attr_accessor :usb attr_accessor :device attr_accessor :dev attr_accessor :endpoint_in attr_accessor :endpoint_out def setup @usb = Context.new @usb.debug = 3 @device = usb.devices( :bDeviceClass=>CLASS_HID, :bDeviceProtocol=>1 ).first abort "no keyboard device found" unless @device @endpoint_in = @device.endpoints.find{|ep| ep.bEndpointAddress&ENDPOINT_IN != 0 }.bEndpointAddress @endpoint_out = @device.endpoints.find{|ep| ep.bEndpointAddress&ENDPOINT_IN == 0 }.bEndpointAddress @dev = @device.open if RUBY_PLATFORM=~/linux/i && dev.kernel_driver_active?(0) dev.detach_kernel_driver(0) end dev.claim_interface(0) # clear any pending data dev.clear_halt(endpoint_in) end def teardown dev.release_interface(0) if dev dev.close if dev end def test_read data_length = 8 recv = dev.interrupt_transfer(:endpoint=>endpoint_in, :dataIn=>data_length) p recv end end
Version data entries
8 entries across 8 versions & 1 rubygems