XBEE_CONRX(3)

NAME
xbee_conRx

SYNOPSIS
#include <xbee.h>

xbee_err xbee_conRx(struct xbee_con *con, struct xbee_pkt **retPkt, int *remainingPackets);

xbee_err xbee_conRxWait(struct xbee_con *con, struct xbee_pkt **retPkt, int *remainingPackets);

DESCRIPTION
xbee_conRx() allows you to retrieve information from an active connection. con must be non-NULL, and must point at a valid connection. At least one of retPkt and remainingPackets must be non-NULL.

retPkt may optionally be non-NULL, in which case the next packet in the connection's buffer is returned to you. If you receive a packet from a connection, you must not forget to call xbee_pktFree(3) when you are finished with it. If retPkt is non-NULL, and a callback has been configured for the connection, then XBEE_EINVAL will be returned and neither retPkt or remainingPackets will have been updated - see xbee_conCallbackSet(3) for more information.

remainingPackets may also optionally be non-NULL. If it is non-NULL, then it will be populated with the number of packets that are currently in the connection's buffer.

When a callback is enabled, xbee_conRx() may be called with retPkt set to NULL, and remainingPackets set as non-NULL.

xbee_conRxWait() is identical to xbee_conRx(), except that it will busy-wait for upto 1 second, checking if there is a packet available.

  Return Value
On success this function will return XBEE_ENONE, otherwise an error number from enum xbee_errors (as specified in <xbee.h>).

XBEE_ENOTEXISTS will be returned if there is no packet available to retrieved.

EXAMPLE
#include <xbee.h>
struct xbee *xbee;
struct xbee_con *con;
struct xbee_pkt *pkt;
/* initialize xbee, using xbee_setup() */
/* initialize con, using xbee_conNew() */
/* receive some data for con */
if (xbee_conRx(con, &pkt, NULL) != XBEE_ENONE) return;
/* use pkt */
if (xbee_pktFree(pkt) != XBEE_ENONE) return;

AUTHOR
Attie Grande <attie@attie.co.uk>

SEE ALSO
libxbee(3) xbee_setup(3), xbee_conNew(3), xbee_pktFree(3), xbee_conCallbackSet(3)