Exemplo n.º 1
0
 public FormTerminal()
 {
     InitializeComponent();
     RBSlashr.Checked = true;
     TimerReceiver.Stop();
     TBOutput.Text = ">>> ";
     History.Items.Add("");
 }
Exemplo n.º 2
0
        private void TimerReceiver_Tick(object sender, EventArgs e)
        {
            if (isAllowToTick)
            {
                isAllowToTick = false;
                TotalTime     = TotalTime + TimerReceiver.Interval;
                if (TotalTime > WaitTime * 1000)
                {
                    TimerReceiver.Stop();
                    isAllowToTick = true;
                    return;
                }

                if (isDataReceived)
                {
                    isDataReceived = false;
                    //Thread.Sleep(50);
                    try
                    {
                        //string output = Form1.Port.ReadExisting();
                        while (Form1.Port.BytesToRead != 0)
                        {
                            char output = (char)Form1.Port.ReadByte();
                            if ((byte)output >= 32 && (byte)output <= 126)
                            {
                                TBOutput.Text = TBOutput.Text + output;
                            }
                            else
                            {
                                TBOutput.Text = TBOutput.Text + "{" + ((int)output).ToString("X2") + "}";
                            }
                        }

                        TBOutput.Text = TBOutput.Text + "\n" + ">>> ";
                        ScrollToEnd();
                    }
                    catch
                    {
                    }
                    TimerReceiver.Stop();
                }

                isAllowToTick = true;
            }
        }