I am working on Visual Studio & I am designing a GUI for my sensor. My sensor is transmitting 8 bytes on press of button and I am having trouble while reading those 8 bytes available serially and store them in array, so I can further use those bytes here is my code below for serially reading available bytes.
For storing serial available bytes in an array I have created and assigned new array as follows:
byte incoming = new byte[9];
Serially writing to sensor is achieved successfully now I am facing trouble in reading the bytes available on serial port transmitted by my sensor. Kindly assist me in achieving best possible solution.
private void timer1_Tick(object sender, EventArgs e)
{
if (!serialPort1.IsOpen)
{
MessageBox.Show("Command cannot be sent, Serial Port Not opened");
}
else
{
serialPort1.Write(TandH, 0, TandH.Length);
serialPort1.Read(incoming[], 0, 8);
}
}