private bool LoadSettings() { if (File.Exists(FullSettingsPath)) { try { ConfigNode node = ConfigNode.Load(FullSettingsPath); ConfigNode config = node.GetNode(SettingsNodeName); ConfigNode.LoadObjectFromConfig(this, config); ConfigNode[] portNodes = config.GetNodes("SerialPort"); for (int i = 0; i < portNodes.Length; i++) { SerialPortNode portNode = new SerialPortNode(); ConfigNode.LoadObjectFromConfig(portNode, portNodes[i]); SerialPorts.Add(portNode); } // Rewrite Documentation parameter on every run, // so we know it's always pointing at what should // be the right place. Documentation = DocoUrl; return(true); } catch (Exception e) { Debug.Log(String.Format("KerbalSimpit: Settings file couldn't be read: {0}", e)); } } else { Debug.Log(String.Format("KerbalSimpit: Settings file not found: {0}", FullSettingsPath)); } return(false); }
private void CreateDefaultSettings() { SerialPortNode defaultPort = new SerialPortNode("/dev/ttyS0", 115200); SerialPorts.Add(defaultPort); SaveSettings(); }
private void CreateDefaultSettings() { // Switch based on OS sourced from stackoverflow: https://softwarerecs.stackexchange.com/a/13722 OperatingSystem os = Environment.OSVersion; PlatformID pid = os.Platform; String defaultSerialPort = ""; SerialPortNode defaultPort = new SerialPortNode(defaultSerialPort, 115200); SerialPorts.Add(defaultPort); CustomResourceMessages.Add(new CustomResourceMessage()); CustomResourceMessages.Add(new CustomResourceMessage()); SaveSettings(); }