#ifndef TEST #include #include #endif #include #include #include #ifdef TEST #include #endif #include #include #ifdef TEST #define LOGBUFFER_SIZE 32 #else #define LOGBUFFER_SIZE 1024 #endif // TEST static ringbuffer_t logBuffer; void logInit() { ringbufferInit(&logBuffer, LOGBUFFER_SIZE); } void logFree() { ringbufferFree(&logBuffer); } int logExecute() { int c = -1; #ifndef TEST if (false) { // is the TX channel free #endif // TEST c = ringbufferGetOne(&logBuffer); if (c > 0) { #ifndef TEST // transfer to TX channel #endif // TEST } #ifndef TEST } #endif // TEST return c; } int logMsg(char *msg) { int res = -1; if (-1 == (res = ringbufferPut(&logBuffer, msg, strlen(msg)))) { #ifndef TEST // blink the red light or so #else printf("\n*** red blink ***\n"); #endif // TEST } return res; }