EDIT: Was a hardware problem.....getting a duplicate device or cable seemed to solve the problem.
Hello, I am pulling my hair out trying to read a large quantity of data (~1MB) from a serial port in .NETCF.
I'm reading a dump of GPS data, but I am randomly receiving a TimeoutException on the call to m_serial.Read(..)
There is definitely data streaming in on the serial port -- the dump takes a couple minutes. When I get the timeout, I can just plug the serial cable into a different computer and see the data streaming steadily by.
I've tried implementing this several different ways -- SerialPort.Read, SerialPort.ReadLine, SerialPort.ReadExisting -- and they all will read for a short time (random amount) and then fail with a TimeoutException.
Any help would be very much appreciated, thank you! I'm basically at a loss as how I'm getting a timeout when there is certainly data available, streaming at 38400 baud
//m_serial is a SerialPort object, ReadTimeout set to 9000
string eoftest = "\r\n$PSRF206";
byte[] bEOFTest = ASCIIEncoding.ASCII.GetBytes(eoftest);
int bufferSize = 1024 * 16;
byte[] buffer = new byte[bufferSize];
int testingIndex = 0;
while (testingIndex < bEOFTest.Length)
{
int count = m_serial.Read(buffer, 0, bufferSize);
if (count > 0)
{
for (int i = 0; i < count; i++)
{
if (buffer[i] == bEOFTest[testingIndex])
{
testingIndex++;
if (testingIndex >= bEOFTest.Length)
break;
}
else
testingIndex = 0;
}
writer.Write(buffer, 0, count);
}
}
UPDATE:
I've discovered that the code runs fine on a Motorola Symbol device, but not on an intermec device that I have. I've swapped out all the hardware to try and eliminate that as a possibility, and it still doesn't work.
Both devices are Windows Mobile 5.0