Пример #1
0
        public async Task <int> SendOutputReportAsync(Win32HidOutputReport report,
                                                      CancellationToken cancellationToken = default(CancellationToken))
        {
            if (report == null)
            {
                throw new ArgumentNullException(nameof(report));
            }

            var outputBuffer = report.GetOutputBuffer();

            log.Trace("Sending output report:\r\n\r\n " + outputBuffer.ToHexString());
            log.Trace(outputBuffer.ToLoggableAsHex("Sending output report:"));
            try
            {
                return(await Kernel32Dll.WriteFileAsync(Handle, outputBuffer, cancellationToken));
            }
            catch (Win32Exception exception)
            {
                log.Error("Sending output report failed", exception);
                throw ExceptionConversion.ConvertException(exception);
            }
            catch (Exception exception)
            {
                log.Error("Sending output report failed", exception);
                throw;
            }
        }
Пример #2
0
        public async Task<int> SendOutputReportAsync(Win32HidOutputReport report,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (report == null) throw new ArgumentNullException(nameof(report));

            var outputBuffer = report.GetOutputBuffer();
            log.Trace("Sending output report:\r\n\r\n " + outputBuffer.ToHexString());
            log.Trace(outputBuffer.ToLoggableAsHex("Sending output report:"));
            try
            {
                return await Kernel32Dll.WriteFileAsync(Handle, outputBuffer, cancellationToken);
            }
            catch (Win32Exception exception)
            {
                log.Error("Sending output report failed", exception);
                throw ExceptionConversion.ConvertException(exception);
            }
            catch (Exception exception)
            {
                log.Error("Sending output report failed", exception);
                throw;
            }
        }