I've followed a brief tutorial Here to read serial port data (I have an Arduino that intercepts a data feed from a home weather station) and whoever wrote it doesn't seem to provide a way to start the program, how would I start the process from the main method? Would it be easier in a Windows form text block or something?
Many thanks
Mike
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
namespace SerialPortReader
{
class Program
{
SerialPort serialP = new SerialPort("COM4", 38400);
static void Main(string[] args)
{
Console.Read();
}
private Program()
{
serialP.DataReceived +=new SerialDataReceivedEventHandler(serialP_DataReceived);
serialP.Open();
Console.Read();
}
void serialP_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(serialP.ReadExisting());
}
}
}

New Topic/Question
Reply




MultiQuote





|