Module: HidApi

Extended by:
FFI::Library
Defined in:
lib/hid_api.rb,
lib/hid_api/util.rb,
lib/hid_api/device.rb,
lib/hid_api/version.rb,
lib/hid_api/util/wchar.rb,
lib/hid_api/device_info.rb,
lib/hid_api/wide_string.rb

Defined Under Namespace

Modules: Util Classes: Device, DeviceInfo, HidError, WideString

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.open(vendor_id, product_id, serial_number = nil) ⇒ Object

Raises:



49
50
51
52
53
# File 'lib/hid_api.rb', line 49

def open vendor_id, product_id, serial_number=nil
  device = hid_open(vendor_id, product_id, serial_number || 0)
  raise HidError, "Unable to open #{[vendor_id, product_id, serial_number].inspect}" if device.null?
  device
end

.open_path(path) ⇒ Object

Raises:



55
56
57
58
59
# File 'lib/hid_api.rb', line 55

def open_path path
  device = hid_open_path(path)
  raise HidError, "Unable to open #{path.inspect}" if device.null?
  device
end