Overlapped Read from COM port

  • Thread starter Thread starter Brad Markisohn
  • Start date Start date
B

Brad Markisohn

Does the compact framework serial API support overlapped IO? I need to
handle both synchronous and asynchronous data and I would prefer to use a
polling scheme to make my data retrieval life easier, but I can't allow the
system to hang waiting for a read to complete. I've had problems in the
past killing a thread in the middle of a blocking read. I'm using the
OpenNetCF Serial IO code which does supply an interrupt event, but that
complicates my parsing life. Any suggestions?

TIA

Brad
 
No overlapped support on CE, but if memory serves me right, on CE (unlike
the desktop) you can call both Read & WriteFile from different threads
without the system hanging. Try it.

If you tell us how it complicates your parsing life maybe someone can
help...

Cheers
Daniel
 
Brad,

As Paul and Daniel have said, overlapped IO isn't supported by the CE
operating system, but you can use multithreading to avoid blocking your main
UI thread while you are waiting for data to arrive at the port. Once you
know that x bytes are there, then only attempt to read x number of bytes.
Take a look at the code for the IO.Serial class on www.opennetcf.org for
ideas.
 
Hi,

Or, download CFSerialIO from my homepage. I include a polling example in
the simple-minded example that is included. The Serial class from
opennetcf.org should work fine, though. What sort of problem do you have
when you poll using it?

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.
 
Back
Top