Пример #1
0
        public new void Launch(string args, Action <object> onFinish, object param, OutputTo outputTo = OutputTo.Console)
        {
            if (args.Trim().Length > 0)
            {
                // Add -u to command line (disables safe mode)
                args = "-u " + args;

                // Set conf file to use
                string confLoc = Config.Prop.avrdudeConfLoc;
                if (confLoc != "")
                {
                    args = "-C \"" + Path.Combine(confLoc, FILE_AVRDUDECONF) + "\" " + args;
                }
            }

            if (outputTo == OutputTo.Console)
            {
                //Util.consoleWrite("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ " + Environment.NewLine);
                // Debug info
                if (Constants.DEBUG_STATUS == true)
                {
                    System.Diagnostics.Debug.Write("\n\n~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \r\n");
                    System.Diagnostics.Debug.Write("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \r\n");
                }
            }

            upload_status = 0;
            base.StartProcessesses();
            base.Launch(args, onFinish, param, outputTo);
        }
Пример #2
0
        protected bool Launch(string args, Action <object> onFinish, object param, OutputTo outputTo)
        {
            outputLog = "";

            this.onFinish = onFinish;
            this.param    = param;

            return(Launch(args, outputTo));
        }
Пример #3
0
        private bool Launch(string args, OutputTo outputTo)
        {
            outputLog = "";

            if (binary == null)
            {
                throw new Exception("Launch(): No executable set, forgot to call SetExecuteable()?\r\n");
            }

            processStartInfo.FileName  = binary;
            processStartInfo.Arguments = args;
            execProcess.StartInfo      = processStartInfo;

            try {
                execProcess.Start();
            }
            catch (Exception ex) {
                MsgBox.error("Unable to start process for console output\r\n", ex);
                return(false);
            }

            OnProcessStart?.Invoke(this, EventArgs.Empty);

            if (outputTo == OutputTo.Console)
            {
                if (execProcess.StartInfo.RedirectStandardError)
                {
                    stderrThread = new Thread(() => ThreadConsoleUpdate(execProcess.StandardError));
                    stderrThread.IsBackground = true;
                    stderrThread.Start();
                }

                if (execProcess.StartInfo.RedirectStandardOutput)
                {
                    stdoutThread = new Thread(() => ThreadConsoleUpdate(execProcess.StandardOutput));
                    stdoutThread.IsBackground = true;
                    stdoutThread.Start();
                }
            }

            if (outputTo == OutputTo.Log)
            {
                execProcess.OutputDataReceived += new DataReceivedEventHandler(OutputLogHandler);
                execProcess.ErrorDataReceived  += new DataReceivedEventHandler(ErrorLogHandler);
                processOutputStreamOpen         = true;
                processErrorStreamOpen          = true;
                execProcess.BeginOutputReadLine();
                execProcess.BeginErrorReadLine();
            }
            else
            {
                processOutputStreamOpen = false;
                processErrorStreamOpen  = false;
            }

            return(true);
        }
