12-18-2007 06:10 AM
12-18-2007 06:19 AM
12-18-2007 06:21 AM
12-18-2007 06:23 AM - edited 12-18-2007 06:29 AM
I think reading from a serial port is one of the most common questions asked in this forum. It depends on your application how to implement this function. I will show an example that continuously monitors the serial port in a standalone thread. When data is collected from the serial port it holds the data in a string buffer until there is no more data to be read at the serial port. Since I don't control how fast or when the data will be at the serial port -- I loop the read in 75ms iterations until the serial port is completely empty (no more data is there to be read)
One note is that it is very important to poll the serial port as to how much data it contains for eading and then read that entire amount. See below. Tom