static void TimestampListener(Object sender, TransportListenerEventArgs e) { Console.Write(String.Format("{0} {1}", DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"), e.Tx ? "Sending" : "Received")); for (int i = 0; i < e.Data.Length; i++) { if ((i & 15) == 0) { Console.WriteLine(); Console.Write(" "); } Console.Write(" " + e.Data[i].ToString("X2")); } Console.WriteLine(); }
/// <summary> /// Simple console-output transport listener /// </summary> public override void SimpleTransportListener(Object sender, TransportListenerEventArgs e) { string msg; msg = Encoding.ASCII.GetString(e.Data, 0, e.Data.Length); // Replace the newline(\n)from the message with Null string msg = msg.Replace(";\n", "").Replace("\n", ""); msg = "\"" + msg.Replace("\r", "\\r").Replace("\n", "\\n") + "\";"; Console.WriteLine(String.Format( "{0}: {1} (timeout={2:D}ms)", e.Tx ? "TX" : "RX", msg, e.Timeout )); }
private void SerialListener(Object sender, TransportListenerEventArgs e) { transportLogFile.Write(String.Format("{0} {1}", DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"), e.Tx ? "Sending" : "Received")); for (int i = 0; i < e.Data.Length; i++) { if ((i & 15) == 0) { transportLogFile.WriteLine(); transportLogFile.Write(" "); } transportLogFile.Write(" " + e.Data[i].ToString("X2")); } transportLogFile.WriteLine(); transportLogFile.Flush(); }
/// <summary> /// Simple console-output transport listener /// </summary> public override void SimpleTransportListener(Object sender, TransportListenerEventArgs e) { string msg; msg = Encoding.ASCII.GetString(e.Data, 0, e.Data.Length); Console.WriteLine(String.Format( "{0}: {1} (timeout={2:D}ms)", e.Tx ? "TX" : "RX", msg, e.Timeout )); }