public void GetData(byte[] buffer, int offset, int length) { UsbCommand cmd = new UsbCommand(dataEndpoint, buffer, offset, length); cmd.Execute(usbLock); cmd.WaitForCompletion(); }
public void WriteControlBytesBulk(byte[] message, int offset, int length, bool async = false) { if (commandWriteEndpoint == null) { throw new ScopeIOException("Command write endpoint is null"); } UsbCommand cmd = new UsbCommand(commandWriteEndpoint, message, offset, length, USB_TIMEOUT); cmd.Execute(usbLock); if (!async) { cmd.WaitForCompletion(); if (cmd.bytesReadOrWritten != length) { throw new ScopeIOException(String.Format("Only wrote {0} out of {1} bytes", cmd.bytesReadOrWritten, length)); } switch (cmd.resultCode) { case ErrorCode.Success: break; default: throw new ScopeIOException("Failed to read from USB device : " + cmd.resultCode.ToString("G")); } } }
public void ReadControlBytes(byte[] buffer, int offset, int length) { UsbCommand cmd = new UsbCommand(commandReadEndpoint, buffer, offset, length); cmd.Execute(usbLock); //FIXME: allow async completion cmd.WaitForCompletion(); }
public void WriteControlBytesBulk(byte[] message, int offset, int length, bool async = false) { UsbCommand cmd = new UsbCommand(commandWriteEndpoint, message, offset, length); cmd.Execute(usbLock); if (!async) { cmd.WaitForCompletion(); } }
public void ReadControlBytes(byte[] buffer, int offset, int length) { UsbCommand cmd = new UsbCommand(commandReadEndpoint, buffer, offset, length, USB_TIMEOUT); cmd.Execute(usbLock); //FIXME: allow async completion cmd.WaitForCompletion(); switch (cmd.resultCode) { case ErrorCode.Success: break; default: throw new ScopeIOException("Failed to read from device: " + cmd.resultCode.ToString("G")); } }
public byte[] ReadControlBytes(int length) { UsbCommand cmd = new UsbCommand(commandReadEndpoint, new byte[COMMAND_READ_ENDPOINT_SIZE]); cmd.Execute(usbLock); //FIXME: allow async completion cmd.WaitForCompletion(); if (cmd.buffer == null) { throw new ScopeIOException("Failed to read control bytes"); } byte[] returnBuffer = new byte[length]; Array.Copy(cmd.buffer, returnBuffer, length); return(returnBuffer); }
public void GetData(byte[] buffer, int offset, int length) { UsbCommand cmd = new UsbCommand(dataEndpoint, buffer, offset, length, USB_TIMEOUT); cmd.Execute(usbLock); cmd.WaitForCompletion(); if (cmd.bytesReadOrWritten != length) { throw new ScopeIOException("No data transferred"); } switch (cmd.resultCode) { case ErrorCode.Success: break; default: throw new ScopeIOException("An error occured while fetching scope data: " + cmd.resultCode.ToString("G")); } }
public byte[] ReadControlBytes(int length) { UsbCommand cmd = new UsbCommand(commandReadEndpoint, new byte[COMMAND_READ_ENDPOINT_SIZE], USB_TIMEOUT); cmd.Execute(usbLock); //FIXME: allow async completion cmd.WaitForCompletion(); switch (cmd.resultCode) { case ErrorCode.Success: break; default: throw new ScopeIOException("Failed to read from device: " + cmd.resultCode.ToString("G")); } byte[] returnBuffer = new byte[length]; Array.Copy(cmd.buffer, returnBuffer, length); return(returnBuffer); }
public byte[] GetData(int numberOfBytes) { UsbCommand cmd = new UsbCommand(dataEndpoint, new byte[numberOfBytes], USB_TIMEOUT); cmd.Execute(usbLock); cmd.WaitForCompletion(); if (cmd.bytesReadOrWritten != numberOfBytes) { return(null); } switch (cmd.resultCode) { case ErrorCode.Success: break; default: throw new ScopeIOException("An error occured while fetching scope data: " + cmd.resultCode.ToString("G")); } //return read data return(cmd.buffer); }
public void WriteControlBytesBulk(byte[] message, int offset, int length, bool async = false) { if (commandWriteEndpoint == null) { throw new ScopeIOException("Command write endpoint is null"); } byte[] buffer; if (offset == 0 && length == message.Length) { buffer = message; } else { buffer = new byte[length]; Array.ConstrainedCopy(message, offset, buffer, 0, length); } UsbCommand cmd = new UsbCommand(commandWriteEndpoint, buffer); cmd.Execute(usbLock); if (!async) { cmd.WaitForCompletion(); if (!cmd.success) { throw new ScopeIOException("Failed to write to scope"); } if (cmd.bytesTransferred != length) { throw new ScopeIOException(String.Format("Only wrote {0} out of {1} bytes", cmd.bytesTransferred, length)); } } }
public byte[] GetData(int numberOfBytes) { UsbCommand cmd = new UsbCommand(dataEndpoint, new byte[numberOfBytes]); cmd.Execute(usbLock); cmd.WaitForCompletion(); if (cmd.bytesTransferred == 0) { return(null); } if (cmd.bytesTransferred != numberOfBytes) { LabNation.Common.Logger.Error(String.Format("WinUSB GetData: got {0} bytes instead of requested {1}", cmd.bytesTransferred, numberOfBytes)); return(null); } #if DEBUG lastBuffer2 = lastBuffer; lastBuffer = cmd.buffer; #endif //return read data return(cmd.buffer); }
public void WriteControlBytesBulk(byte[] message, int offset, int length, bool async = false) { if (commandWriteEndpoint == null) throw new ScopeIOException("Command write endpoint is null"); byte[] buffer; if (offset == 0 && length == message.Length) buffer = message; else { buffer = new byte[length]; Array.ConstrainedCopy(message, offset, buffer, 0, length); } UsbCommand cmd = new UsbCommand(commandWriteEndpoint, buffer); cmd.Execute(usbLock); if (!async) { cmd.WaitForCompletion(); if (!cmd.success) throw new ScopeIOException("Failed to write to scope"); if (cmd.bytesTransferred != length) throw new ScopeIOException(String.Format("Only wrote {0} out of {1} bytes", cmd.bytesTransferred, length)); } }
public byte[] ReadControlBytes(int length) { UsbCommand cmd = new UsbCommand(commandReadEndpoint, new byte[COMMAND_READ_ENDPOINT_SIZE]); cmd.Execute(usbLock); //FIXME: allow async completion cmd.WaitForCompletion(); if (cmd.buffer == null) throw new ScopeIOException("Failed to read control bytes"); byte[] returnBuffer = new byte[length]; Array.Copy(cmd.buffer, returnBuffer, length); return returnBuffer; }
public byte[] GetData(int numberOfBytes) { UsbCommand cmd = new UsbCommand(dataEndpoint, new byte[numberOfBytes]); cmd.Execute(usbLock); cmd.WaitForCompletion(); if (cmd.bytesTransferred == 0) return null; if (cmd.bytesTransferred != numberOfBytes) { LabNation.Common.Logger.Error(String.Format("WinUSB GetData: got {0} bytes instead of requested {1}", cmd.bytesTransferred, numberOfBytes)); return null; } #if DEBUG lastBuffer2 = lastBuffer; lastBuffer = cmd.buffer; #endif //return read data return cmd.buffer; }
public void WriteControlBytesBulk(byte[] message, int offset, int length, bool async = false) { if (commandWriteEndpoint == null) throw new ScopeIOException("Command write endpoint is null"); byte[] buffer; if (offset == 0 && length == message.Length) buffer = message; else { buffer = new byte[length]; Array.ConstrainedCopy(message, offset, buffer, 0, length); } UsbCommand cmd = new UsbCommand(commandWriteEndpoint, buffer, USB_TIMEOUT); cmd.Execute(usbLock); if (!async) { cmd.WaitForCompletion(); if (cmd.bytesReadOrWritten != length) throw new ScopeIOException(String.Format("Only wrote {0} out of {1} bytes", cmd.bytesReadOrWritten, length)); switch (cmd.resultCode) { case ErrorCode.Success: break; default: throw new ScopeIOException("Failed to read from USB device : " + cmd.resultCode.ToString("G")); } } }
public byte[] ReadControlBytes(int length) { UsbCommand cmd = new UsbCommand(commandReadEndpoint, new byte[COMMAND_READ_ENDPOINT_SIZE], USB_TIMEOUT); cmd.Execute(usbLock); //FIXME: allow async completion cmd.WaitForCompletion(); switch (cmd.resultCode) { case ErrorCode.Success: break; default: throw new ScopeIOException("Failed to read from device: " + cmd.resultCode.ToString("G")); } byte[] returnBuffer = new byte[length]; Array.Copy(cmd.buffer, returnBuffer, length); return returnBuffer; }
public byte[] GetData(int numberOfBytes) { UsbCommand cmd = new UsbCommand(dataEndpoint, new byte[numberOfBytes], USB_TIMEOUT); cmd.Execute(usbLock); cmd.WaitForCompletion(); if (cmd.bytesReadOrWritten != numberOfBytes) return null; switch (cmd.resultCode) { case ErrorCode.Success: break; default: throw new ScopeIOException("An error occured while fetching scope data: " + cmd.resultCode.ToString("G")); } //return read data return cmd.buffer; }