コード例 #1
0
 public bool Open(string com)
 {
     try
     {
         _ComDataSplitcs             = new ComDataSplitcs();
         _ComDataSplitcs._SplitData += new ComDataSplitcs.SplitData(_ComDataSplitcs__SplitData);
         Comm          = new SerialPort();
         Comm.PortName = com;
         Comm.BaudRate = 115200;
         Comm.DataBits = 8;
         Comm.StopBits = (System.IO.Ports.StopBits) 1;
         Comm.Parity   = (System.IO.Ports.Parity) 0;
         Comm.Open();
         Start();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #2
0
ファイル: 串口读数.cs プロジェクト: jyorin/yinghe
        public bool Open(string com)
        {
            try
            {
                _ComDataSplitcs = new ComDataSplitcs();
                _ComDataSplitcs._SplitData += new ComDataSplitcs.SplitData(_ComDataSplitcs__SplitData);
                Comm = new SerialPort();
                Comm.PortName = com;
                Comm.BaudRate = 115200;
                Comm.DataBits = 8;
                Comm.StopBits = (System.IO.Ports.StopBits)1;
                Comm.Parity = (System.IO.Ports.Parity)0;
                Comm.Open();
                Start();
                return true;

            }
            catch (Exception ex)
            {
                return false;
            }
        }