protected void ThrowException(ArduinoResult result) { switch (result) { case ArduinoResult.Unknown: throw new ResultUnknownException(); case ArduinoResult.Success: // *** // *** Do nothing // *** break; case ArduinoResult.BufferSizeNotExpected: throw new BufferSizeNotExpectedException(); case ArduinoResult.BufferError: throw new BufferErrorException(); case ArduinoResult.CommandNotSupported: throw new CommandNotSupportedException(); case ArduinoResult.MappingMismatch: throw new MappingMismatchException(); case ArduinoResult.MissingCallback: throw new MissingMappingException(); case ArduinoResult.IdTooLarge: throw new RegisterIdTooLargeException(); case ArduinoResult.BufferNotReady: throw new BufferNotReadyException(); } }
protected Task <bool> CheckResult(byte[] readBuffer, bool throwException = true) { bool returnValue = false; ArduinoResult result = (ArduinoResult)readBuffer[0]; if (result == ArduinoResult.Success) { returnValue = true; } else { if (throwException) { this.ThrowException(result); } else { returnValue = false; } } return(Task <bool> .FromResult(returnValue)); }