Skip to content
This repository has been archived by the owner on May 16, 2019. It is now read-only.

Commit

Permalink
fixed support for XBEE_DISABLE_LOGGING
Browse files Browse the repository at this point in the history
  • Loading branch information
attie committed Jun 17, 2015
1 parent b07bf87 commit 77bdfec
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
18 changes: 18 additions & 0 deletions log.c
Expand Up @@ -44,6 +44,24 @@ EXPORT xbee_err xbee_logLevelSet(struct xbee *xbee, int level) {
EXPORT xbee_err xbee_logLevelGet(struct xbee *xbee, int *level) {
return XBEE_ENOTIMPLEMENTED;
}
EXPORT xbee_err xbee_logRxSet(struct xbee *xbee, int enable) {
return XBEE_ENOTIMPLEMENTED;
}
EXPORT xbee_err xbee_logRxGet(struct xbee *xbee, int *enabled) {
return XBEE_ENOTIMPLEMENTED;
}
EXPORT xbee_err xbee_logTxSet(struct xbee *xbee, int enable) {
return XBEE_ENOTIMPLEMENTED;
}
EXPORT xbee_err xbee_logTxGet(struct xbee *xbee, int *enabled) {
return XBEE_ENOTIMPLEMENTED;
}
EXPORT xbee_err xbee_logColorSet(struct xbee *xbee, int enable) {
return XBEE_ENOTIMPLEMENTED;
}
EXPORT xbee_err xbee_logColorGet(struct xbee *xbee, int *enabled) {
return XBEE_ENOTIMPLEMENTED;
}

/* ######################################################################### */
#else /* XBEE_DISABLE_LOGGING */
Expand Down
6 changes: 0 additions & 6 deletions log.h
Expand Up @@ -23,12 +23,6 @@

#ifdef XBEE_DISABLE_LOGGING

struct xbee_log;

#define xbee_logAlloc(...) XBEE_ENONE
#define xbee_logFree(...)

#define xbee_logTest(...)
#define xbee_log(...)

/* ######################################################################### */
Expand Down
4 changes: 3 additions & 1 deletion rx.c
Expand Up @@ -92,7 +92,8 @@ xbee_err xbee_rx(struct xbee *xbee, int *restart, void *arg) {
usleep(10000); /* 10 ms */
continue;
}


#ifndef XBEE_DISABLE_LOGGING
#ifndef XBEE_LOG_NO_RX
if (xbee->log->enable_rx) {
/* format: tx[0x0000000000000000] */
Expand All @@ -109,6 +110,7 @@ xbee_err xbee_rx(struct xbee *xbee, int *restart, void *arg) {
xbee_logData(25, label, buf->data, buf->len);
}
#endif /* !XBEE_LOG_NO_RX */
#endif /* !XBEE_DISABLE_LOGGING */

if (xbee_ll_add_tail(info->bufList, buf) != XBEE_ENONE) return XBEE_ELINKEDLIST;
buf = NULL;
Expand Down
2 changes: 2 additions & 0 deletions tx.c
Expand Up @@ -82,6 +82,7 @@ xbee_err xbee_tx(struct xbee *xbee, int *restart, void *arg) {
if ((ret = xbee_ll_ext_head(info->bufList, (void**)&buf)) != XBEE_ENONE && ret != XBEE_ERANGE) return XBEE_ELINKEDLIST;
if (!buf) continue;

#ifndef XBEE_DISABLE_LOGGING
#ifndef XBEE_LOG_NO_TX
if (xbee->log->enable_tx) {
/* format: tx[0x0000000000000000] */
Expand All @@ -98,6 +99,7 @@ xbee_err xbee_tx(struct xbee *xbee, int *restart, void *arg) {
xbee_logData(25, label, buf->data, buf->len);
}
#endif /* !XBEE_LOG_NO_TX */
#endif /* !XBEE_DISABLE_LOGGING */

if ((ret = info->ioFunc(xbee, info->ioArg, buf)) != XBEE_ENONE) {
xbee_log(1, "tx() returned %d... buffer was lost", ret);
Expand Down
4 changes: 4 additions & 0 deletions xbee.c
Expand Up @@ -68,7 +68,9 @@ xbee_err xbee_alloc(struct xbee **nXbee) {

memset(xbee, 0, memSize);
if ((ret = xbee_frameBlockAlloc(&xbee->fBlock)) != XBEE_ENONE) goto die1;
#ifndef XBEE_DISABLE_LOGGING
if ((ret = xbee_logAlloc(&xbee->log)) != XBEE_ENONE) goto die1;
#endif /* !XBEE_DISABLE_LOGGING */
if ((ret = xbee_txAlloc(&xbee->iface.tx)) != XBEE_ENONE) goto die1;
if ((ret = xbee_rxAlloc(&xbee->iface.rx)) != XBEE_ENONE) goto die1;

Expand Down Expand Up @@ -111,7 +113,9 @@ xbee_err xbee_free(struct xbee *xbee) {
xbee_modeCleanup(xbee->iface.conTypes);
xbee_rxFree(xbee->iface.rx);
xbee_txFree(xbee->iface.tx);
#ifndef XBEE_DISABLE_LOGGING
xbee_logFree(xbee->log);
#endif /* !XBEE_DISABLE_LOGGING */
xbee_frameBlockFree(xbee->fBlock);

free(xbee);
Expand Down
2 changes: 2 additions & 0 deletions xbee_int.h
Expand Up @@ -34,7 +34,9 @@ struct xbee {
int die;

struct xbee_frameBlock *fBlock;
#ifndef XBEE_DISABLE_LOGGING
struct xbee_log *log;
#endif /* !XBEE_DISABLE_LOGGING */

const struct xbee_mode *mode;
void *modeData; /* for use by the mode */
Expand Down

0 comments on commit 77bdfec

Please sign in to comment.