logger, implementation and test

This commit is contained in:
2020-10-29 14:30:55 +01:00
parent 08c4907526
commit e5a77ccc00
6 changed files with 224 additions and 45 deletions

View File

@ -1,6 +1,19 @@
#ifndef _LOGGER_H_
#define _LOGGER_H_
void log(char *msg);
// initialize the logger, creates a ringbuffer
void logInit();
// de-initialize the logger, free the ringbuffer
void logFree();
// log a message, make sure it is a null-terminated string
// return value can be ignored, it is only used in test
int logMsg(char *msg);
// reads the ringbuffer and transfers data to output channel
// call this from the idle-loop
// return value can be ignored, it is only used in test
int logExecute();
#endif // _LOGGER_H_

View File

@ -14,10 +14,13 @@ typedef struct {
void ringbufferInit(ringbuffer_t *handle, uint32_t bufferSize);
void ringbufferFree(ringbuffer_t *handle);
int ringbufferPut(ringbuffer_t *handle, uint8_t *data, uint32_t dataLen);
uint8_t *ringbufferGet(ringbuffer_t *handle, uint32_t dataLen);
bool ringbufferEmpty(ringbuffer_t *handle);
int ringbufferGetOne(ringbuffer_t *handle); // if positive, cast to uint8_t and be happy, if negative error
// not yet implemented
uint8_t *ringbufferGet(ringbuffer_t *handle, uint32_t dataLen);
#endif // _RINGBUFFER_H_