problem with serial port 
Author Message
 problem with serial port

I open serial port with CreateFile and FILE_FLAG_OVERLAPPED.
I create 2 threads, one to read the serial port and another to write. If I
want to finish the read operation and terminate the opertations pending,
what could I do?

With PurgeComm? I need do it inmediatly, without any delay.

Thanks in advance



Sat, 29 Jun 2002 03:00:00 GMT  
 problem with serial port

Quote:

> I open serial port with CreateFile and FILE_FLAG_OVERLAPPED.
> I create 2 threads, one to read the serial port and another to write. If I
> want to finish the read operation and terminate the opertations pending,
> what could I do?

> With PurgeComm? I need do it inmediatly, without any delay.

> Thanks in advance

PurgeComm seems to work that way for me, with separate calls in the read and
write threads.  I do the following to see if there are any late completions and
it never asserts.  (The PurgeComm call definitely fixed an awful crash that only
happened about once a week.)

PurgeComm(m_hComport, PURGE_TXABORT | PURGE_TXCLEAR);
#ifdef _DEBUG
// Development test: Make certain the driver has stopped
// because we're about to free the buffer we gave it.
ResetEvent(m_osWrite.hEvent);
ASSERT(WaitForSingleObject(m_osWrite.hEvent, 1000) == WAIT_TIMEOUT);
#endif

--
Scott McPhillips [VC++ MVP]



Sat, 29 Jun 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. problems in serial port interfacing

2. Problems with serial port

3. problems with serial ports

4. Problems with serial port access in NT 4.0

5. Serial port to serial port copying software

6. Challenge: Virtual serial ports from real serial port

7. using PC/104 serial expansion board with WinCE, 4 serial ports total

8. problem with C-programme for Serial port (TTY)

9. Win32 Serial Port Problem (permuted characters)

10. serial port problem

11. Problem with accessing the serial port.

12. HELP for a serial port problem

 

 
Powered by phpBB® Forum Software