internal void WaitForCompletion() { if (asyncResult == null) { throw new ScopeIOException("Can't wait for command's completion before executing command"); } try { if (endPoint.IsOut) { endPoint.EndWrite(asyncResult); } else if (endPoint.IsIn) { endPoint.EndRead(asyncResult); } else { throw new ScopeIOException("Unknown endpoint type"); } } catch (USBException e) { Error = e; bytesTransferred = 0; buffer = null; return; } MadWizard.WinUSBNet.USBAsyncResult usbresult = (MadWizard.WinUSBNet.USBAsyncResult)asyncResult; if (usbresult.Error != null) { Error = usbresult.Error; success = false; bytesTransferred = 0; buffer = null; } else { bytesTransferred = usbresult.BytesTransfered; } }
internal void WaitForCompletion() { if (asyncResult == null) { throw new ScopeIOException("Can't wait for command's completion before executing command"); } try { if (endPoint.IsOut) { endPoint.EndWrite(asyncResult); } else if (endPoint.IsIn) { endPoint.EndRead(asyncResult); } else { throw new ScopeIOException("Unknown endpoint type"); } } catch (Exception e) { throw new ScopeIOException("USB Error occurred: " + e.Message); } USBAsyncResult usbresult = (USBAsyncResult)asyncResult; if (usbresult.Error != null) { throw new ScopeIOException("USB Error occurred: " + usbresult.Error.Message); } if (usbresult.BytesTransfered != length) { throw new ScopeIOException(String.Format("Only transferred {0:d} out of {1:d} bytes", usbresult.BytesTransfered, length)); } }