private static void Main(string[] args) { ConsoleEx.WriteAppCaption(); ConsoleEx.WriteLine($"Valid port(s): {Helpers.GetValidPorts()}"); var cmdLine = new MyCommandLine(args); if (cmdLine.ExistsAny(new[] { PAR_HELP_1, PAR_HELP_2, PAR_HELP_3 })) { ShowHelp(); return; } try { var comCom = new ComComunication(cmdLine.Value(PAR_PORT_LIST)); Console.WriteLine($"Selected port: {comCom.PortName}"); var comComThread = comCom.StartCommunication(); var pipeName = cmdLine.Exists(PAR_PIPE_NAME) ? cmdLine.Value(PAR_PIPE_NAME) : Helpers.GetPipeName(comCom.PortName); var pipeServer = new PipeServer(pipeName, comCom.SerialPort); var pipeServerThread = pipeServer.Start(); comComThread?.Join(); } catch (Exception ex) { ConsoleEx.WriteError(ex); } }
private static MessageFromClient GetCmdMessage(MyCommandLine cmdLine) { if (!cmdLine.Exists(PAR_CMD_COMMAND)) { return(null); } var command = cmdLine.Value(PAR_CMD_COMMAND); if (string.IsNullOrEmpty(command)) { throw new Exception("Command not specified."); } return(new MessageFromClient { Command = "CMD", Parameters = new List <string> { command } }); }
private static MessageFromClient GetUploadMessage(MyCommandLine cmdLine) { if (!cmdLine.Exists(PAR_CMD_UPLOAD)) { return(null); } var fileName = cmdLine.Value(PAR_CMD_UPLOAD); if (string.IsNullOrEmpty(fileName)) { throw new Exception("File not specified."); } return(new MessageFromClient { Command = "UPLOAD", Parameters = new List <string> { fileName } }); }