开发者

serial port communication

HI all,

I am doing serial port co开发者_如何学JAVAmmunication program. How do I achieve the following.

  1. Need to know number bytes available for reading.
  2. Flushing

Note: I am creating File with Overlapped option.

thanks in advance

~ Johnnie


You are trying to query the number of bytes available first, and then read them. The standard way would be to just allocate a buffer (say 1000 chars), then call ReadComm() which tells you how many bytes were actually used (e.g. less than or equal to 1000).

You can flush the buffer of serial io using FlushFileBuffers() (http://msdn.microsoft.com/en-us/library/aa364439%28VS.85%29.aspx) but since you want asynchronous IO, you probably only want to do that when you have written to a file and then want to move the file (certainly not on every call to WriteComm()).

More info:

http://msdn.microsoft.com/en-us/library/ms810467.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