C# Class MonoLibUsb.Transfer.MonoUsbTransfer

ファイルを表示 Open project: arvydas/BlinkStickDotNet Class Usage Examples

Public Methods

Method Description
Alloc ( int numIsoPackets ) : MonoUsbTransfer

Allocate a libusb transfer with a specified number of isochronous packet descriptors

The returned transfer is pre-initialized for you. When the new transfer is no longer needed, it should be freed with Free.

Transfers intended for non-isochronous endpoints (e.g. control, bulk, interrupt) should specify an iso_packets count of zero.

For transfers intended for isochronous endpoints, specify an appropriate number of packet descriptors to be allocated as part of the transfer. The returned transfer is not specially initialized for isochronous I/O; you are still required to set the MonoUsbTransfer.NumIsoPackets and MonoUsbTransfer.Type fields accordingly.

It is safe to allocate a transfer with some isochronous packets and then use it on a non-isochronous endpoint. If you do this, ensure that at time of submission, MonoUsbTransfer.NumIsoPackets is 0 and that type is set appropriately.

Alloc is roughly equivalent to libusb_alloc_transfer().
Cancel ( ) : MonoUsbError

Cancels this transfer.

Cancel is roughly equivalent to libusb_cancel_transfer().

FillBulk ( MonoUsbDeviceHandle devHandle, byte endpoint, IntPtr buffer, int length, Delegate callback, IntPtr userData, int timeout ) : void

Helper function to populate the required MonoUsbTransfer properties for a bulk transfer.

FillBulk is similar to libusb_fill_bulk_transfer().

FillControl ( MonoUsbDeviceHandle devHandle, MonoUsbControlSetupHandle controlSetupHandle, Delegate callback, IntPtr userData, int timeout ) : void

Helper function to populate the required MonoUsbTransfer properties for a control transfer.

Isochronous transfers are not supported on windows.

FillControl is similar to libusb_fill_control_transfer().
FillInterrupt ( MonoUsbDeviceHandle devHandle, byte endpoint, IntPtr buffer, int length, Delegate callback, IntPtr userData, int timeout ) : void

Helper function to populate the required MonoUsbTransfer properties for an interrupt transfer.

FillInterrupt is roughly equivalent to libusb_fill_interrupt_transfer().

FillIsochronous ( MonoUsbDeviceHandle devHandle, byte endpoint, IntPtr buffer, int length, int numIsoPackets, Delegate callback, IntPtr userData, int timeout ) : void

Helper function to populate the required MonoUsbTransfer properties for an isochronous transfer.

Isochronous transfers are not supported on windows.

FillIsochronous is similar to libusb_fill_iso_transfer().
Free ( ) : void

Frees this transfer.

Free is roughly equivalent to libusb_free_transfer(). Calling Free on a transfer that has already been freed will result in a double free.

GetIsoPacketBuffer ( int packet ) : IntPtr

Convenience function to locate the position of an isochronous packet within the buffer of an isochronous transfer.

This is a thorough function which loops through all preceding packets, accumulating their lengths to find the position of the specified packet. Typically you will assign equal lengths to each packet in the transfer, and hence the above method is sub-optimal. You may wish to use GetIsoPacketBufferSimple instead.

GetIsoPacketBuffer is roughly equivalent to libusb_get_iso_packet_buffer().
GetIsoPacketBufferSimple ( int packet ) : IntPtr

Convenience function to locate the position of an isochronous packet within the buffer of an isochronous transfer, for transfers where each packet is of identical size.

This function relies on the assumption that every packet within the transfer is of identical size to the first packet. Calculating the location of the packet buffer is then just a simple calculation: buffer + (packet_size * packet)

Do not use this function on transfers other than those that have identical packet lengths for each packet.

GetIsoPacketBufferSimple is roughly equivalent to libusb_get_iso_packet_buffer_simple().
IsoPacket ( int packetNumber ) : MonoUsbIsoPacket

Gets a MonoUsbIsoPacket that represents the specified iso packet descriptor.

MonoUsbTransfer ( int numIsoPackets ) : System

Allocate a libusb transfer with a specified number of isochronous packet descriptors

The transfer is pre-initialized for you. When the new transfer is no longer needed, it should be freed with Free.

Transfers intended for non-isochronous endpoints (e.g. control, bulk, interrupt) should specify an iso_packets count of zero.

