/// <summary> /// This is the low level call to do a control transfer at the Android level. This can be overriden in the contructor /// </summary> private static Task <TransferResult> PerformControlTransferAndroid( UsbDeviceConnection usbDeviceConnection, SetupPacket setupPacket, byte[] buffer = null, int?timeout = null, CancellationToken cancellationToken = default) => //Use Task.Run so we can pass the cancellation token in instead of using the async control transfer method which doesn't have a cancellation token Task.Run(() => { var bytesTransferred = usbDeviceConnection.ControlTransfer( setupPacket.RequestType.Direction == RequestDirection.In ? UsbAddressing.In : UsbAddressing.Out, setupPacket.Request, setupPacket.Value, setupPacket.Index, buffer, setupPacket.Length, timeout ?? 0 ); return(new TransferResult(buffer, (uint)bytesTransferred)); }, cancellationToken);
private int SendAcmControlMessage(int request, int value, byte[] buf) => _connection.ControlTransfer((UsbAddressing)UsbRtAcm, request, value, 1, buf, buf?.Length ?? 0, 100);