コード例 #1
0
 public CommTest()
 {
     InitializeComponent();
     port = new SyncSerialPort(portName, baudRate, parity, dataBits, stopBits);
     if (port.Open())
     {
         writeToLog(string.Format("Port: {0} open\n", portName));
     }
     else
     {
         writeToLog(string.Format("Port failed to open with ex: {0}" + System.Environment.NewLine));
         return;
     }
 }
コード例 #2
0
 public CommTest(string newPort)
 {
     InitializeComponent();
     portName = newPort;
     port     = new SyncSerialPort(portName, baudRate, parity, dataBits, stopBits);
     try
     {
         if (port.Open())
         {
             writeToLog(string.Format("Port: {0} open\n", portName));
         }
         else
         {
             writeToLog(string.Format("Failed to open port {0} ", portName));
         }
     }
     catch (Exception ex)
     {
         writeToLog(string.Format("Port failed to open with ex: {0}" + System.Environment.NewLine, ex.Message));
     }
 }
コード例 #3
0
 public bool open()
 {
     return(port.Open());
 }