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 ActionResult AddSubmit(PackageAddModel model) { if (model.File != null && model.File.ContentLength > 0) { Logger.Info(this, "Received package upload " + model.File.FileName); Core.Package package = BytePackage.Create(model.File.InputStream.ReadAllBytes(), model.File.FileName); Persistence.Application fileSystemApplication = this._repository.GetApplication(model.Application); this._repository.CreatePackage(fileSystemApplication, package); } return(this.RedirectToAction("List", new { application = model.Application })); }
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); }
public object Execute(string[] arguments) { if (Host == null) { throw new InvalidOperationException("Host shoudln't be null"); } BytePackage package = new BytePackage(CommandTable.GetVersion); byte recieved = Host.ComPort.WriteBytes(package); if (recieved != package.Size) { throw new ShellException(Resources.ErrorCommunication); } var response = Host.ComPort.ReadBytes(); if (response.Length != 3) { throw new ShellException(Resources.ErrorCommunication); } return(new Version(response[0], response[1], response[2])); }