SerialPort.Read : SerialPort « System.IO.Ports « C# / C Sharp by API






SerialPort.Read

  
using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Ports;

class Serial
{
 public static void Main()
 {
      byte[] buffer = new byte[256];
      using (SerialPort sp = new SerialPort("COM1", 19200))
      {
           sp.Open();
           //read directly
           sp.Read(buffer, 0, (int)buffer.Length);
           //read using a Stream
           sp.BaseStream.Read(buffer, 0, (int)buffer.Length);
      }
 }
}

   
    
  








Related examples in the same category

1.new SerialPort("COM1", 19200))
2.SerialPort.BaseStream
3.SerialPort.BaudRate
4.SerialPort.Parity
5.SerialPort.ReadTimeout
6.SerialPort.StopBits
7.SerialPort.Write