Access a COM Port - CSharp File IO

CSharp examples for File IO:COM

Description

Access a COM Port

Demo Code


using System;//  www  .j  a  v  a 2 s .c om
using System.IO.Ports;

    static 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;

                // Write a message into the port.
                port.Open();
                port.Write("Hello world!");

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

Result


Related Tutorials