Class: USB::Configuration

Inherits:
Data
  • Object
show all
Defined in:
lib/usb.rb,
ext/usb/usb.c

Instance Method Summary collapse

Instance Method Details

#bConfigurationValueObject

USB::Configuration#bConfigurationValue



295
# File 'ext/usb/usb.c', line 295

static VALUE rusb_config_bConfigurationValue(VALUE v) { return INT2FIX(get_usb_config_descriptor(v)->bConfigurationValue); }

#bDescriptorTypeObject

USB::Configuration#bDescriptorType



286
# File 'ext/usb/usb.c', line 286

static VALUE rusb_config_bDescriptorType(VALUE v) { return INT2FIX(get_usb_config_descriptor(v)->bDescriptorType); }

#bLengthObject

USB::Configuration#bLength



283
# File 'ext/usb/usb.c', line 283

static VALUE rusb_config_bLength(VALUE v) { return INT2FIX(get_usb_config_descriptor(v)->bLength); }

#bmAttributesObject

USB::Configuration#bmAttributes



301
# File 'ext/usb/usb.c', line 301

static VALUE rusb_config_bmAttributes(VALUE v) { return INT2FIX(get_usb_config_descriptor(v)->bmAttributes); }

#bMaxPowerObject

USB::Configuration#bMaxPower



304
# File 'ext/usb/usb.c', line 304

static VALUE rusb_config_bMaxPower(VALUE v) { return INT2FIX(get_usb_config_descriptor(v)->MaxPower); }

#bNumInterfacesObject

USB::Configuration#bNumInterfaces



292
# File 'ext/usb/usb.c', line 292

static VALUE rusb_config_bNumInterfaces(VALUE v) { return INT2FIX(get_usb_config_descriptor(v)->bNumInterfaces); }

#busObject



313
# File 'lib/usb.rb', line 313

def bus() self.device.bus end

#descriptionObject



308
309
310
311
# File 'lib/usb.rb', line 308

def description
  return @description if defined? @description
  @description = self.device.open {|h| h.get_string_simple(self.iConfiguration) }
end

#deviceObject

USB::Configuration#device



280
# File 'ext/usb/usb.c', line 280

static VALUE rusb_config_device(VALUE v) { return get_rusb_config_descriptor(v)->parent; }

#endpointsObject



316
# File 'lib/usb.rb', line 316

def endpoints() self.settings.map {|d| d.endpoints }.flatten end

#iConfigurationObject

USB::Configuration#iConfiguration



298
# File 'ext/usb/usb.c', line 298

static VALUE rusb_config_iConfiguration(VALUE v) { return INT2FIX(get_usb_config_descriptor(v)->iConfiguration); }

#inspectObject



293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/usb.rb', line 293

def inspect
  if self.revoked?
    "\#<#{self.class} revoked>"
  else
    attrs = []
    attrs << self.bConfigurationValue.to_s
    bits = self.bmAttributes
    attrs << "SelfPowered" if (bits & 0b1000000) != 0
    attrs << "RemoteWakeup" if (bits & 0b100000) != 0
    desc = self.description
    attrs << desc if desc != '?'
    "\#<#{self.class} #{attrs.join(' ')}>"
  end
end

#interfacesObject

USB::Configuration#interfaces



307
308
309
310
311
312
313
314
315
316
# File 'ext/usb/usb.c', line 307

static VALUE
rusb_config_interfaces(VALUE v)
{
  struct usb_config_descriptor *p = get_usb_config_descriptor(v);
  int i;
  VALUE interface = rb_ary_new2(p->bNumInterfaces);
  for (i = 0; i < p->bNumInterfaces; i++)
    rb_ary_store(interface, i, rusb_interface_make(&p->interface[i], v));
  return interface;
}

#revoked?Boolean

USB::Configuration#revoked?

Returns:

  • (Boolean)


273
274
275
276
277
# File 'ext/usb/usb.c', line 273

static VALUE
rusb_config_revoked_p(VALUE v)
{
  return RTEST(!check_usb_config_descriptor(v));
}

#settingsObject



315
# File 'lib/usb.rb', line 315

def settings() self.interfaces.map {|d| d.settings }.flatten end

#wTotalLengthObject

USB::Configuration#wTotalLength



289
# File 'ext/usb/usb.c', line 289

static VALUE rusb_config_wTotalLength(VALUE v) { return INT2FIX(get_usb_config_descriptor(v)->wTotalLength); }