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.



383
384
385
386
387
388
389
390
# File 'lib/libusb/transfer.rb', line 383

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



379
380
381
# File 'lib/libusb/transfer.rb', line 379

def self.new(*)
  super
end

Instance Method Details

#[](nr) ⇒ Object



399
400
401
# File 'lib/libusb/transfer.rb', line 399

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

#num_packetsObject



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

def num_packets
  @transfer[:num_iso_packets]
end

#num_packets=(number) ⇒ Object



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

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.



405
406
407
408
409
410
411
# File 'lib/libusb/transfer.rb', line 405

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