Class: LIBUSB::IsochronousTransfer

Inherits:
Transfer
  • Object
show all
Defined in:
lib/libusb/transfer.rb

Constant Summary

Constants inherited from Transfer

Transfer::TransferStatusToError

Instance Attribute Summary

Attributes inherited from Transfer

#allow_device_memory, #dev_handle

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Transfer

#actual_buffer, #actual_length, #alloc_buffer, #buffer, #buffer=, #callback=, #cancel!, #endpoint=, #free_buffer, #memory_type, #status, #submit!, #submit_and_wait, #submit_and_wait!, #timeout, #timeout=

Constructor Details

#initialize(num_packets, args = {}) ⇒ IsochronousTransfer

Returns a new instance of IsochronousTransfer.


379
380
381
382
383
384
385
386
# File 'lib/libusb/transfer.rb', line 379

def initialize(num_packets, args={})
  @ptr = Call.libusb_alloc_transfer(num_packets)
  @transfer = Call::Transfer.new @ptr
  @transfer[:type] = TRANSFER_TYPE_ISOCHRONOUS
  @transfer[:timeout] = 1000
  @transfer[:num_iso_packets] = num_packets
  super(args)
end

Class Method Details

.newObject


375
376
377
# File 'lib/libusb/transfer.rb', line 375

def self.new(*)
  super
end

Instance Method Details

#[](nr) ⇒ Object


395
396
397
# File 'lib/libusb/transfer.rb', line 395

def [](nr)
  IsoPacket.new( @ptr + Call::Transfer.size + nr*Call::IsoPacketDescriptor.size, nr)
end

#num_packetsObject


388
389
390
# File 'lib/libusb/transfer.rb', line 388

def num_packets
  @transfer[:num_iso_packets]
end

#num_packets=(number) ⇒ Object


391
392
393
# File 'lib/libusb/transfer.rb', line 391

def num_packets=(number)
  @transfer[:num_iso_packets] = number
end

#packet_lengths=(len) ⇒ Object

Convenience function to set the length of all packets in an isochronous transfer, based on #num_packets.


401
402
403
404
405
406
407
# File 'lib/libusb/transfer.rb', line 401

def packet_lengths=(len)
  ptr = @ptr + Call::Transfer.size
  num_packets.times do
    ptr.write_uint(len)
    ptr += Call::IsoPacketDescriptor.size
  end
end