I'm fairly new to C# and can't seem to find anything working for me. I need to get data from the serial port which I can collect successfully. Every time I click the button the data gets displayed. This data needs to go in an array, over this array I want the calculate the moving average.
What is the best way to approach this problem?
private void btnRead_Click(object sender, EventArgs e)
{
// Filtering incoming data from string to double
string inComingData = serialPort.ReadLine();
int charLoc = 0;
int serialCharLoc = inComingData.IndexOf("N");
while(!(inComingData.Contains("N")) && !(charLoc == serialCharLoc))
{
inComingData = serialPort.ReadLine();
}
rtbIncoming.Text = inComingData;
string [] usableData = inComingData.Split(' ');
string correctData = usableData[1];
tbData.Text = correctData;
serialPort.DiscardInBuffer();
This is the code I have right now to get the filtered data from the serial port.