using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
using System.Threading;
namespace SerealRead
{
class Program
{
SerialPort sp = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);
static void Main(string[] args)
{
new Program();
}
private Program()
{
//Set the datareceived event handler
sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
//Open the serial port
sp.Open();
Thread.Sleep(60000);
}
private void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
Console.Write( indata);
Console.WriteLine();
}
}
}