Пример #4
0
        private bool launch(string args, OutputTo outputTo)
        {
            exitWait.Reset();
            stdOutWait.Reset();
            stdErrWait.Reset();

            Process tmp = new Process();

            tmp.StartInfo.FileName               = binary;
            tmp.StartInfo.Arguments              = args;
            tmp.StartInfo.CreateNoWindow         = true;
            tmp.StartInfo.UseShellExecute        = false;
            tmp.StartInfo.RedirectStandardOutput = true;
            tmp.StartInfo.RedirectStandardError  = true;
            tmp.EnableRaisingEvents              = true;
            if (outputTo == OutputTo.Memory)
            {
                tmp.OutputDataReceived += new DataReceivedEventHandler(outputLogHandler);
                tmp.ErrorDataReceived  += new DataReceivedEventHandler(errorLogHandler);
            }
            tmp.Exited += new EventHandler(p_Exited);

            try
            {
                tmp.Start();
            }
            catch (Exception ex)
            {
                Util.consoleError("_EXECFAIL", ex.Message);
                return(false);
            }

            if (OnProcessStart != null)
            {
                OnProcessStart(this, EventArgs.Empty);
            }

            //var _ = ConsumeReader(tmp.StandardOutput);
            //_ = ConsumeReader(tmp.StandardError);

            enableConsoleUpdate = (outputTo == OutputTo.Console);
            p = tmp;

            if (outputTo == OutputTo.Memory)
            {
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }
            else
            {
                stdOutWait.Set();
                stdErrWait.Set();
            }

            return(true);
        }
 public static ILoggerFactory AddFallbackLogger(this ILoggerFactory factory, OutputTo consoleorlistofstring, string name = "Console")
 {
     if (factory == null)
     {
         throw new ArgumentNullException(nameof(factory));
     }
     if (consoleorlistofstring == OutputTo.ListOfString)
     {
         throw new ArgumentException($"Can't specify {consoleorlistofstring} unless you also specify a BackingList", nameof(consoleorlistofstring));
     }
     factory.AddProvider(new FallbackLoggerProvider(name));
     return(factory);
 }
Пример #6
0
        private bool launch(string args, OutputTo outputTo)
        {
            Process tmp = new Process();

            tmp.StartInfo.FileName               = binary;
            tmp.StartInfo.Arguments              = args;
            tmp.StartInfo.CreateNoWindow         = true;
            tmp.StartInfo.UseShellExecute        = false;
            tmp.StartInfo.RedirectStandardOutput = true;
            tmp.StartInfo.RedirectStandardError  = true;
            tmp.EnableRaisingEvents              = true;
            if (outputTo == OutputTo.Log)
            {
                tmp.OutputDataReceived += new DataReceivedEventHandler(outputLogHandler);
                tmp.ErrorDataReceived  += new DataReceivedEventHandler(errorLogHandler);
            }
            tmp.Exited += new EventHandler(p_Exited);

            try
            {
                tmp.Start();
            }
            catch (Exception ex)
            {
                MsgBox.error("Error starting process", ex);
                return(false);
            }

            if (OnProcessStart != null)
            {
                OnProcessStart(this, EventArgs.Empty);
            }

            enableConsoleUpdate = (outputTo == OutputTo.Console);
            p = tmp;

            if (outputTo == OutputTo.Log)
            {
                processOutputStreamOpen = true;
                processErrorStreamOpen  = true;
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }
            else
            {
                processOutputStreamOpen = false;
                processErrorStreamOpen  = false;
            }

            return(true);
        }
        public static ILoggerFactory AddFallbackLogger(this ILoggerFactory factory, OutputTo consoleorlistofstring, List <string> backingList = null, string name = "ListOfString")
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            if (consoleorlistofstring == OutputTo.Console)
            {
                throw new ArgumentException($"Can't specify {consoleorlistofstring} with a BackingList", nameof(backingList));
            }

            factory.AddProvider(new FallbackLoggerProvider(backingList ?? new List <string>(), name));
            return(factory);
        }
Пример #8
0
        public new void Launch(string args, Action <object> onFinish, object param, OutputTo outputTo = OutputTo.Console)
        {
            if (outputTo == OutputTo.Console)
            {
                // Debug info
                if (Constants.DEBUG_STATUS == true)
                {
                    System.Diagnostics.Debug.Write("\r\n\r\n~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \r\n");
                    System.Diagnostics.Debug.Write("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ \r\n");
                }
            }

            upload_status = 0;
            base.StartProcessesses();
            base.Launch(args, onFinish, param, outputTo);
        }
Пример #9
0
        protected bool launch(string args, Action<object> onFinish, object param, OutputTo outputTo)
        {
            if (isActive()) // Another process is active
                return false;

            // Clear log
            outputLog = "";
            //Util.consoleClear();

            // Binary is missing
            if (binary == null || !File.Exists(binary))
                return false;

            this.onFinish = onFinish;
            this.param = param;

            return launch(args, outputTo);
        }
