Method: LIBUSB::Device#max_iso_packet_size

Defined in:
lib/libusb/device.rb

#max_iso_packet_size(endpoint) ⇒ Fixnum

Calculate the maximum packet size which a specific endpoint is capable is sending or receiving in the duration of 1 microframe.

Only the active configution is examined. The calculation is based on the wMaxPacketSize field in the endpoint descriptor as described in section 9.6.6 in the USB 2.0 specifications.

If acting on an isochronous or interrupt endpoint, this function will multiply the value found in bits 0:10 by the number of transactions per microframe (determined by bits 11:12). Otherwise, this function just returns the numeric value found in bits 0:10.

This function is useful for setting up isochronous transfers, for example you might use the return value from this function to call IsoPacket#alloc_buffer in order to set the length field of an isochronous packet in a transfer.

Parameters:

  • endpoint (Endpoint, Fixnum)

    (address of) the endpoint in question

Returns:

  • (Fixnum)

    the maximum packet size which can be sent/received on this endpoint

See Also:


224
225
226
227
228
229
# File 'lib/libusb/device.rb', line 224

def max_iso_packet_size(endpoint)
  endpoint = endpoint.bEndpointAddress if endpoint.respond_to? :bEndpointAddress
  res = Call.libusb_get_max_iso_packet_size(@pDev, endpoint)
  LIBUSB.raise_error res, "in libusb_get_max_iso_packet_size" unless res>=0
  res
end