471,350 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Asynchronous Serial port

Hello,

I am trying to write asynchronous serial port.
meaning, read and write operations are made via async cllbacks.
so far so good.
I open my port in continues state:
1)Set the BytesToRead property of the serial port.
2)open the port
3)generate read request
4)meanwhile generate write request.
5)in result, the read operation is executed(provided that the BytesToRead are
present n the stream)
i encountered a problem that despite of Setting the BytesToRead property,the
read operation is executed and reads 1 byte from the stream.
after the read operation is completed i generate another async read request
so the port is always in "Listening" mode.

am i doing something wrong?
can't i work asynchronically?
do i have to lock the stream or the port or the buffer itself?

Thanks

--
Message posted via http://www.dotnetmonster.com
Nov 28 '05 #1
2 11670
shayke wrote:
Hello,

I am trying to write asynchronous serial port.
meaning, read and write operations are made via async cllbacks.
so far so good.
I open my port in continues state:
1)Set the BytesToRead property of the serial port.
2)open the port
3)generate read request
4)meanwhile generate write request.
5)in result, the read operation is executed(provided that the BytesToRead are
present n the stream)
i encountered a problem that despite of Setting the BytesToRead property,the
read operation is executed and reads 1 byte from the stream.
after the read operation is completed i generate another async read request
so the port is always in "Listening" mode.

am i doing something wrong?
can't i work asynchronically?
do i have to lock the stream or the port or the buffer itself?

Thanks

I encountered the same problem.at the first read operation the read operation
returns after reading only the first byte.i think it is a problem of timeout
settings.i am not sure.
anyone else knows???

--
Message posted via http://www.dotnetmonster.com
Nov 29 '05 #2


shayke via DotNetMonster.com wrote:
am i doing something wrong?
can't i work asynchronically?
do i have to lock the stream or the port or the buffer itself?


In general, all .NET read primitives can read less bytes than "requested".

If bytes are not arriving fast the async read operation *should* return
a number of bytes less than BytesToRead.

If you need to wait until a certain number of bytes have arrived you
must copy those bytes into a buffer yourself and signal an event when
it's full.
--
Helge Jensen
mailto:he**********@slog.dk
sip:he**********@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-
Nov 30 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by ^CeFoS^ | last post: by
13 posts views Thread by Al the programmer | last post: by
13 posts views Thread by Rob | last post: by
8 posts views Thread by panko | last post: by
2 posts views Thread by Martijn | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.