Пример #10
0
        public new void launch(string args, Action <object> onFinish, object param, OutputTo outputTo = OutputTo.Console)
        {
            if (args.Trim().Length > 0)
            {
                // Add -u to command line (disables safe mode)
                args = "-u " + args;

                // Set conf file to use
                string confLoc = Config.Prop.avrdudeConfLoc;
                if (confLoc != "")
                {
                    args = "-C \"" + Path.Combine(confLoc, FILE_AVRDUDECONF) + "\" " + args;
                }
            }

            if (outputTo == OutputTo.Console)
            {
                Util.consoleWriteLine("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~");
            }

            base.launch(args, onFinish, param, outputTo);
        }
Пример #11
0
        protected bool launch(string args, Action <object> onFinish, object param, OutputTo outputTo)
        {
            if (isActive()) // Another process is active
            {
                return(false);
            }

            // Clear log
            outputLog = "";
            //Util.consoleClear();

            // Binary is missing
            if (binary == null || !File.Exists(binary))
            {
                return(false);
            }

            this.onFinish = onFinish;
            this.param    = param;

            return(launch(args, outputTo));
        }
Пример #12
0
 public void Launch(string args, CommandType commandType, OutputTo outputTo = OutputTo.Console)
 {
     SetCommandType(commandType);
     Launch(args, null, null, outputTo);
 }
Пример #13
0
 public void launch(string args, OutputTo outputTo = OutputTo.Console)
 {
     launch(args, null, null, outputTo);
 }
Пример #14
0
        private bool launch(string args, OutputTo outputTo)
        {
            Process tmp = new Process();
            tmp.StartInfo.FileName = binary;
            tmp.StartInfo.Arguments = args;
            tmp.StartInfo.CreateNoWindow = true;
            tmp.StartInfo.UseShellExecute = false;
            tmp.StartInfo.RedirectStandardOutput = true;
            tmp.StartInfo.RedirectStandardError = true;
            tmp.EnableRaisingEvents = true;
            if (outputTo == OutputTo.Log)
            {
                tmp.OutputDataReceived += new DataReceivedEventHandler(outputLogHandler);
                tmp.ErrorDataReceived += new DataReceivedEventHandler(errorLogHandler);
            }
            tmp.Exited += new EventHandler(p_Exited);

            try
            {
                tmp.Start();
            }
            catch (Exception ex)
            {
                MsgBox.error("Error starting process", ex);
                return false;
            }

            if (OnProcessStart != null)
                OnProcessStart(this, EventArgs.Empty);

            enableConsoleUpdate = (outputTo == OutputTo.Console);
            p = tmp;

            if (outputTo == OutputTo.Log)
            {
                processOutputStreamOpen = true;
                processErrorStreamOpen = true;
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
            }
            else
            {
                processOutputStreamOpen = false;
                processErrorStreamOpen = false;
            }

            return true;
        }
Пример #15
0
 public void launch(string args, OutputTo outputTo = OutputTo.Console)
 {
     launch(args, null, null, outputTo);
 }
Пример #16
0
        public new void launch(string args, Action<object> onFinish, object param, OutputTo outputTo = OutputTo.Console)
        {
            if (args.Trim().Length > 0)
            {
                // Add -u to command line (disables safe mode)
                args = "-u " + args;

                // Set conf file to use
                string confLoc = Config.Prop.avrdudeConfLoc;
                if (confLoc != "")
                    args = "-C " + Path.Combine(confLoc, FILE_AVRDUDECONF) + " " + args;
            }

            if (outputTo == OutputTo.Console)
                Util.consoleWrite("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ " + Environment.NewLine);

            base.launch(args, onFinish, param, outputTo);
        }
Пример #17
0
 public bool launch(string args, OutputTo outputTo = OutputTo.Console)
 {
     return(launch(args, null, null, outputTo));
 }