Exemple #1
0
        public override void Close()
        {
            try
            {
                thisSerial.Close();
                Sup.LogDebugMessage($"Serial: Closed the port on {SensorUsed}");
            }
            catch (IOException e)
            {
                Sup.LogTraceErrorMessage($"Serial: Exception on Close {SensorUsed}: {e.Message}");
            }

            Valid = false;
        }
Exemple #2
0
        }// PMS1003 Constructor

        public override void Open()
        {
            thisSerial = new SerialPort(Port.SerialPortUsed, Port.SerialBaudRate, Port.SerialParity, Port.SerialDataBits, Port.SerialNrOfStopBits)
            {
                ReadTimeout = 500
            };

            try
            {
                thisSerial.Open();
                Sup.LogDebugMessage($"Serial: Opened the port {Port.SerialPortUsed}, {Port.SerialBaudRate}, {Port.SerialParity}, {Port.SerialDataBits}, {Port.SerialNrOfStopBits}");
            }
            catch (Exception e) when(e is ArgumentOutOfRangeException || e is ArgumentException || e is IOException || e is InvalidOperationException)
            {
                Sup.LogTraceErrorMessage($"Serial: Exception on Open {SensorUsed}: {e.Message}");
                Sup.LogTraceErrorMessage("No use continuing when the particle sensor is not there, trying anyway...");
                Valid = false;
            }
        }