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);
}
}
}
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.
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
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:
> .
>
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
"Markus Humm" wrote:
> .
>
there is no heavy load ...
maybe i should use createfile instead of serialport class (regarding
underlaying stream buffer) ?
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