From 00cb6f33a3c8d29d929e25e99a0b716e14e9378d Mon Sep 17 00:00:00 2001 From: Jiashuo Li Date: Tue, 12 May 2015 16:39:16 -0700 Subject: [PATCH] Fix: Cannot open COM Port when COM port is greater than 10. --- UI/Connector/EmulatorConnector.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/UI/Connector/EmulatorConnector.cs b/UI/Connector/EmulatorConnector.cs index c846089..818a29b 100644 --- a/UI/Connector/EmulatorConnector.cs +++ b/UI/Connector/EmulatorConnector.cs @@ -35,7 +35,10 @@ public static void TranslateToC(HLProgram program) string mainTemplateFullPath = System.IO.Path.Combine(emulatorPath, "MCEmulator", MainTemplate); string mainOutputFullPath = System.IO.Path.Combine(emulatorPath, "MCEmulator", MainOutput); string mainStr = File.ReadAllText(mainTemplateFullPath); - mainStr = mainStr.Replace("/**change_com_port**/", (Properties.Settings.Default.EmulatorComPort[3] - '0' - 1).ToString()); + + // COM1 is the 0th + int comNo = Int32.Parse(Properties.Settings.Default.EmulatorComPort.Substring(3)) - 1; + mainStr = mainStr.Replace("/**change_com_port**/", (comNo.ToString())); File.WriteAllText(mainOutputFullPath, mainStr); } }