public static bool CheckPort(string port) { if (File.Exists(UtilAll.GetECapSimSignalFileName())) //simulatedEncoder { simulated = true; return(true); } simulated = false; LogB.Information("testing encoder port: ", port); sp = new SerialPort(port); sp.BaudRate = 115200; LogB.Information("testing 1: sp created"); try { sp.Open(); LogB.Information("testing 2: sp opened"); sp.Close(); LogB.Information("testing 3: sp closed. Success!"); } catch { LogB.Error("testing encoder port failed"); return(false); } return(true); }
private bool initSimulated() { if (!File.Exists(UtilAll.GetECapSimSignalFileName())) { return(false); } string filename = Util.ReadFile(UtilAll.GetECapSimSignalFileName(), true); simulatedInts = Util.ReadFileAsInts(filename); return(true); }