Aktionen
Logging¶
There is no clean logging concept at the moment.
- Low footprint
 - Work within ISRs. The output is delayed. The order is preserved.
 - Only short messages, e.g. 20 chars.
 - Heart-beat LED might be involved
 - CAN might be involved to transmit diagnose
 - Debug can be disabled even for Debug-builds; BIWAK_LOG_DEBUG has to be defined to show bDebug
 
Heartbeat-Class¶
An LED can indicate problems.
- good (double heartbeat)
 - warning; temporary error/ trouble (fast blink - off 1Hz) (goes away)
 - critical error/ exception (fast blink)
 - fatal error (slow blink)
 
Usecases¶
- invalid eeprom causes "critical"-state
 - Not being able to sen CAN messages causes "trouble"
 - fatal: the application can not run for some reason but the led should work; e.g. a reception buffer is full
 - exception: Don't even try to run any more. e.g. memory error.
 
Notes¶
There is already a doublebuffer-class for CAN.
Examples¶
add_definitions( BIWAK_LOG_HEARTBEAT )
add_definitions( BIWAK_LOG_CAN )
add_definitions( BIWAK_LOG_DEBUG )
#define bDebug(a,...) debug(a, __VA_ARGS__)
#include <biwak/log.hpp>
main()
{
   bDebug();      // Just print some text
   bCritical();
   bTrouble();    // 
   bFatal();
   bException("Static text");
}
static struct {
    char buf[20];
    bool used;
}buffers[2]={0};
void bWarning(const char *text, ...)
{
    va_list list;
    va_start(list, text);
    int bufid;
    for(bufid=0; bufid < ARRAY_ELEMENTS(buffers); bufid++)
    {
        if(!buffers[bufid].used)
        {
            break;
        }
    }
    if(bufid >= ARRAY_ELEMENTS(buffers))
    {
        bException("Out of log buffers!");
    }
    buffers[bufid].used=true;
    vsnprintf(buffers[bufid].buf, 20, text, list);
    puts(buffers[bufid].buf);
    printf("Bufid: %d; elements: %d\n", bufid, ARRAY_ELEMENTS(buffers));
};
Von Maximilian Seesslen vor fast 3 Jahren aktualisiert · 6 Revisionen