Method: LIBUSB::Device#open
- Defined in:
- lib/libusb/device.rb
#open ⇒ DevHandle
Open the device and obtain a device handle.
A handle allows you to perform I/O on the device in question. This is a non-blocking function; no requests are sent over the bus.
If called with a block, the handle is passed to the block and is closed when the block has finished.
You need proper device access:
-
Linux: read+write permissions to
/dev/bus/usb/<bus>/<dev>
-
Windows: by installing a WinUSB-driver for the device (see README )
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/libusb/device.rb', line 58 def open ppHandle = FFI::MemoryPointer.new :pointer res = Call.libusb_open(@pDev, ppHandle) LIBUSB.raise_error res, "in libusb_open" if res!=0 handle = DevHandle.new self, ppHandle.read_pointer return handle unless block_given? begin yield handle ensure handle.close end end |