lib/hidapi/device.rb
def read_string(index, on_failure = '')
      begin
        # does not require an interface, so open from the usb_dev instead of using our open method.
        data = mutex.synchronize do
          if open?
            handle.string_descriptor_ascii(index)
          else
            usb_device.open { |handle| handle.string_descriptor_ascii(index) }
          end
        end

        HIDAPI.debug("read string at index #{index} for device #{path}: #{data.inspect}")
        data
      rescue =>e
        HIDAPI.debug("failed to read string at index #{index} for device #{path}: #{e.inspect}")
        on_failure || ''
      end
    end
def read_string(index, on_failure = '')
      begin
        # does not require an interface, so open from the usb_dev instead of using our open method.
        data = mutex.synchronize do
          if open?
            handle.string_descriptor_ascii(index)
          else
            usb_device.open { |handle| handle.string_descriptor_ascii(index) }
          end
        end

        HIDAPI.debug("read string at index #{index} for device #{path}: #{data.inspect}")
        data
      rescue =>e
        HIDAPI.debug("failed to read string at index #{index} for device #{path}: #{e.inspect}")
        on_failure || ''
      end
    end
def read_string ( index , on_failure = '' ) begin # does not require an interface, so open from the usb_dev instead of using our open method. data = mutex . synchronize do if open? handle . string_descriptor_ascii ( index ) else usb_device . open { | handle | handle . string_descriptor_ascii ( index ) } end end HIDAPI . debug ( "read string at index #{index} for device #{path}: #{data.inspect}" ) data rescue => e HIDAPI . debug ( "failed to read string at index #{index} for device #{path}: #{e.inspect}" ) on_failure || '' end end
Reads a string descriptor from the USB device.
Reads a string descriptor from the USB device .