Board index » cppbuilder » serial port read and write problem!!!

serial port read and write problem!!!


2004-04-03 10:25:35 AM
cppbuilder60
Hi!
Now i wana write and read data stream through serial port at same time.i use
a thread for reading,and second thread for write,both threads use one file
handle.I wana know if my idea can be implemented!
Thanks
Tony
 
 

Re:serial port read and write problem!!!

Then you want to open the file in overlapped mode.
I don't know why Windows or the serial port would care if you read
from one thread and write from another.
. Ed
Quote
Tony wrote in message
news: XXXX@XXXXX.COM ...
Hi!
Now i wana write and read data stream through serial port at
same time.i use a thread for reading,and second thread for
write,both threads use one file handle.I wana know if my idea
can be implemented!
 

Re:serial port read and write problem!!!

Thanks for your reply
In your words,i cann't use TFileStream to access serial port for reading and
read at the same time,instead use CreateFile API?
If i don't open the file in overlapped mode,when i write data to the serial
port, the reading operation must be influence,mustn't it?
tony
Quote
Then you want to open the file in overlapped mode.

I don't know why Windows or the serial port would care if you read
from one thread and write from another.

. Ed
 

{smallsort}

Re:serial port read and write problem!!!

Quote
In your words,i cann't use TFileStream to access
serial port for reading and read at the same time,
instead use CreateFile API?
"In your words I..." is not correct. I said no such thing.
Your question was about serial communications in which reading and
writing were done from separate threads.
Neither your question nor my reply spoke of TFileStream. You asked
about the serial port. You did not ask about a class. My reply was
about the serial port. It was not about a class. Look in the
documentation for the class to see if it has any support for
overlapped I/O. Also look up TThread::Synchronize.
. Ed
Quote
Tony wrote in message
news: XXXX@XXXXX.COM ...

In your words,i cann't use TFileStream to access serial
port for reading and read at the same time,instead use
CreateFile API?

If i don't open the file in overlapped mode,when i write
data to the serial port, the reading operation must be
influence,mustn't it?

tony

>Then you want to open the file in overlapped mode.
>
>I don't know why Windows or the serial port would
>care if you read from one thread and write from another.
 

Re:serial port read and write problem!!!

Thanks a lot!Thanks for all you replied!
tony