Look RS232 > RS232C Hardware  
fCoder SIA
fCoder SIA Look RS232 Download Order Support Cookie Policy
Look RS232
Download
Order
Support
Testimonials
FAQ
Online help
Modem Programming
Serial port
RS232 Hardware
Programming
  Event

Win32 API provides WaitCommEvent function used to wait for events which can occur for the specified communications device. At that the set of events checked by this function is contained in the events mask connected with the given device.

Function syntax:

BOOL WaitCommEvent(HANDLE hFile, LPDWORD lpEvtMask, LPOVERLAPPED lpOverlapped);

Parameters specification:

hFile � the descriptor of the open file of the communication port;

lpEvtMask - pointer to a 32-bit variable which receives the mask specifying the type of event occurred. If an error occurs, null-value is returned, if the result is successful, one of the following values is returned:

  • EV_BREAK � inform when a send break is detected.
  • EV_CTS - inform about changes of CTS (clear-to-send) signal.
  • EV_DSR - inform about changes of DSR (data-set-ready)signal.
  • EV_ERR � inform about line-status errors. Line-status errors are CE_FRAME, CE_OVERRUN, and CE_RXPARITY.
  • EV_EVENT1 - An event of the first provider-specific type occured.
  • EV_EVENT2 - An event of the second provider-specific type occured.
  • EV_PERR � inform about printer errors.
  • EV_RING - A ring indicator was detected.
  • EV_RLSD - inform about changes of RLSD (receive-line-signal-detect) signal.
  • EV_RX80FULL - inform when the buffer is 80 percent full.
  • EV_RXCHAR - inform about the character reception and place the character into the front-end buffer.
  • EV_RXFLAG � inform about the receiving of a random character and its placing into the front-end buffer. The random character is specified in the DCB structure for the given device, which is recorded into the device by SetCommState function.
  • EV_TXEMPTY � inform about the transmission of the last character from the back-end buffer.

lpOverlapped - pointer to the OVERLAPPED structure. This structure is needed if hFile was opened with the help of FILE_FLAG_OVERLAPPED.

If hFile was opened with the help of FILE_FLAG_OVERLAPPED, lpOverlapped parameter shouldn't be NULL. This pointer should point at the active OVERLAPPED structure. If hFile was opened with the help of FILE_FLAG_OVERLAPPED and lpOverlapped is NULL, WaitCommEvent function is executed as an overlapped operation. In this case the OVERLAPPED structure should contain a descriptor to a manual-reset event object (created by using the CreateEvent function).

If hFile descriptor wasn't opened with the help of FILE_FLAG_OVERLAPPED, WaitCommEvent is not returned until one of the specified events (or an error) occurs.

Note

WaitCommEvent controls the events set for the specified connection resource. Use SetCommMask and GetCommMask functions to set and get a mask of the current eventfor the connection device.

If an overlapped operation cannot be stopped immediately the function returns FALSE and GetLastError function returns ERROR_IO_PENDING, by that indicating that an operation is being executed in the background. When it happens the system sets the hEvent member of the OVERLAPPED structure into not-signaled state until WaitCommEvent is returned, and then it sets it to the signaled state when one of the specified events (or an error) occurs. The request process can use one of the wait functions to detect the state of the event objects and then use GetOverlappedResult function to detect the WaitCommEvent operation result. GetOverlappedResult reports of a sucsessful or unsuccessful operation result, at the same time the transient pointer at lpEvtMask parameter is set to indicate the event occurred.

If the process is trying to change the event mask of the device descriptor by using the SetCommMask function while the overlapped WaitCommEvent operation is being executed, WaitCommEvent is immediately returned. The pointer of the lpEvtMask parameter variable is set to zero.

 
  Contact us
© fCoder SIA