private int ControlTransfer(byte flags, byte fieldRequest, ushort fieldValue, ushort fieldIndex, UsbBuffer buffer, uint timeout) { //Apply int code; if (buffer != null) { code = LibUSBNative.libusb_control_transfer(handle, flags, fieldRequest, fieldValue, fieldIndex, buffer.AsPtr(), (ushort)buffer.ByteLength, timeout); } else { code = LibUSBNative.libusb_control_transfer(handle, flags, fieldRequest, fieldValue, fieldIndex, null, 0, timeout); } //Valiate if (code < 0) { throw new Exception("Unknown USB transfer write error."); } return(code); }
public int BulkTransfer(UsbTransferDirection direction, byte endpoint, UsbBuffer buffer, int timeout) { int transferred; LibUSBNative.ThrowIfError(LibUSBNative.libusb_bulk_transfer(handle, (byte)(endpoint | (byte)direction), buffer.AsPtr(), buffer.ByteLength, &transferred, (uint)timeout)); return(transferred); }