Exemple #1
0
        private void Initialize()
        {
            var portName = settings.COMPort;

            try
            {
                portName = GodSerialPort.GetPortNames().Single <string>();
            }
            catch
            {
            }

            myPort = new GodSerialPort(portName, baudRate: 9600, parity: 0);
            myPort.UseDataReceived(true, OnDataReceived);
            myPort.OnPinChange(action: (port, e) => { Trace.TraceEvent(TraceEventType.Error, 3, "pinchanged:" + e.ToString()); });
            myPort.OnError(action: (port, e) => { Trace.TraceEvent(TraceEventType.Error, 1, "error:" + e.ToString()); });

            myPort.Open();
        }