Set BaudRate, Parity, ReadTimeout, StopBits for COM1 SerialPort : SerialPort « Development Class « C# / C Sharp






Set BaudRate, Parity, ReadTimeout, StopBits for COM1 SerialPort

  


using System;
using System.IO.Ports;

class MainClass {
    static void Main(string[] args) {
        using (SerialPort port = new SerialPort("COM1")) {
            port.BaudRate = 9600;
            port.Parity = Parity.None;
            port.ReadTimeout = 10;
            port.StopBits = StopBits.One;

            port.Open();
            port.Write("Hello world!");

            Console.WriteLine("Wrote to the port.");
        }
    }
}
           
         
    
  








Related examples in the same category

1.SerialPort Class represents a serial port resource.
2.Represents the method that will handle the data received event of a SerialPort object.
3.Gets an array of serial port names for the current computer.
4.Write data to COM port