コード例 #1
0
 private void _device_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     if (e.EventType == SerialError.Overrun)
     {
         _device_RaiseError(e.EventType.ToString(), "Received data while buffer is full(overrun)");
     }
     else
     {
         _device_RaiseError(e.EventType.ToString(), $"Unknown Serial error '{e.EventType.ToString()}' while receiving data");
     }
 }
コード例 #2
0
ファイル: EmiTagMerger.cs プロジェクト: petlof/SSFTiming2OLA
 void sp_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     MessageBox.Show("Got error: " + e.EventType);
     sourcePort.Close();
     sourcePort.Dispose();
     sourcePort = null;
     btnConnectSource.Invoke(new MethodInvoker(() =>
     {
         btnConnectSource.Text = "Connect";
     }));
 }
コード例 #3
0
 private void ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     Console.WriteLine(Environment.NewLine + nameBarDec + "Поймал ошибку! {0}", DateTime.Now.ToLocalTime().ToString());
     foreach (SerialPort port in _port)
     {
         if (port.BytesToRead != 0)
         {
             Console.WriteLine(nameBarDec + "Ошибка с {0}:\n" + port.ReadLine(), port.PortName);
         }
     }
 }
コード例 #4
0
 /// <summary>
 /// Handles the ErrorReceived event of the SerialPort.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="SerialErrorReceivedEventArgs"/> instance containing the event data.</param>
 private void SerialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     try
     {
         onError?.Invoke(this, e.EventType);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
コード例 #5
0
 private void SerialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     if (MessageBox.Show("Serial Port Error",
                         "Error",
                         MessageBoxButton.OK,
                         MessageBoxImage.Error,
                         MessageBoxResult.OK) == MessageBoxResult.OK)
     {
         Exit();
     }
 }
コード例 #6
0
 void mserial_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     try
     {
         string m = e.ToString();
     }
     catch (Exception f)
     {
         string errMsg = f.Message;
     }
 }
コード例 #7
0
 void m_Port_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     if (InvokeRequired)
     {
         ErrorReceivedDelegate d = new ErrorReceivedDelegate(ErrorReceived);
         Invoke(d, new object[] { e });
     }
     else
     {
         ErrorReceived(e);
     }
 }
コード例 #8
0
 void COM_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     System.IO.Ports.SerialPort sp = (System.IO.Ports.SerialPort)sender;
     loger.Log(
         new LogerMsg(
             String.Format(R.Error_Format,
                           e.EventType.ToString(), sp.PortName), TraceLevel.ERROR));
     if (ErrorReceived != null)
     {
         ErrorReceived.BeginInvoke(sender, e, null, null);
     }
 }
コード例 #9
0
ファイル: frmMain.cs プロジェクト: flyinmryan/SimpleCH3OCtrl
 private void serialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     try
     {
         System.Diagnostics.Debug.WriteLine(e);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         System.Diagnostics.Debug.WriteLine(ex.ToString());
     }
 }
コード例 #10
0
        /// <summary>
        /// 错误处理函数
        /// </summary>
        void comPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
        {
#if TEST
            OutputDebugString("comPort_ErrorReceived ");
#endif
            if (Error != null)
            {
#if TEST
                OutputDebugString(e.ToString());
#endif
                Error(sender, e);
            }
        }
コード例 #11
0
ファイル: XBeeAPIPort.cs プロジェクト: jesumarquez/lt
 private void ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     lock (uartLocker)
     {
         transient_uart_errors++;
         STrace.Debug(GetType().FullName, "ErrorReceived: " + e.EventType);
         if (transient_uart_errors == 10)
         {
             transient_uart_errors = 0;
             Estado = Estados.PUERTO_CERRADO;
         }
     }
 }
コード例 #12
0
 void sp_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     try
     {
     }
     catch (TimeoutException tex)
     {
         MessageBox.Show("Timeout oldu:\n" + tex);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception oldu:\n" + ex);
     }
 }
コード例 #13
0
 private void Port_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     // In caso di errore cambio il testo sul pulsante
     port.Close();
     if (ConnectButton.InvokeRequired)
     {
         ConnectButton.Invoke((Action)(() => UpdateText(ConnectButton, "Connect")));
         return;
     }
     else
     {
         UpdateText(ConnectButton, "Connect");
     }
 }
コード例 #14
0
ファイル: SerialUBX.cs プロジェクト: nhutt-baf/f9p
        private void Port_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
        {
            lock (eventLock)
            {
                MessageBox.Show("ERROR ERROR");
                switch (e.EventType)
                {
                case SerialError.TXFull:
                    break;

                case SerialError.Overrun:
                    break;
                }
            }
        }
