/// <summary> /// Initializes a new connection to the interface /// </summary> /// <remarks>Uses the credentials Port, StopBites, aso.</remarks> private void InitConnection(string port = "COM2", int baudRate = 57600, ComPortParity parityBits = ComPortParity.None, int dataBits = 8, ComPortStopBits stopBits = ComPortStopBits.One) { SerialPortConnection = new ComPortConnection(port, baudRate, parityBits, dataBits, stopBits); try { SerialPortConnection.Open(); } catch (System.UnauthorizedAccessException notavail) { // COM Port in use logme.Log(i18n.FlakeLIErrors.ComPortNotAvailable, logme.LogLevel.error); notavail.ToString(); // foo return; } catch (IOException ioex) { logme.Log(ioex); return; } catch (Exception ex) { logme.Log(ex); return; } }
/// <summary> /// Initializes a new connection to the interface /// </summary> /// <remarks>Uses the credentials Port, StopBites, aso.</remarks> private void InitConnection(string port = "COM2", int baudRate = 57600, ComPortParity parityBits = ComPortParity.None, int dataBits = 8, ComPortStopBits stopBits = ComPortStopBits.One) { SerialPortConnection = new ComPortConnection(port, baudRate, parityBits, dataBits, stopBits); try { SerialPortConnection.Open(); } catch (System.UnauthorizedAccessException notavail) { // COM Port in use logme.Log(i18n.FlakeLIErrors.ComPortNotAvailable, logme.LogLevel.error); notavail.ToString(); // foo return; } catch (IOException ioex) { logme.Log(ioex); return; } catch (Exception ex) { logme.Log(ex); return; } }
public void OpenTest() { tcpClientComPort.Open(false); Thread.Sleep(500); Assert.IsTrue(tcpClientComPort.IsConnected); Assert.IsTrue(connectionState); }
/// <summary> /// Creates a new XpressNet LI central /// </summary> /// <param name="serialPortConnection">an existing serialport connection</param> public Central(IComPort serialPortConnection) { Config = new FlakeLIConfiguration(); _RigisteredEntities = new List <ILIEntity>(); _ErrorInARow = 0; // Open connection to interface SerialPortConnection = serialPortConnection; SerialPortConnection.Open(); // start command queue worker process //System.Threading.ThreadPool.QueueUserWorkItem(delegate { _AnswerListener = new LIListener(this); }, null); logme.Log(string.Format(i18n.FlakeLIMsgs.StartLIListener, Port), logme.LogLevel.info); SerialPortConnection.ComDataReceived += new ComPortEventHandler(DataReceivedHandler); GetInterfaceAndCentralInfo(); }
/// <summary> /// Creates a new XpressNet LI central /// </summary> /// <param name="serialPortConnection">an existing serialport connection</param> public Central(IComPort serialPortConnection) { Config = new FlakeLIConfiguration(); _RigisteredEntities = new List<ILIEntity>(); _ErrorInARow = 0; // Open connection to interface SerialPortConnection = serialPortConnection; SerialPortConnection.Open(); // start command queue worker process //System.Threading.ThreadPool.QueueUserWorkItem(delegate { _AnswerListener = new LIListener(this); }, null); logme.Log(string.Format(i18n.FlakeLIMsgs.StartLIListener, Port), logme.LogLevel.info); SerialPortConnection.ComDataReceived += new ComPortEventHandler(DataReceivedHandler); GetInterfaceAndCentralInfo(); }