예제 #1
0
        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);
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: xPaRi/Esp8266Dev
        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
                }
            });
        }
예제 #3
0
파일: Program.cs 프로젝트: xPaRi/Esp8266Dev
        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
                }
            });
        }