I am building a c# application that needs to read some serial data received from an arduino. The arduino sends the following:
Serial.write(0x1);
Serial.write(0x106);
Serial.write(fake_channel.samples, SAMPLE_COUNT); //Sample array
The sample array is nothing else than an array filled with integers.
What is the best way to read this with an c# application? I need to get the integer from the serial data. So when I got 0x1, I want to read the 1. I am able to read data with the following method:
private void serialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
//Code to read the serial data needed here
}
In an older application of mine, I was able to read some serial data in string format with: serialPort.ReadExisting(); The only problem now is that I am not receiving a string, but an integer that looks like a byte. That is the part I am confused about because how is it possible to read an integer out of a thing that looks like a byte.