[Mono-dev] Serial ports in mono - event notification

Dries Naudts dries.naudts at intec.ugent.be
Wed Oct 17 03:59:34 EDT 2007

Dear Eric,

thank you very much for your detailed information. I will consider your 
polling technique. Since I'm not sure whether mono will support serial 
events soon, it seems like a good solution for both environments.

Kind regards,

Engler, Eric wrote:
> Hash: SHA256
>> What is the current status on the event notification mechanism of 
>> serial ports in  Mono? 
> I can't comment on the Mono status question but I thought I'd pass along
> a lesson I learned about serial events in Windows. They are notoriously
> late in many cases due to buffering. They are supposed to occur quick
> enough to let you stream at a high baud rate, but Windows XP tries to
> reduce the frequency of the events because it can cache the data (it
> caches a lot more than the small UART cache buffer). This is maddening
> for people like me who want to know immediately when a byte has been
> received. 
> If you only need a relatively low baud rate, or if you can tolerate a
> delay in notification, this may be fine. In my case I needed 115K baud
> and I had to know immediately when a byte was received (I could not
> accept any significant latency).
> I took a 2-prong approach to fix my problem. Firstly, when I am in a
> routine that knows how many bytes to expect I go into a tight loop and
> receive that number of bytes. Secondly, when I am not sure when to
> expect incoming data, I hook the Windows Application_Idle event and I
> poll the serial port to see if it found any data. This polling gives me
> immediate notification without delay, but the Application_Idle event
> doesn't occur often enough to let me stream data at 115K baud, so that's
> why I combined both approaches. Another advantage of this approach is
> that it freed me from the threading concern of having to marshal over
> the data from a background event over to the GUI thread (not difficult,
> but still a little bit of a pain).
> You can see my Windows application here (a visual debugger for
> microcontrollers):
> http://www.EricEngler.com/Pluto.aspx
> Mono serial events (when implemented) might not share this Windows XP
> problem, especially when running on linux, but if you need one
> application to work on both environments this is something to consider.
> Eric
> NOTICE:  The information contained in this electronic mail transmission is intended by the sender for the sole use of the named individual or entity to which it is directed and may contain information that is privileged or 
> otherwise confidential.  Please do not copy it or use it for any purposes, or disclose its contents to any other person.  To do so could violate state and Federal privacy laws.  If you have received this electronic mail
> transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply email or by telephone, so that the sender's address records can be corrected.  Thank you for your cooperation.
> Version: PGP Universal 2.6.2
> Charset: us-ascii
> wsBVAwUBRxOnUchfyUs+le7yAQjclQf/Y9UVN9lgzoKzlQ9NuQZhH147mT3IDYvq
> sEm+Q13jVuUE5tVQ3QjrcKJ33TN40XqdK6q7oSptnVjODWsy4vl3P7D7zRxVihAz
> 9/WQWhQSL5+ItxiCYNLIJ63M+hSQ+IO9SCTtMbVlOxxct+bSGokDnh4Gp3u1FkLo
> nXgDImyuj1fmg4qPpWsNUnvB5n4dflYl6dBgVwmIEXaa5pNB4WH5/G32FnFuSpWS
> /3SHZwxkAQkFe97axc1VwdGJSvxb4dwrdF0FzmwzTBLPAwM6T7J5ZXCT9q2yO3dA
> gxGiJbfJlJAYe0DSD6xYeR2a8Dy3ML/KNFbOvrTCWD5FyAtL3GKkEQ==
> =cSHh
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

Dries Naudts
IBCN - IBBT - Universiteit Gent
Gaston Crommenlaan 8 bus 201
B-9050 Ghent
Tel: +32 9 331 49 74
Fax: +32 9 331 48 99

More information about the Mono-devel-list mailing list