Пример #1
0
 public async Task <ReadResult> ReadAsync(uint bufferLength)
 {
     return(await Task.Run(() =>
     {
         var bytes = new byte[bufferLength];
         var isSuccess = WinUsbApiCalls.WinUsb_ReadPipe(_SafeFileHandle, ReadEndpoint.PipeId, bytes, bufferLength, out var bytesRead, IntPtr.Zero);
         WindowsDeviceBase.HandleError(isSuccess, "Couldn't read data");
         Tracer?.Trace(false, bytes);
         return new ReadResult(bytes, bytesRead);
     }));
 }
Пример #2
0
 public override async Task <byte[]> ReadAsync()
 {
     return(await Task.Run(() =>
     {
         var bytes = new byte[ReadBufferSize];
         //TODO: Allow for different interfaces and pipes...
         var isSuccess = WinUsbApiCalls.WinUsb_ReadPipe(_DefaultUsbInterface.Handle, _DefaultUsbInterface.ReadPipe.WINUSB_PIPE_INFORMATION.PipeId, bytes, ReadBufferSize, out var bytesRead, IntPtr.Zero);
         HandleError(isSuccess, "Couldn't read data");
         Tracer?.Trace(false, bytes);
         return bytes;
     }));
 }