private bool DiscoverDevice(ISerialPortManager serialPortManager) { ISerialPort serialPort; string response;// just used for testPort receive foreach (var portName in serialPortManager.GetNotAllocatedPortNames()) { serialPort = serialPortManager.GetSerialPort(portName); ConfigurePortForDiscovery(serialPort); Thread.Sleep(MESSAGE_DELAY); try { serialPort.WriteLine("*IDN?"); response = serialPort.ReadLine().ToUpper(); serialPort.Close(); if (response.Contains("KEITHLEY") && response.Contains("2400")) { SerialPort = serialPort; return(true); } } catch { // Ignore Port error. throw new PortCommunicationException(ex.Message, ex); } } return(false); }
public override void InitializeDevice(ISerialPortManager serialPortManager) { _serialPortManager = serialPortManager ?? throw new ArgumentNullException(nameof(serialPortManager)); if (DiscoverDevice(_serialPortManager)) { ConfigurePort(SerialPort); } else { throw new DeviceNotFoundException("No Wayne Kerr 4300 Device available"); } }
public override void InitializeDevice(ISerialPortManager serialPortManager) { if (serialPortManager == null) { throw new ArgumentNullException(nameof(serialPortManager)); } _serialPortManager = serialPortManager; if (DiscoverDevice(_serialPortManager)) { ConfigurePort(SerialPort); } else { throw new DeviceNotFoundException("No Keithley 2400 Device available"); } }
public Worker(ILogger <Worker> logger, IMessenger messenger, ISerialPortManager serialport) { _logger = logger; _messenger = messenger; _serialPort = serialport; _serialPort.Start(); if (SystemdHelpers.IsSystemdService()) { _logger.LogInformation("Running as linux daemon"); } else { _logger.LogInformation("Not running as Linux daemon"); } }
public abstract void InitializeDevice(ISerialPortManager serialPortManager);
public SerialPortManagerSelector(ISerialPortManager realSerialPortManager, ISerialPortManager serialPortEmulatorManager) { _realSerialPortManager = realSerialPortManager; _serialPortEmulatorManager = serialPortEmulatorManager; }
public void InitializeDevice(ISerialPortManager serialPortManager) { _wayneKerr4300SerialDevice.InitializeDevice(serialPortManager); }
public void InitializeDevice(ISerialPortManager serialPortManager) { ((ISerialDevice)_keithley2400SerialDevice).InitializeDevice(serialPortManager); }