/// <summary> /// Connect to the device and begin speaking rs232 /// </summary> public void Connect() { // Lock so we only have one connection attempt at a time. This protects // from client code behaving badly. lock (mutex) { try { port = new StrongPort(Config.CommPortName); } catch (IOException) { NotifyError(Errors.FailedToOpenPort); return; } port.ReadTimeout = 500; DebugBufferEntry.SetEpoch(); try { port.Connect(); // Only start if we connect without error startRS232Loop(); IsPaused = false; } catch (Exception e) { log.ErrorFormat("Exception Connecting to acceptor: {0}", e.Message, e); if (OnError != null) { NotifyError(Errors.PortError); } } } }
/// <summary> /// Returns a list of all available ports /// </summary> /// <returns></returns> public static List <string> GetAvailablePorts() { return(StrongPort.GetAvailablePorts()); }