Excessive Delay with Compact Framework 2.0 and System.IO.Ports.SerialPort
Hello all,
Under Compact Framework 2.0 (using C#) I use the
System.IO.Ports.SerialPort data that is being read from the serial
port can take up to 6 seconds to read (after its actually received.)
This result is the same regardless of whether I loop the serial port
back on itself or communicate with an external device.
I've tried using SerialPort.ReadByte, SerialPort.Read and the
DataReceived Event. I really want to be able to use the DataReceived
event as it fits more with the design of the software. However at
this point, if one of the other ones can be made to work, I'll use it.
I've checked the rx/tx lines with a scope to verify the timing and
setup of the port. The output on the tx is correct, the input on the
rx looks correct and the input on the rx is confirmed to arrive about
6 seconds before it shows up in software. All verified with an
Oscilloscope.
The code (with the serial port looped back on itself) works under
Windows XP Pro with the .Net Framework 2.0. So I figure that the
problem is likely either in the embedded device trying buffering too
much data (and not firing the event until a long long 6 second timeout
elapses) or something else is going wrong.
I've also tried messing with the ReadTimeout property but have not had
any success.
Does anyone have any ideas or has seen this before? My next step is
to use the Win32 APIs to try and determine where the fault lies
(whether its at the Compact Framework or OS level.)
My Settings:
SerialPort.BaudRate = 9600;
SerialPort.ParityReplace = 0xaa;
SerialPort.DataBits = 8;
SerialPort.Handshake = Handshake.None
SerialPort.ReceivedBytesThreshold = 1; // Originally not set, set
to see if it would help.
SerialPort.StopBits = StopBits.One
SerialPort.Parity = Parity.Mark
Thank you for any help you may have.
Date:Thu, 02 Aug 2007 15:54:12 -0700
Author:
|