Pregunta

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

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top