For transfers intended for isochronous endpoints, specify an appropriate number of packet descriptors to be allocated as part of the transfer. The returned transfer is not specially initialized for isochronous I/O; you are still required to set the MonoUsbTransfer.NumIsoPackets and MonoUsbTransfer.Type fields accordingly.

It is safe to allocate a transfer with some isochronous packets and then use it on a non-isochronous endpoint. If you do this, ensure that at time of submission, MonoUsbTransfer.NumIsoPackets is 0 and that type is set appropriately.

SetIsoPacketLengths ( int length ) : void

Convenience function to set the length of all packets in an isochronous transfer, based on the num_iso_packets field in the transfer structure.

SetIsoPacketLengths is roughly equivalent to libusb_set_iso_packet_lengths().

Submit ( ) : MonoUsbError

Submits this transfer.

This functions submits the USB transfer and return immediately. Submit is roughly equivalent to libusb_submit_transfer().

UniqueName ( ) : String

Gets a unqiue name for this transfer.

Private Methods

Method Description
MonoUsbTransfer ( IntPtr pTransfer ) : System

Creates a new wrapper for transfers allocated by MonoUsbApi.AllocTransfer,

Method Details

Alloc() public static method

Allocate a libusb transfer with a specified number of isochronous packet descriptors

The returned transfer is pre-initialized for you. When the new transfer is no longer needed, it should be freed with Free.

Transfers intended for non-isochronous endpoints (e.g. control, bulk, interrupt) should specify an iso_packets count of zero.

For transfers intended for isochronous endpoints, specify an appropriate number of packet descriptors to be allocated as part of the transfer. The returned transfer is not specially initialized for isochronous I/O; you are still required to set the MonoUsbTransfer.NumIsoPackets and MonoUsbTransfer.Type fields accordingly.

It is safe to allocate a transfer with some isochronous packets and then use it on a non-isochronous endpoint. If you do this, ensure that at time of submission, MonoUsbTransfer.NumIsoPackets is 0 and that type is set appropriately.

Alloc is roughly equivalent to libusb_alloc_transfer().
If the transfer was not allocated.
public static Alloc ( int numIsoPackets ) : MonoUsbTransfer
numIsoPackets int number of isochronous packet descriptors to allocate.
return MonoUsbTransfer

Cancel() public method

Cancels this transfer.
Cancel is roughly equivalent to libusb_cancel_transfer().
public Cancel ( ) : MonoUsbError
return MonoUsbError

FillBulk() public method

Helper function to populate the required MonoUsbTransfer properties for a bulk transfer.
FillBulk is similar to libusb_fill_bulk_transfer().
public FillBulk ( MonoUsbDeviceHandle devHandle, byte endpoint, IntPtr buffer, int length, Delegate callback, IntPtr userData, int timeout ) : void
devHandle MonoUsbDeviceHandle handle of the device that will handle the transfer
endpoint byte address of the endpoint where this transfer will be sent
buffer System.IntPtr data buffer
length int length of data buffer
callback System.Delegate callback function to be invoked on transfer completion
userData System.IntPtr user data to pass to callback function
timeout int timeout for the transfer in milliseconds
return void

FillControl() public method

Helper function to populate the required MonoUsbTransfer properties for a control transfer.

Isochronous transfers are not supported on windows.

FillControl is similar to libusb_fill_control_transfer().
public FillControl ( MonoUsbDeviceHandle devHandle, MonoUsbControlSetupHandle controlSetupHandle, Delegate callback, IntPtr userData, int timeout ) : void
devHandle MonoUsbDeviceHandle handle of the device that will handle the transfer
controlSetupHandle MonoUsbControlSetupHandle the setup packet/control data to transfer.
callback System.Delegate callback function to be invoked on transfer completion
userData System.IntPtr user data to pass to callback function
timeout int timeout for the transfer in milliseconds
return void

FillInterrupt() public method

Helper function to populate the required MonoUsbTransfer properties for an interrupt transfer.
FillInterrupt is roughly equivalent to libusb_fill_interrupt_transfer().
public FillInterrupt ( MonoUsbDeviceHandle devHandle, byte endpoint, IntPtr buffer, int length, Delegate callback, IntPtr userData, int timeout ) : void
devHandle MonoUsbDeviceHandle handle of the device that will handle the transfer
endpoint byte address of the endpoint where this transfer will be sent
buffer System.IntPtr data buffer
length int length of data buffer
callback System.Delegate callback function to be invoked on transfer completion
userData System.IntPtr user data to pass to callback function
timeout int timeout for the transfer in milliseconds
return void

FillIsochronous() public method

Helper function to populate the required MonoUsbTransfer properties for an isochronous transfer.

Isochronous transfers are not supported on windows.

FillIsochronous is similar to libusb_fill_iso_transfer().
public FillIsochronous ( MonoUsbDeviceHandle devHandle, byte endpoint, IntPtr buffer, int length, int numIsoPackets, Delegate callback, IntPtr userData, int timeout ) : void
devHandle MonoUsbDeviceHandle handle of the device that will handle the transfer
endpoint byte address of the endpoint where this transfer will be sent
buffer System.IntPtr data buffer
length int length of data buffer
numIsoPackets int the number of isochronous packets
callback System.Delegate callback function to be invoked on transfer completion
userData System.IntPtr user data to pass to callback function
timeout int timeout for the transfer in milliseconds
return void

Free() public method

Frees this transfer.
Free is roughly equivalent to libusb_free_transfer(). Calling Free on a transfer that has already been freed will result in a double free.
public Free ( ) : void
return void

GetIsoPacketBuffer() public method

Convenience function to locate the position of an isochronous packet within the buffer of an isochronous transfer.

This is a thorough function which loops through all preceding packets, accumulating their lengths to find the position of the specified packet. Typically you will assign equal lengths to each packet in the transfer, and hence the above method is sub-optimal. You may wish to use GetIsoPacketBufferSimple instead.

GetIsoPacketBuffer is roughly equivalent to libusb_get_iso_packet_buffer().
This exception is thrown if the packet requested is >= .
public GetIsoPacketBuffer ( int packet ) : IntPtr
packet int The packet to return the address of.
return System.IntPtr

GetIsoPacketBufferSimple() public method

Convenience function to locate the position of an isochronous packet within the buffer of an isochronous transfer, for transfers where each packet is of identical size.

This function relies on the assumption that every packet within the transfer is of identical size to the first packet. Calculating the location of the packet buffer is then just a simple calculation: buffer + (packet_size * packet)

Do not use this function on transfers other than those that have identical packet lengths for each packet.

GetIsoPacketBufferSimple is roughly equivalent to libusb_get_iso_packet_buffer_simple().
This exception is thrown if the packet requested is >= .
public GetIsoPacketBufferSimple ( int packet ) : IntPtr
packet int The packet to return the address of.
return System.IntPtr

IsoPacket() public method

Gets a MonoUsbIsoPacket that represents the specified iso packet descriptor.
public IsoPacket ( int packetNumber ) : MonoUsbIsoPacket
packetNumber int The iso packet descriptor to return.
return MonoUsbIsoPacket

MonoUsbTransfer() public method

Allocate a libusb transfer with a specified number of isochronous packet descriptors

The transfer is pre-initialized for you. When the new transfer is no longer needed, it should be freed with Free.

Transfers intended for non-isochronous endpoints (e.g. control, bulk, interrupt) should specify an iso_packets count of zero.

For transfers intended for isochronous endpoints, specify an appropriate number of packet descriptors to be allocated as part of the transfer. The returned transfer is not specially initialized for isochronous I/O; you are still required to set the MonoUsbTransfer.NumIsoPackets and MonoUsbTransfer.Type fields accordingly.

It is safe to allocate a transfer with some isochronous packets and then use it on a non-isochronous endpoint. If you do this, ensure that at time of submission, MonoUsbTransfer.NumIsoPackets is 0 and that type is set appropriately.

public MonoUsbTransfer ( int numIsoPackets ) : System
numIsoPackets int number of isochronous packet descriptors to allocate.
return System

SetIsoPacketLengths() public method

Convenience function to set the length of all packets in an isochronous transfer, based on the num_iso_packets field in the transfer structure.
SetIsoPacketLengths is roughly equivalent to libusb_set_iso_packet_lengths().
public SetIsoPacketLengths ( int length ) : void
length int The length to set in each isochronous packet descriptor.
return void

Submit() public method

Submits this transfer.
This functions submits the USB transfer and return immediately. Submit is roughly equivalent to libusb_submit_transfer().
public Submit ( ) : MonoUsbError
return MonoUsbError

UniqueName() public method

Gets a unqiue name for this transfer.
public UniqueName ( ) : String
return String