/// <summary> /// Safely reconnect to the slave device /// </summary> private void Reconnect() { // Try to close the port before we re instantiate. If this // explodes there are bigger issues _port.Disconnect(); // Let the port cool off (close base stream, etc.) Thread.Sleep(100); Connect(); }
/// <summary> /// Stop talking to the slave and release the underlying comm port. /// <remarks>Do not use this to disable the bill acceptor: use PauseAcceptance()</remarks> /// </summary> public void Close() { // This will kill the comms loop IsRunning = false; _port?.Disconnect(); lock (_mutex) { IsPaused = true; } }