private void SetupComPort() { _target?.Dispose(); _target = new SafeSerialPort { BaudRate = 4800, Handshake = Handshake.None, NewLine = "\r\n", Parity = Parity.None, ReadTimeout = 10000, StopBits = StopBits.One }; _lineReceiver?.Abort(); _lineReceiver = new Thread(ReceiveLine_T) { IsBackground = true, Name = ToString() + "_LineReceiver" }; _lineReceiver.Start(); }
private void SetupComPort() { if (_target != null) _target.Dispose(); _target = new SafeSerialPort(); _target.BaudRate = 4800; _target.Handshake = Handshake.None; _target.NewLine = "\r\n"; _target.Parity = Parity.None; _target.ReadTimeout = 10000; // 3 second regulator timeout _target.StopBits = StopBits.One; }
private void Disconnect(string reason) { lock (_commandSendLock) { if (_target != null) { AppLog.Write(Strings.Default.DisconnectHeader + reason, LogEntryType.Info, LogEntrySource.MsregDevice, TargetPort); //target.Close(); _target.Dispose(); _target = null; //GC.Collect(); OnDisconnected(reason); } if (_lineReceiver != null) { _lineReceiver.Abort(); _lineReceiver = null; } ConnectedDeviceInfo = null; _ackReplies.Clear(); } if (AutoReconnect) Connect(); }