Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
sdLog.h File Reference
#include "std.h"
#include "mcuconf.h"
#include <stdarg.h>
+ Include dependency graph for sdLog.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NUMBERLEN   4
 
#define NUMBERMAX   9999
 
#define NUMBERFMF   "%s\\%s%.04d.LOG"
 
#define LOG_PREALLOCATION_ENABLED   true
 
#define LOG_PREALLOCATION_DISABLED   false
 
#define LOG_APPEND_TAG_AT_CLOSE_ENABLED   true
 
#define LOG_APPEND_TAG_AT_CLOSE_DISABLED   false
 

Typedefs

typedef struct _SdLogBuffer SdLogBuffer
 
typedef int8_t FileDes
 

Enumerations

enum  SdioError {
  SDLOG_OK, SDLOG_NOCARD, SDLOG_FATFS_ERROR, SDLOG_FATFS_NOENT,
  SDLOG_FSFULL, SDLOG_FDFULL, SDLOG_QUEUEFULL, SDLOG_MEMFULL,
  SDLOG_NOTHREAD, SDLOG_INTERNAL_ERROR, SDLOG_CANNOT_EXPAND, SDLOG_LOGNUM_ERROR,
  SDLOG_WAS_LAUNCHED
}
 

Functions

SdioError sdLogInit (uint32_t *freeSpaceInKo)
 initialise sdLog More...
 
SdioError getFileName (const char *prefix, const char *directoryName, char *nextFileName, const size_t nameLength, const int indexOffset)
 get last used name for a pattern, then add offset and return valid filename More...
 
SdioError removeEmptyLogs (const char *directoryName, const char *prefix, const size_t sizeConsideredEmpty)
 remove spurious log file left on sd More...
 
SdioError sdLogFinish (void)
 unmount filesystem More...
 

Macro Definition Documentation

◆ LOG_APPEND_TAG_AT_CLOSE_DISABLED

#define LOG_APPEND_TAG_AT_CLOSE_DISABLED   false

Definition at line 105 of file sdLog.h.

◆ LOG_APPEND_TAG_AT_CLOSE_ENABLED

#define LOG_APPEND_TAG_AT_CLOSE_ENABLED   true

Definition at line 104 of file sdLog.h.

◆ LOG_PREALLOCATION_DISABLED

#define LOG_PREALLOCATION_DISABLED   false

Definition at line 103 of file sdLog.h.

◆ LOG_PREALLOCATION_ENABLED

#define LOG_PREALLOCATION_ENABLED   true

Definition at line 102 of file sdLog.h.

◆ NUMBERFMF

#define NUMBERFMF   "%s\\%s%.04d.LOG"

Definition at line 36 of file sdLog.h.

◆ NUMBERLEN

#define NUMBERLEN   4

Definition at line 34 of file sdLog.h.

◆ NUMBERMAX

#define NUMBERMAX   9999

Definition at line 35 of file sdLog.h.

Typedef Documentation

◆ FileDes

typedef int8_t FileDes

Definition at line 128 of file sdLog.h.

◆ SdLogBuffer

typedef struct _SdLogBuffer SdLogBuffer

Definition at line 127 of file sdLog.h.

Enumeration Type Documentation

◆ SdioError

enum SdioError
Enumerator
SDLOG_OK 
SDLOG_NOCARD 
SDLOG_FATFS_ERROR 
SDLOG_FATFS_NOENT 
SDLOG_FSFULL 
SDLOG_FDFULL 
SDLOG_QUEUEFULL 
SDLOG_MEMFULL 
SDLOG_NOTHREAD 
SDLOG_INTERNAL_ERROR 
SDLOG_CANNOT_EXPAND 
SDLOG_LOGNUM_ERROR 
SDLOG_WAS_LAUNCHED 

Definition at line 111 of file sdLog.h.

Function Documentation

◆ getFileName()

SdioError getFileName ( const char *  prefix,
const char *  directoryName,
char *  nextFileName,
const size_t  nameLength,
const int  indexOffset 
)

get last used name for a pattern, then add offset and return valid filename

for log file, you often have a pattern and a version. To retreive last file for reading, call function with indexOffset=0. To get next available file for writing, call function with indexOffset=1 This function is available even without thread login facility : even if SDLOG_XXX macro are zeroed

Parameters
[in]prefix: the pattern for the file : example LOG_
[in]directoryName: root directory where to find file
[out]nextFileName: file with path ready to be used for f_open system call
[in]nameLength: length of previous buffer
[in]indexOffset: use 0 to retrieve last existent filename, 1 for next filename
Returns
status (always check status)

Definition at line 730 of file sdLog.c.

References chsnprintf(), dir, MAX, MIN, NUMBERFMF, NUMBERMAX, SDLOG_FATFS_ERROR, SDLOG_LOGNUM_ERROR, SDLOG_OK, and uiGetIndexOfLogFile().

+ Here is the call graph for this function:

◆ removeEmptyLogs()

SdioError removeEmptyLogs ( const char *  directoryName,
const char *  prefix,
const size_t  sizeConsideredEmpty 
)

remove spurious log file left on sd

when tuning firmware, log files are created at each tries, and we consider that empty or nearly empty log are of no value this function remove log file whose size is less than a given value

Parameters
[in]prefix: the pattern for the file : example LOG_
[in]directoryName: root directory where to find file
[in]sizeConsideredEmpty: file whose size is less or equal to that value will be removed
Returns
status (always check status)

Definition at line 791 of file sdLog.c.

References dir, SDLOG_FATFS_ERROR, SDLOG_FATFS_NOENT, and SDLOG_OK.

Referenced by thd_startlog().

+ Here is the caller graph for this function:

◆ sdLogFinish()

SdioError sdLogFinish ( void  )

unmount filesystem

unmount filesystem, free sdio peripheral This function is available even without thread login facility : even if SDLOG_XXX macro are zeroed

Returns
status (always check status)

Definition at line 262 of file sdLog.c.

References SDLOG_FATFS_ERROR, and SDLOG_OK.

Referenced by sdlog_chibios_finish().

+ Here is the caller graph for this function:

◆ sdLogInit()

SdioError sdLogInit ( uint32_t freeSpaceInKo)

initialise sdLog

init sdio peripheral, verify sdCard is inserted, check and mount filesystem, launch worker thread This function is available even without thread login facility : even if SDLOG_XXX macro are zeroed

Parameters
[out]freeSpaceInKo: if pointer in nonnull, return free space on filesystem
Returns
status (always check status)

Definition at line 202 of file sdLog.c.

References FALSE, HEAP_DEFAULT, msgqueue_init(), sdio_connect(), sdio_disconnect(), SDLOG_FATFS_ERROR, SDLOG_NOCARD, SDLOG_NUM_FILES, SDLOG_OK, SDLOG_QUEUE_BUCKETS, and SDLOG_WAS_LAUNCHED.

Referenced by thd_startlog().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: