/// <summary> /// Helper function to populate the required <see cref="MonoUsbTransfer"/> properties for a control transfer. /// </summary> /// <remarks> /// <note type="tip"> /// <para>Isochronous transfers are not supported on windows.</para> /// </note> /// <note title="Libusb-1.0 API Note:" type="cpp"> /// <see cref="FillControl"/> is similar to /// <a href="http://libusb.sourceforge.net/api-1.0/group__asyncio.html#ga3a8513ed87229fe2c9771ef0bf17206e">libusb_fill_control_transfer()</a>. /// </note> /// </remarks> /// <param name="devHandle">handle of the device that will handle the transfer</param> /// <param name="controlSetupHandle">the setup packet/control data to transfer.</param> /// <param name="callback">callback function to be invoked on transfer completion</param> /// <param name="userData">user data to pass to callback function</param> /// <param name="timeout">timeout for the transfer in milliseconds</param> public void FillControl(MonoUsbDeviceHandle devHandle, MonoUsbControlSetupHandle controlSetupHandle, Delegate callback, IntPtr userData, int timeout) { PtrDeviceHandle = devHandle.DangerousGetHandle(); Endpoint = 0; PtrCallbackFn = Marshal.GetFunctionPointerForDelegate(callback); PtrUserData = userData; Timeout = timeout; Type = EndpointType.Control; Flags = MonoUsbTransferFlags.None; IntPtr pSetupPacket = controlSetupHandle.DangerousGetHandle(); PtrBuffer = pSetupPacket; MonoUsbControlSetup w = new MonoUsbControlSetup(pSetupPacket); Length = MonoUsbControlSetup.SETUP_PACKET_SIZE + w.Length; }
/// <summary> /// Helper function to populate the required <see cref="MonoUsbTransfer"/> properties for an interrupt transfer. /// </summary> /// <remarks> /// <note title="Libusb-1.0 API Note:" type="cpp"> /// <see cref="FillInterrupt"/> is roughly equivalent to /// <a href="http://libusb.sourceforge.net/api-1.0/group__asyncio.html#ga90f53cea1124a7566df1aa1202b77510">libusb_fill_interrupt_transfer()</a>. /// </note> /// </remarks> /// <param name="devHandle">handle of the device that will handle the transfer</param> /// <param name="endpoint">address of the endpoint where this transfer will be sent</param> /// <param name="buffer">data buffer</param> /// <param name="length">length of data buffer</param> /// <param name="callback">callback function to be invoked on transfer completion</param> /// <param name="userData">user data to pass to callback function</param> /// <param name="timeout">timeout for the transfer in milliseconds</param> public void FillInterrupt(MonoUsbDeviceHandle devHandle, byte endpoint, IntPtr buffer, int length, Delegate callback, IntPtr userData, int timeout) { PtrDeviceHandle = devHandle.DangerousGetHandle(); Endpoint = endpoint; PtrBuffer = buffer; Length = length; PtrCallbackFn = Marshal.GetFunctionPointerForDelegate(callback); PtrUserData = userData; Timeout = timeout; Type = EndpointType.Interrupt; Flags = MonoUsbTransferFlags.None; }
/// <summary> /// Helper function to populate the required <see cref="MonoUsbTransfer"/> properties for an isochronous transfer. /// </summary> /// <remarks> /// <note type="tip"> /// <para>Isochronous transfers are not supported on windows.</para> /// </note> /// <note title="Libusb-1.0 API Note:" type="cpp"> /// <see cref="FillIsochronous"/> is similar to /// <a href="http://libusb.sourceforge.net/api-1.0/group__asyncio.html#ga30fdce8c461e851f0aa4c851014e1aa7">libusb_fill_iso_transfer()</a>. /// </note> /// </remarks> /// <param name="devHandle">handle of the device that will handle the transfer</param> /// <param name="endpoint">address of the endpoint where this transfer will be sent</param> /// <param name="buffer">data buffer</param> /// <param name="length">length of data buffer</param> /// <param name="numIsoPackets">the number of isochronous packets</param> /// <param name="callback">callback function to be invoked on transfer completion</param> /// <param name="userData">user data to pass to callback function</param> /// <param name="timeout">timeout for the transfer in milliseconds</param> public void FillIsochronous(MonoUsbDeviceHandle devHandle, byte endpoint, IntPtr buffer, int length,int numIsoPackets, Delegate callback, IntPtr userData, int timeout) { PtrDeviceHandle = devHandle.DangerousGetHandle(); Endpoint = endpoint; PtrBuffer = buffer; Length = length; PtrCallbackFn = Marshal.GetFunctionPointerForDelegate(callback); PtrUserData = userData; Timeout = timeout; Type = EndpointType.Isochronous; Flags = MonoUsbTransferFlags.None; NumIsoPackets = numIsoPackets; }