Class: USB::Device
- Inherits:
-
Data
- Object
- Data
- USB::Device
- Defined in:
- lib/usb.rb,
ext/usb/usb.c
Overview
:startdoc:
Instance Method Summary collapse
-
#bcdDevice ⇒ Object
USB::Device#descriptor_bcdDevice.
-
#bcdUSB ⇒ Object
USB::Device#descriptor_bcdUSB.
-
#bDescriptorType ⇒ Object
USB::Device#descriptor_bDescriptorType.
-
#bDeviceClass ⇒ Object
USB::Device#descriptor_bDeviceClass.
-
#bDeviceProtocol ⇒ Object
USB::Device#descriptor_bDeviceProtocol.
-
#bDeviceSubClass ⇒ Object
USB::Device#descriptor_bDeviceSubClass.
-
#bLength ⇒ Object
USB::Device#descriptor_bLength.
-
#bMaxPacketSize0 ⇒ Object
USB::Device#descriptor_bMaxPacketSize0.
-
#bNumConfigurations ⇒ Object
USB::Device#descriptor_bNumConfigurations.
-
#bus ⇒ Object
USB::Device#bus.
-
#children ⇒ Object
USB::Device#children.
-
#configurations ⇒ Object
USB::Device#configurations.
-
#devnum ⇒ Object
USB::Device#devnum.
- #endpoints ⇒ Object
-
#filename ⇒ Object
USB::Device#filename.
-
#idProduct ⇒ Object
USB::Device#descriptor_idProduct.
-
#idVendor ⇒ Object
USB::Device#descriptor_idVendor.
-
#iManufacturer ⇒ Object
USB::Device#descriptor_iManufacturer.
- #inspect ⇒ Object
- #interfaces ⇒ Object
-
#iProduct ⇒ Object
USB::Device#descriptor_iProduct.
-
#iSerialNumber ⇒ Object
USB::Device#descriptor_iSerialNumber.
- #manufacturer ⇒ Object
-
#next ⇒ Object
USB::Device#next.
-
#num_children ⇒ Object
USB::Device#num_children.
- #open ⇒ Object
-
#prev ⇒ Object
USB::Device#prev.
- #product ⇒ Object
-
#revoked? ⇒ Boolean
USB::Bus#revoked?.
- #serial_number ⇒ Object
- #settings ⇒ Object
-
#usb_open ⇒ Object
USB::Device#usb_open.
Instance Method Details
#bcdDevice ⇒ Object
USB::Device#descriptor_bcdDevice
235 |
# File 'ext/usb/usb.c', line 235 static VALUE rusb_devdesc_bcdDevice(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.bcdDevice); } |
#bcdUSB ⇒ Object
USB::Device#descriptor_bcdUSB
214 |
# File 'ext/usb/usb.c', line 214 static VALUE rusb_devdesc_bcdUSB(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.bcdUSB); } |
#bDescriptorType ⇒ Object
USB::Device#descriptor_bDescriptorType
211 |
# File 'ext/usb/usb.c', line 211 static VALUE rusb_devdesc_bDescriptorType(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.bDescriptorType); } |
#bDeviceClass ⇒ Object
USB::Device#descriptor_bDeviceClass
217 |
# File 'ext/usb/usb.c', line 217 static VALUE rusb_devdesc_bDeviceClass(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.bDeviceClass); } |
#bDeviceProtocol ⇒ Object
USB::Device#descriptor_bDeviceProtocol
223 |
# File 'ext/usb/usb.c', line 223 static VALUE rusb_devdesc_bDeviceProtocol(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.bDeviceProtocol); } |
#bDeviceSubClass ⇒ Object
USB::Device#descriptor_bDeviceSubClass
220 |
# File 'ext/usb/usb.c', line 220 static VALUE rusb_devdesc_bDeviceSubClass(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.bDeviceSubClass); } |
#bLength ⇒ Object
USB::Device#descriptor_bLength
208 |
# File 'ext/usb/usb.c', line 208 static VALUE rusb_devdesc_bLength(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.bLength); } |
#bMaxPacketSize0 ⇒ Object
USB::Device#descriptor_bMaxPacketSize0
226 |
# File 'ext/usb/usb.c', line 226 static VALUE rusb_devdesc_bMaxPacketSize0(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.bMaxPacketSize0); } |
#bNumConfigurations ⇒ Object
USB::Device#descriptor_bNumConfigurations
247 |
# File 'ext/usb/usb.c', line 247 static VALUE rusb_devdesc_bNumConfigurations(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.bNumConfigurations); } |
#bus ⇒ Object
USB::Device#bus
186 |
# File 'ext/usb/usb.c', line 186 static VALUE rusb_device_bus(VALUE v) { return rusb_bus_make(get_usb_device(v)->bus, Qnil); } |
#children ⇒ Object
USB::Device#children
195 196 197 198 199 200 201 202 203 204 205 |
# File 'ext/usb/usb.c', line 195 static VALUE rusb_device_children(VALUE vdevice) { rusb_device_t *d = get_rusb_device(vdevice); struct usb_device *device = d->ptr; int i; VALUE children = rb_ary_new2(device->num_children); for (i = 0; i < device->num_children; i++) rb_ary_store(children, i, rusb_device_make(device->children[i], d->parent)); return children; } |
#configurations ⇒ Object
USB::Device#configurations
250 251 252 253 254 255 256 257 258 259 |
# File 'ext/usb/usb.c', line 250 static VALUE rusb_device_config(VALUE v) { struct usb_device *device = get_usb_device(v); int i; VALUE children = rb_ary_new2(device->descriptor.bNumConfigurations); for (i = 0; i < device->descriptor.bNumConfigurations; i++) rb_ary_store(children, i, rusb_config_descriptor_make(&device->config[i], v)); return children; } |
#devnum ⇒ Object
USB::Device#devnum
189 |
# File 'ext/usb/usb.c', line 189 static VALUE rusb_device_devnum(VALUE v) { return INT2FIX(get_usb_device(v)->devnum); } |
#endpoints ⇒ Object
289 |
# File 'lib/usb.rb', line 289 def endpoints() self.settings.map {|d| d.endpoints }.flatten end |
#filename ⇒ Object
USB::Device#filename
183 |
# File 'ext/usb/usb.c', line 183 static VALUE rusb_device_filename(VALUE v) { return rb_str_new2(get_usb_device(v)->filename); } |
#idProduct ⇒ Object
USB::Device#descriptor_idProduct
232 |
# File 'ext/usb/usb.c', line 232 static VALUE rusb_devdesc_idProduct(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.idProduct); } |
#idVendor ⇒ Object
USB::Device#descriptor_idVendor
229 |
# File 'ext/usb/usb.c', line 229 static VALUE rusb_devdesc_idVendor(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.idVendor); } |
#iManufacturer ⇒ Object
USB::Device#descriptor_iManufacturer
238 |
# File 'ext/usb/usb.c', line 238 static VALUE rusb_devdesc_iManufacturer(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.iManufacturer); } |
#inspect ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/usb.rb', line 230 def inspect if self.revoked? "\#<#{self.class} revoked>" else attrs = [] attrs << "#{self.bus.dirname}/#{self.filename}" attrs << ("%04x:%04x" % [self.idVendor, self.idProduct]) attrs << self.manufacturer attrs << self.product attrs << self.serial_number if self.bDeviceClass == USB::USB_CLASS_PER_INTERFACE devclass = self.settings.map {|i| USB.dev_string(i.bInterfaceClass, i.bInterfaceSubClass, i.bInterfaceProtocol) }.join(", ") else devclass = USB.dev_string(self.bDeviceClass, self.bDeviceSubClass, self.bDeviceProtocol) end attrs << "(#{devclass})" attrs.compact! "\#<#{self.class} #{attrs.join(' ')}>" end end |
#interfaces ⇒ Object
287 |
# File 'lib/usb.rb', line 287 def interfaces() self.configurations.map {|d| d.interfaces }.flatten end |
#iProduct ⇒ Object
USB::Device#descriptor_iProduct
241 |
# File 'ext/usb/usb.c', line 241 static VALUE rusb_devdesc_iProduct(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.iProduct); } |
#iSerialNumber ⇒ Object
USB::Device#descriptor_iSerialNumber
244 |
# File 'ext/usb/usb.c', line 244 static VALUE rusb_devdesc_iSerialNumber(VALUE v) { return INT2FIX(get_usb_device(v)->descriptor.iSerialNumber); } |
#manufacturer ⇒ Object
253 254 255 256 257 258 |
# File 'lib/usb.rb', line 253 def manufacturer return @manufacturer if defined? @manufacturer @manufacturer = self.open {|h| h.get_string_simple(self.iManufacturer) } @manufacturer.strip! if @manufacturer @manufacturer end |
#next ⇒ Object
USB::Device#next
180 |
# File 'ext/usb/usb.c', line 180 static VALUE rusb_device_next(VALUE v) { rusb_device_t *device = get_rusb_device(v); return rusb_device_make(device->ptr->next, device->parent); } |
#num_children ⇒ Object
USB::Device#num_children
192 |
# File 'ext/usb/usb.c', line 192 static VALUE rusb_device_num_children(VALUE v) { return INT2FIX(get_usb_device(v)->num_children); } |
#open ⇒ Object
274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/usb.rb', line 274 def open h = self.usb_open if block_given? begin r = yield h ensure h.usb_close end else h end end |
#prev ⇒ Object
USB::Device#prev
177 |
# File 'ext/usb/usb.c', line 177 static VALUE rusb_device_prev(VALUE v) { rusb_device_t *device = get_rusb_device(v); return rusb_device_make(device->ptr->prev, device->parent); } |
#product ⇒ Object
260 261 262 263 264 265 |
# File 'lib/usb.rb', line 260 def product return @product if defined? @product @product = self.open {|h| h.get_string_simple(self.iProduct) } @product.strip! if @product @product end |
#revoked? ⇒ Boolean
USB::Bus#revoked?
170 171 172 173 174 |
# File 'ext/usb/usb.c', line 170 static VALUE rusb_device_revoked_p(VALUE v) { return RTEST(!check_usb_device(v)); } |
#serial_number ⇒ Object
267 268 269 270 271 272 |
# File 'lib/usb.rb', line 267 def serial_number return @serial_number if defined? @serial_number @serial_number = self.open {|h| h.get_string_simple(self.iSerialNumber) } @serial_number.strip! if @serial_number @serial_number end |
#settings ⇒ Object
288 |
# File 'lib/usb.rb', line 288 def settings() self.interfaces.map {|d| d.settings }.flatten end |
#usb_open ⇒ Object
USB::Device#usb_open
262 263 264 265 266 267 268 |
# File 'ext/usb/usb.c', line 262 static VALUE rusb_device_open(VALUE vdevice) { struct usb_device *device = get_usb_device(vdevice); usb_dev_handle *h = usb_open(device); return rusb_dev_handle_new(h); } |