문제

I tried to run some code with libusb:

require 'libusb'
USB::devices.each { |d| puts "device (#{d.product_name}) vendor: #{d.vendor_id} product: #{d.product_id}" }

But when i run it:

C:\icd_programm>ruby libusb.rb
libusb.rb:2:in `<main>': uninitialized constant USB (NameError)

Why do i get such an error? I followed this instructions:http://www.technofetish.net/mike/demo1.txt

도움이 되었습니까?

해결책

The error means that there is no class or module named USB. The instructions you referred to seem to use an older version of libusb that originally defined the USB module.

Here's how to do it in newer versions of libusb:

require 'libusb'

usb = LIBUSB::Context.new
usb.devices.each{ ... }

Source: https://github.com/larskanis/libusb

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top