Transferring Data

Discard Data

lgo_DiscardData()

Discard a waiting data packet.

Syntax
#include "laygo.h"

LResult lgo_DiscardData
    (
        LCid    cid
    );
cidconnection with data waiting to be read
Description

lgo_DiscardData() discards a waiting data packet. Only data, CRC error, aborted frame and length error events can be discarded in this way. Control events must be read using lgo_Event().

lgo_DiscardData() is intended primarily for applications using only a physical layer, without the services of a link or packet layer. In this case, data which would normally be discarded by higher layer protocols is passed to the application and may be discarded without being read.

Return Values

If successful, lgo_DiscardData() returns a non-negative value. Otherwise, it returns a negative value indicating the reason it failed. Possible unsuccessful return values are:

See Also

lgo_Read()
lgo_Poll()

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:

            lgo_DiscardData(cid);
            break;

        default:

            /* process nondata event */
            break;
    }
}