예제 #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 PECommunication(string newPortName)
 {
     portName = newPortName;
     port     = new SyncSerialPort(portName, baudRate, parity, dataBits, stopBits);
 }