public ComPortWithThreshold(ComPortWithThresholdSettings settings,
                             Func <List <byte>, bool> packetRcvAction,
                             Action <ComPortErrorNames, Exception> errorCallback)
     : base(settings, errorCallback)
 {
     try
     {
         this.settings     = settings;
         packetRcv         = packetRcvAction ?? throw new ArgumentNullException(nameof(packetRcvAction));
         Buffer            = new Queue <byte>();
         checkBufferThread = new RepeatedTask(checkBuffer, 1);
         checkBufferThread.Start();
     }
     catch (Exception ex)
     {
         raiseError(ComPortErrorNames.OnConstruction, ex);
     }
 }
Beispiel #2
0
        public override object CreateDefault()
        {
            var baseSettings = base.CreateDefault() as ComPortSettings;

            var res = new ComPortWithThresholdSettings
            {
                BaudRate        = baseSettings.BaudRate,
                DataBits        = baseSettings.DataBits,
                Handshake       = baseSettings.Handshake,
                Parity          = baseSettings.Parity,
                PortName        = baseSettings.PortName,
                ReadBufferSize  = baseSettings.ReadBufferSize,
                StopBits        = baseSettings.StopBits,
                WriteBufferSize = baseSettings.WriteBufferSize,
                Threshold       = 8
            };

            return(res);
        }