コード例 #15
0
ファイル: Form1.cs プロジェクト: Haberwin/NBM01
        private void SerialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
        {
            int n = this.SerialPort.BytesToRead;

            byte[] buf = new byte[n];
            this.SerialPort.Read(buf, 0, n);
            ReceiverError.Append(this.SerialPort.Encoding.GetString(buf));
            if (ReceiverError.ToString().EndsWith("\r\n"))
            {
                PrintLog(">>>" + ReceiverError.ToString());
                ReceiverError.Clear();
            }
            FaidTimes += 1;
            SetFailTime(FaidTimes);
        }
コード例 #16
0
        SerialDataReceivedEventHandler thcPort_DataReceived(object sender, SerialErrorReceivedEventArgs arg)
        {
            StringBuilder sdata = new StringBuilder(rcvData);

            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker) delegate()
                {
                    // ProcessSerialMessage(sdata);
                });
            }
            else
            {
                //ProcessSerialMessage(sdata);
            }
        }
コード例 #17
0
ファイル: DrawMain.cs プロジェクト: xiaodelea/DrawGRBL
 private void serialPort1_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     try
     {
         string inLine = serialPort1.ReadLine();
         DataReceivedOK = inLine;
         Byte[] InputBuf = System.Text.Encoding.Default.GetBytes(inLine);
         this.BeginInvoke(disp_delegate, InputBuf); //disp_delegate是定义的委托事件,在委托事件中调用修改UI的程序
     }
     catch (TimeoutException ex)                    //超时处理
     {
         MessageBox.Show(ex.ToString());
         DataReceivedOK = "error";
     }
     Application.DoEvents();
 }
コード例 #18
0
 protected virtual void ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     if (this.IsClosing)
     {
         return;
     }
     try
     {
         this.IsErrorReceiving = true;
         this.ComPort_ErrorReceived(sender, e);
     }
     catch { }
     finally
     {
         this.IsErrorReceiving = false;
     }
 }
コード例 #19
0
 void eventSerialPort_ErrorReceived_AfterOpen(object sender, SerialErrorReceivedEventArgs e)
 {
     if (e.EventType == expectedError)
     {
         if (eventCount == 0)
         {
             Log.Comment("AfterOpen event fired.  Event Type: " + e.EventType);
         }
         eventCount++;
     }
     // with loopback you can't get a TxFull without an RX FULL
     else if (!(e.EventType == SerialError.RXOver && expectedError == SerialError.TXFull))
     {
         Log.Exception("Expected EventType " + expectedError + " but received EventType " + e.EventType);
         result = MFTestResults.Fail;
     }
 }
コード例 #20
0
        public void HandleEvent(object source, SerialErrorReceivedEventArgs e)
        {
            int bytesToRead;

            lock (_com)
            {
                bytesToRead = _com.BytesToRead;
            }

            lock (this)
            {
                BytesToRead.Add(bytesToRead);
                EventType.Add(e.EventType);
                Source.Add((SerialPort)source);
                NumEventsHandled++;
                System.Threading.Monitor.Pulse(this);
            }
        }
コード例 #21
0
        private void SP_ErrorRecieved(Object sender, SerialErrorReceivedEventArgs e)
        {
            string data = "";

            if (fsendData)
            {
                try
                {
                    data = _serialport.ReadLine();
                }
                catch (TimeoutException error)
                {
                    log.Error(error.Message);
                }
                string retval = "err";
                OnBarcodeScan(retval);
            }
        }
コード例 #22
0
        private void OnErrorReceived(object sender, SerialErrorReceivedEventArgs e)
        {
            //Event handler for a serial port error
            switch (e.EventType)
            {
            case SerialError.Frame:
                if (this.PrinterEventChanged != null)
                {
                    this.PrinterEventChanged(this, new PrinterEventArgs(e.EventType));
                }
                break;

            case SerialError.Overrun:
                if (this.PrinterEventChanged != null)
                {
                    this.PrinterEventChanged(this, new PrinterEventArgs(e.EventType));
                }
                break;

            case SerialError.RXOver:
                base.DiscardInBuffer();
                if (this.PrinterEventChanged != null)
                {
                    this.PrinterEventChanged(this, new PrinterEventArgs(e.EventType));
                }
                break;

            case SerialError.RXParity:
                base.DiscardInBuffer();
                if (this.PrinterEventChanged != null)
                {
                    this.PrinterEventChanged(this, new PrinterEventArgs(e.EventType));
                }
                break;

            case SerialError.TXFull:
                base.DiscardOutBuffer();
                if (this.PrinterEventChanged != null)
                {
                    this.PrinterEventChanged(this, new PrinterEventArgs(e.EventType));
                }
                break;
            }
        }
コード例 #23
0
        private void _SerialErrorReceived(object sender, SerialErrorReceivedEventArgs e)
        {
            //Console.WriteLine("Error: " + e.EventType.ToString());

            if (SerialError != null)
            {
                if (_uiInvokeControl != null)
                {
                    _uiInvokeControl.Invoke((MethodInvoker) delegate
                    {
                        SerialError();
                    });
                }
                else
                {
                    SerialError();
                }
            }
        }
