public Task <SerialPort> GetPort(GsmModemHwSettings gsmModemHwSettings) { _port = new SerialPort() { PortName = gsmModemHwSettings.PortName, BaudRate = gsmModemHwSettings.BaudRate, Handshake = gsmModemHwSettings.Handshake, NewLine = gsmModemHwSettings.NewLine }; if (SerialPort.GetPortNames().Any(pn => pn == _port.PortName)) { _logger.LogInformation("Serial port configured on {PortName}", gsmModemHwSettings.PortName); return(Task.FromResult(_port)); } _logger.LogError("Port not configured. Available ports: {Ports}", SerialPort.GetPortNames().ToList()); return(Task.FromException <SerialPort>(new IOException("Requested port not available"))); }
public IHwSettings GetSettings() { return(_hwSettings = _configuration .GetSection($"{HwSettingsSection}:{HwSettingsCurrentActorSection}") .Get <GsmModemHwSettings>()); }