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

  • Thread starter Thread starter jwei
  • Start date Start date
J

jwei

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);
}
}
}
 
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.
 
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
 
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
 
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
 
no success

there is no heavy load ...

maybe i should use createfile instead of serialport class (regarding
underlaying stream buffer) ?
 
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
 
did you also used at91rm9200-dk/ek ?
maybe this is an adeneo bsp driver issue (windows ce 5) ?
 
Back
Top