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); }
public LibUSBProvider() { //Create the LibUSB instance LibUSBNative.ThrowIfError(LibUSBNative.libusb_init(ref ctx)); //Create event thread eventThread = new Thread(EventLoop); eventThread.Name = "LibUSB Provider Event Loop"; eventThread.IsBackground = true; eventThread.Start(); }
public bool OpenDevice() { //If it's already opened, return true if (isOpened) { return(true); } //Request the device to be opened handle = IntPtr.Zero; isOpened = LibUSBNative.libusb_open(device, ref handle) == 0; if (!isOpened) { return(false); } //Set config LibUSBNative.ThrowIfError(LibUSBNative.libusb_set_configuration(handle, 1)); LibUSBNative.ThrowIfError(LibUSBNative.libusb_claim_interface(handle, 0)); return(true); }
public void SubmitTransfer() { LibUSBNative.ThrowIfError(LibUSBNative.libusb_submit_transfer(transfer)); }