Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

serial comm;unable wrt. to a port while thread is using WaitCommEvent

Status
Not open for further replies.

uskorc

Programmer
Joined
Jun 14, 2003
Messages
1
Location
SI
Hello!

I am working on a simple program 4 read/write operations to a serial port. I set up everything and it all goes well to the point where I start a separate thread to monitor the port with the SetCommMask and WaitCommEvent functions.
The writing is working fine. When I start the tread which monitors the port, I cannot write to it unless I send sth back. I am using functions CreateFile, ReadFile etc and they are all from examples within the help.

So everything IS working, the writing, the reading ... but I can only either write or read ... if I want to send some data while waiting for an event with WaitCommEvent in another thread I simply cannot but if a send sth back the data is received and then the char is also sent.

Can I raise any event monitored by the WaitCommEvent by hand so that it releses the I don't know whatever the function is holding to and then I could do the job within the same thread, I would just specify that the data must be sent and in an if clause he would sent it and then go back waiting for the data. Or must I do sth. before the EriteFile?

I've been searching the solution for 2 days now and no luck.

Thanx!
 
Using FILE_FLAG_OVERLAPPED when you open the serial port with CreateFile. Some functions should be used, such as WaitforSingleObject, WaitCommEvent, etc., when you write/ read something to/from the serial port.

hope helpful
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top