Hi Jan (& anybody else out there!)
I have a project that is being awkward it involves two board of custom design (PIC based). I am being forced to use the below function for Comms to the board due to an earlier mess. It's principle is fairly simple Write() sends a command and waits in the function for a reply. I have a timer running to avoid lock ups of the board not answering which could mean it has crashed. The problem I am now seeing it the recieved data flag is being raised one byte comes in and that satisfys the test conditions the data gets processed and there is not a complete byte ready. Instead of it being #RE=152,143,112 it only #RE=152, it gets past the checks and falls flat on its face.
while ((DUTComPort.BytesToRead > 0) && (gotresponse == false))
{
boolFalseTrip = false;
NoDataAtPort.Start();
Data_From_DUT = DUTComPort.ReadExisting();
if (Data_From_DUT.Contains('\r'))
{
gotresponse = true;
}
else if (!Data_From_DUT.Contains('\r'))
{
gotresponse = false;
}
rtbDUTIncoming.Text += Data_From_DUT;
}
Seems to get it self in a knot??