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"); } }
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"; })); }
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); } } }
/// <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); } }
private void SerialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) { if (MessageBox.Show("Serial Port Error", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK) == MessageBoxResult.OK) { Exit(); } }
void mserial_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) { try { string m = e.ToString(); } catch (Exception f) { string errMsg = f.Message; } }
void m_Port_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) { if (InvokeRequired) { ErrorReceivedDelegate d = new ErrorReceivedDelegate(ErrorReceived); Invoke(d, new object[] { e }); } else { ErrorReceived(e); } }
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); } }
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()); } }
/// <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); } }
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; } } }
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); } }
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"); } }
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; } } }
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); }
SerialDataReceivedEventHandler thcPort_DataReceived(object sender, SerialErrorReceivedEventArgs arg) { StringBuilder sdata = new StringBuilder(rcvData); if (this.InvokeRequired) { this.Invoke((MethodInvoker) delegate() { // ProcessSerialMessage(sdata); }); } else { //ProcessSerialMessage(sdata); } }
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(); }
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; } }
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; } }
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); } }
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); } }
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; } }
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(); } } }
/// <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, "接受到串口通讯异常"); }
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); } }
//---------------------------------------------------------------------------- /// <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; }
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); } }
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; } }
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); } }
/* 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"); } }
void ThePort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) { throw new Exception("The method or operation is not implemented." + e.EventType.ToString()); }
/// <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) { }
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"); }