Right now, my program logs all serial output from the Arduino board. The numbers appear as 25, 26, 27, etc. Numbers above 25 only need to be logged, and logging should be suspended as soon as the numbers go below 26 but resume again when the number reaches 26.
I have 122 lines or so that are used to show the console output as all output is logged to file, but writing four or five classes to mirror the output seems weird to me compared to other languages. This is rather much a beginner's question, but I'd like to know if there is a simpler way of logging console output but only do so when numbers reach a certain point, and perhaps maintaining the ability to see everything in the console window.
I know that I probably also need to write the output from the serial port to a variable, then use an if statement to evaluate it and start the logging when required, but with my current logging mechanism I don't really know how it is supposed to work. SO, really a simple algorithm that I can't seem to get my head around in C# in this case.
I'm assuming that if I am right about this, the variable should be here so that it stores the serial output:
static void p_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(
(sender as SerialPort).ReadExisting());
}
It'd be great if I can get some help on this. I've been looking around for a while, but I haven't found anything consistent. Improving the logging mechanism would also be great, since that's partly what is confusing me when I need to log only certain parts of information.