Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

serialport DataReceived event very slow -> fires after about 8sec

13 views
Skip to first unread message

jwei

unread,
Oct 28, 2009, 1:46:01 PM10/28/09
to
i am using an AT91RM9200 with win ce 5.0 and .net cf 2.0

using the following sample programm i try to send some chars over a serial
connection to the board with hyperterminal, but the key entered in
hyperterminal gets displayed (= DataReceived event fired) not until about
8sec ?!?

i debugged the serial driver also, and the AT91SERIAL_RxIntr gets called not
until 8sec too ... ?

any ideas ?
class Program {

static void Main(string[] args) {
SerialPort sp = new SerialPort("COM1", 9600, Parity.None, 8,
StopBits.One);
sp.Handshake = Handshake.None;

try {
sp.Open();
sp.DataReceived += new
SerialDataReceivedEventHandler(sp_DataReceived);
Thread.Sleep(Timeout.Infinite);
} catch (Exception ex) {
Console.WriteLine(ex.Message);
}
}

static void sp_DataReceived(object sender,
SerialDataReceivedEventArgs e) {
SerialPort sp = (SerialPort)sender;
try {
string s = sp.ReadExisting();
Console.WriteLine(s);
} catch (Exception ex) {
Console.WriteLine(ex.Message);
}
}
}

DickGrier

unread,
Oct 28, 2009, 3:14:48 PM10/28/09
to
I have not seen such a delay. Are you using a device, or the emulator?

BTW, I'd remove the Try/Catch block which does slow things down (though not
to this extent). There should never be an error here, at least AFAIK.

Dick

--
Richard Grier, Consultant, Hard & Software 12962 West Louisiana Avenue
Lakewood, CO 80228 303-986-2179 (voice) Homepage: www.hardandsoftware.net
Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004, Revised July
2006.

Markus Humm

unread,
Oct 29, 2009, 3:36:49 PM10/29/09
to
Hello,

I also never saw such a thing. RS232 is instant receiving of data. Seems
your RS232 driver has some problem or your hardware. Maybe it uses a
fifo which doesn't correctly report when it received some bytes or so?

Greetings

Markus

B-Dawg

unread,
Nov 2, 2009, 9:06:01 AM11/2/09
to
I've seen this kind of delay several times and once had to spend quite a
while getting to the bottom of it .

Not sure if it is related but in my case it was because I was loading the
processor too much (but not enough that the application ground to a halt).
After I re-coded my application to be more efficient it was fine. The same
sluggish behaviour was seen with both USB to RS232 serial dongles and the
harware serial ports.

Regards,

Bevan

"Markus Humm" wrote:

> .
>

Markus Humm

unread,
Nov 2, 2009, 12:31:46 PM11/2/09
to
Hello,

this could also be a case. So it the events don't come through anymore
because whtever the CPU hogs has higher pripority then thins will be
delayed until the events get a bit CPU time as well.

Greetings

Markus

jwei

unread,
Nov 5, 2009, 2:47:03 AM11/5/09
to
i use a real hardware : AT91RM9200-DK
i will try a simple program - thanks

"Markus Humm" wrote:

> .
>

jwei

unread,
Nov 5, 2009, 2:44:02 PM11/5/09
to
no success

there is no heavy load ...

maybe i should use createfile instead of serialport class (regarding
underlaying stream buffer) ?

Broeden

unread,
Nov 6, 2009, 3:00:01 PM11/6/09
to
Hi

I had the same problem... but I gave up and are now using the GPS
Intermediete driver directly. It work very well. See SDK WM6 GPS sample

/Brofalad

0 new messages