/// <summary> /// シリアルデータ受信イベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Port_DataReceived(object sender, SerialDataReceivedEventArgs e) { // ログデータ受信処理を登録 LogOutputDelegate logOutput = new LogOutputDelegate(messegeReceive); // データ受信バッファ Byte[] buf = new byte[this.Port.BytesToRead]; // 受信データが存在する if (buf.Length > 0) { try { // Serial Portより受信 this.Port.Read(buf, 0, buf.Length); // 受信データをメインスレッドへ dispatcher.BeginInvoke(logOutput, buf); } catch (Exception ex) { Debug.WriteLine("SERIAL DATA RECEIVE EXCEPTION : {0}", ex.ToString()); } } }
public static void RegisterLogOutput(LogOutputDelegate logOutput) { LogOutputs.Add(logOutput); }