Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Comm event query

3 views
Skip to first unread message

Bruce Varley

unread,
Dec 29, 2011, 5:21:13 AM12/29/11
to
Trying to get WaitCommEvent to work with non-overlapped I/O, and came across
the following sample code, reproduced in full. What is dwCommModemStatus,
how is it set? The code is obviously only skeleton. TIA


BYTE Byte;
DWORD dwBytesTransferred;

// Specify a set of events to be monitored for the port.
SetCommMask (hPort, EV_RXCHAR | EV_CTS | EV_DSR | EV_RLSD | EV_RING);

while (hPort != INVALID_HANDLE_VALUE)
{
// Wait for an event to occur for the port.
WaitCommEvent (hPort, &dwCommModemStatus, 0);

// Re-specify the set of events to be monitored for the port.
SetCommMask (hPort, EV_RXCHAR | EV_CTS | EV_DSR | EV_RING);

if (dwCommModemStatus & EV_RXCHAR)
{
// Loop for waiting for the data.
do
{
// Read the data from the serial port.
ReadFile (hPort, &Byte, 1, &dwBytesTransferred, 0);

// Display the data read.
if (dwBytesTransferred == 1)
ProcessChar (Byte);

} while (dwBytesTransferred == 1);
}


Bruce Varley

unread,
Dec 29, 2011, 6:07:43 AM12/29/11
to
Problem solved. Sorry for spurious post.

"Bruce Varley" <b...@NoSpam.com> wrote in message
news:EsKdnfyLT9-AomHT...@westnet.com.au...

Bert

unread,
Dec 29, 2011, 12:09:17 PM12/29/11
to
In news:EsKdnfyLT9-AomHT...@westnet.com.au "Bruce Varley"
<b...@NoSpam.com> wrote:

> Trying to get WaitCommEvent to work with non-overlapped I/O, and came
> across the following sample code, reproduced in full. What is
> dwCommModemStatus, how is it set? The code is obviously only skeleton.
> TIA
> ...
> WaitCommEvent (hPort, &dwCommModemStatus, 0);

If you look at the docs for WaitCommEvent, you'll see that the second
argument is shown as "__out LPDWORD lpEvtMask".

lpEvtMask
A pointer to a variable that receives a mask indicating the type of
event that occurred. If an error occurs, the value is zero; otherwise,
it is one of the following values. ...


--
be...@iphouse.com St. Paul, MN
0 new messages