public void Read(HandleReturnStringDelegate handler) { if (iHandle != -1) { // Assume that an ASCII file is being read. System.Text.ASCIIEncoding Encoding = new System.Text.ASCIIEncoding(); byte[] buffer = new byte[128]; int bytesRead; do { bytesRead = this.Read(buffer, 0, buffer.Length); string content = Encoding.GetString(buffer, 0, bytesRead); if (handler != null) { handler(content); } else { System.Console.Write("{0}", content); } //return content; }while (bytesRead > 0); } // return string.Empty; }
public void Read(HandleReturnStringDelegate handler) { if (comPort.IsOpen) { this.hanlder = handler; comPort.DataReceived += new SerialDataReceivedEventHandler(comPort_DataReceived); } }
public void Read(HandleReturnStringDelegate handler) { if (iHandle!=-1) { // Assume that an ASCII file is being read. System.Text.ASCIIEncoding Encoding = new System.Text.ASCIIEncoding(); byte[] buffer = new byte[128]; int bytesRead; do { bytesRead = this.Read(buffer, 0, buffer.Length); string content = Encoding.GetString(buffer, 0, bytesRead); if (handler != null) { handler(content); } else { System.Console.Write("{0}", content); } //return content; } while (bytesRead > 0); } // return string.Empty; }