Beispiel #1
0
        private void btnTestCom_Click(object sender, EventArgs e)
        {
            bool check = false;

            if (com == null)
            {
                com = new ComPort(1);
                //   com.OnComReaderReceived += new ComReaderReceived(this._port_DataReceived);
                check = com.Init();
            }
            if (check)
            {
                check = com.Connect();
                if (check)
                {
                    MessageBox.Show("OK");
                }
                else
                {
                    MessageBox.Show("Fail");
                }
            }
            else
            {
                MessageBox.Show("Fail");
            }
        }
Beispiel #2
0
        public bool InitCom()
        {
            bool check = false;

            if (com.Init())
            {
                if (com.Connect())
                {
                    com.OnComReaderReceived += new ComReaderReceived(this._port_DataReceived);
                }
                else
                {
                    return(check);
                }
            }
            else
            {
                return(check);
            }

            return(true);
        }