コード例 #24
0
 /// <summary>
 /// 记录串口通讯异常信息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void _spCom_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     curErrCount++;
     if (curErrCount >= 10)
     {
         Stop();
         Close();
         Thread.Sleep(100);
         WeightDeviceLogger.Error("重新打开串口._spCom.IsOpen=" + _spCom.IsOpen);
         if (Open())
         {
             Start();
             WeightDeviceLogger.Debug("已重新打开串口._spCom.IsOpen=" + _spCom.IsOpen);
         }
         curErrCount = 0;
     }
     WeightDeviceLogger.Error("接受到串口通讯错误。e.EventType=" + e.EventType);
     //ShowErrorMsg(ErrorType.Error, "接受到串口通讯异常");
 }
コード例 #25
0
 private void OnErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     try
     {
         if (_portSerie.IsOpen)
         {
             Close();    // Ferme le port Serie
             Open();
         }
         else
         {
             Open();
         }
     }
     catch (Exception ex)
     {
         GestionErreur.GerrerErreur(ex);
     }
 }
コード例 #26
0
        //----------------------------------------------------------------------------
        /// <summary>
        /// Обработчик событий ошибочной работы COM-порта
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComPort_ErrorReceived(object sender,
                                           SerialErrorReceivedEventArgs e)
        {
            switch (e.EventType)
            {
            case SerialError.Frame:
            {
                _error = RequestError.Frame;
                break;
            }

            case SerialError.Overrun:
            {
                _error = RequestError.Overrun;
                break;
            }

            case SerialError.RXOver:
            {
                _error = RequestError.RXOver;
                break;
            }

            case SerialError.RXParity:
            {
                _error = RequestError.RXParity;
                break;
            }

            case SerialError.TXFull:
            {
                _error = RequestError.TXFull;
                break;
            }
            }

            StopTransaction();

            _timeOut.Set();

            return;
        }
コード例 #27
0
ファイル: StepMotor.cs プロジェクト: Ilia-Kosenkov/StepMotor
        protected virtual void Port_ErrorReceived(object sender, SerialErrorReceivedEventArgs args)
        {
            var n = Port.BytesToRead;

            if (n <= 0)
            {
                return;
            }

            var buffer = ArrayPool <byte> .Shared.Rent(n);

            try
            {
                Port.Read(buffer, 0, n);
            }
            finally
            {
                ArrayPool <byte> .Shared.Return(buffer);
            }
        }
コード例 #28
0
        void OnErrorReceived(object sender, SerialErrorReceivedEventArgs e)
        {
            switch (e.EventType)
            {
            case SerialError.Frame:
                break;

            case SerialError.Overrun:
                break;

            case SerialError.RXOver:
                break;

            case SerialError.RXParity:
                break;

            case SerialError.TXFull:
                break;
            }
        }
コード例 #29
0
ファイル: Form1.cs プロジェクト: anand1606/SAPWeigh
 private void ErrorReceivedHandler(object sender, SerialErrorReceivedEventArgs e)
 {
     lock (eventLock)
         if (e.EventType == SerialError.TXFull)
         {
             Exception ex = new Exception("Error: TXFull. Can't handle this!");
             WriteErr(ex, "Terminating Program");
             terminateService.Set();
         }
         else
         {
             Exception ex = new Exception(e.ToString());
             WriteErr(ex, "Resetting everything");
             var port = (SerialPort)sender;
             port.DiscardInBuffer();
             port.DiscardOutBuffer();
             string x = port.ReadExisting();
             unprocessedBuffer = null;
             //port.Write(new byte[] { NAK }, 0, 1);
         }
 }
コード例 #30
0
        /* This event handler captures any SerialPort Receive Errors
         *
         */
        #region Serial ErrorReceived Handler
        void oSerialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
        {
            if (e.EventType == SerialError.RXOver)
            {
                Debug.Print("RXOver on Port");
            }

            else if (e.EventType == SerialError.Overrun)
            {
                Debug.Print("Overrun on Port");
            }

            else if (e.EventType == SerialError.RXParity)
            {
                Debug.Print("Parity on Port");
            }

            else if (e.EventType == SerialError.Frame)
            {
                Debug.Print("Frame on Port");
            }
        }
コード例 #31
0
ファイル: cProt.cs プロジェクト: wxgb9801/Measurer
 void ThePort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     throw new Exception("The method or operation is not implemented." + e.EventType.ToString());
 }
コード例 #32
0
 /// <summary>
 /// Com Port Error Received event
 /// </summary>
 /// <param name="sender">object sender</param>
 /// <param name="e">event Args</param>
 private void ComPortErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
 }
コード例 #33
0
ファイル: MainWindow.cs プロジェクト: xmalmorthen/DashBoard
 void sport_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
 {
     SerialPort thisPort = (sender as SerialPort);
     SerialError err = e.EventType;
     BitacoraModel.addItem ("Error de resepción de puerto",string.Format ("Puerto {0}", thisPort.PortName),string.Format ("{0}",err.ToString()),"ERROR");
 }