private void ReadSettings() { // Read from file _lastConnectedSetting.Port = "COM1"; _lastConnectedSetting.BaudRate = 115200; if (File.Exists(SettingsFileName)) { var fileStream = File.OpenRead(SettingsFileName); var deserializer = new BinaryFormatter(); _lastConnectedSetting = (LastConnectedSetting)deserializer.Deserialize(fileStream); fileStream.Close(); } }
/// <summary> /// Connection manager for serial port connection /// </summary public SerialConnectionManager(SerialTransport serialTransport, CmdMessenger cmdMessenger, int challengeCommandId, int responseCommandId) : base(cmdMessenger, challengeCommandId, responseCommandId) { WatchdogTimeOut = 2000; WatchdogRetryTimeOut = 1000; MaxWatchdogTries = 3; if (serialTransport == null) { return; } if (cmdMessenger == null) { return; } _serialTransport = serialTransport; _lastConnectedSetting = new LastConnectedSetting(); ReadSettings(); _serialTransport.UpdatePortCollection(); StartConnectionManager(); }