public object Execute(string[] arguments) { if (Host == null) { throw new InvalidOperationException("Host shoudln't be null"); } if (arguments[0].TryParseByte(out byte port)) { BytePackage package = new BytePackage(CommandTable.DigitalRead); package.AddBytes(port); byte recieved = Host?.ComPort.WriteBytes(package) ?? 0; if (recieved != package.Size) { throw new ShellException(Resources.ErrorCommunication); } var response = Host !.ComPort.ReadBytes(); if (response.Length != 1) { throw new ShellException(Resources.ErrorCommunication); } return(response[0] > 0); } throw new ShellException(Resources.ErrorParameterParse); }
public object?Execute(string[] arguments) { if (Host == null) { throw new InvalidOperationException("Host shoudln't be null"); } if (arguments[0].TryParseByte(out byte port) && arguments[1].TryParseByte(out byte value)) { BytePackage package = new BytePackage(CommandTable.DigitalWrite); package.AddBytes(port, value); byte recieved = Host.ComPort.WriteBytes(package); if (recieved != package.Size) { throw new ShellException(Resources.ErrorCommunication); } return(null); } throw new ShellException(Resources.ErrorParameterParse); }