예제 #1
0
        private void connectToToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (m_terminalClient != null)
            {
                return;
            }
            ConnectTo ct = new ConnectTo();

            if (ct.ShowDialog() == DialogResult.OK)
            {
                if (ct.IsSerial)
                {
                    SerialParams sp = Helper.GetDefaultSerialParams();
                    sp.PortName = ct.SerialPort.ToUpper();
                    if (!TryConnectTerminalClient(sp))
                    {
                        m_terminalClient = null;
                    }
                }
                else
                {
                    ConnectWithNkParams(ct.Address, ct.Port);
                }
            }
        }
예제 #2
0
        public static SerialParams GetDefaultSerialParams(string comPort)
        {
            SerialParams sp = new SerialParams();

            sp.PortName  = comPort;
            sp.BaudRate  = 115200;
            sp.DataBits  = 8;
            sp.Parity    = Parity.None;
            sp.StopBits  = StopBits.One;
            sp.Handshake = Handshake.None;
            return(sp);
        }
예제 #3
0
 private bool TryConnectTerminalClient(SerialParams sp)
 {
     m_terminalClient = new SerialClient(sp);
     m_terminalClient.DataReceivedEvent += MTerminalClientDataReceivedEvent;
     if (m_terminalClient.Connect())
     {
         SetTitle(m_terminalClient.Title);
         SetConnectState();
         return(true);
     }
     MessageBox.Show(String.Format("Connecting to {0} failed.", sp.PortName));
     return(false);
 }
예제 #4
0
 public void CheckAutoConnect()
 {
     if (Config.GetInstance().GetConfig().AutoConnect)
     {
         if (Config.GetInstance().GetConfig().ConType == ConnectionType.Serial)
         {
             SerialParams sp = Config.GetInstance().GetConfig().SerialParams;
             if (!TryConnectTerminalClient(sp))
             {
                 m_terminalClient = null;
                 sp.PortName      = "COM2";
                 if (!TryConnectTerminalClient(sp))
                 {
                     m_terminalClient = null;
                 }
             }
         }
         else
         {
             ConnectWithNkParams(Config.GetInstance().GetConfig().NtAddress,
                                 Config.GetInstance().GetConfig().NtPort);
         }
     }
 }
예제 #5
0
 public SerialClient(SerialParams sp)
 {
     _mSerialParams = sp;
 }