Transferring Data

Poll

lgo_Poll()

Poll for the presence of control or data events.

Syntax
#include "laygo.h"

LEvent  lgo_Poll
    (
        LCid             cid,
        LBufferSize *    count
    );
cidconnection to poll for events
counton output, size of buffer needed to receive the event
Description

lgo_Poll() tests for the receipt of control and data events. If lgo_Read() or lgo_ReadSpecial() fails with an error code of lgo_ERROR_BUFFER_SIZE, an application may call lgo_Poll() to determine the number of bytes of data waiting to be read.

Return Values

If successful, lgo_Poll() returns a non-negative value indicating the type of control event received. Possible successful return values are:

Otherwise, it returns a negative value indicating the reason it failed. Possible unsuccessful return values are:

See Also

lgo_Event()

Example
if ((event = lgo_Poll(cid, &bufferSize)) < 0)
{
    /* process error */
}
else
{
    switch(event)
    {
        case lgo_EVENT_DATA_OK:

            /* read good data */
            break;

        case lgo_EVENT_DATA_LENGTH_ERROR:
        case lgo_EVENT_DATA_CRC_ERROR:
        case lgo_EVENT_DATA_ABORTED_FRAME:

            /* discard bad data */
            break;

        default:

            /* process events */
            break;
    }
}