new SerialPort("COM1", 19200)) : SerialPort « System.IO.Ports « C# / C Sharp by API






new SerialPort("COM1", 19200))

  
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.SerialPort.BaseStream
2.SerialPort.BaudRate
3.SerialPort.Parity
4.SerialPort.Read
5.SerialPort.ReadTimeout
6.SerialPort.StopBits
7.SerialPort.Write