public async ValueTask StartAsync() { if (_mdc == null) { _logger.LogInformation($"Connecting to display on port '{_configuration.Value.Port}'"); _mdc = Mdc.Connection.Factory.ForSerialPort(_configuration.Value.Port); await _mdc.ConnectAsync(); } else { throw new InvalidOperationException("Controller has already been started"); } }
public async ValueTask StopAsync() { if (_mdc != null) { _logger.LogInformation($"Disconnecting from display on port '{_configuration.Value.Port}'"); await _mdc.DisconnectAsync(); await _mdc.DisposeAsync(); _mdc = null; } else { throw new InvalidOperationException("Controller has not been started"); } }