automotive-dlt
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <syslog.h>
#include <dlt_offline_trace.h>
#include "dlt_common.h"
Go to the source code of this file.
Functions | |
unsigned int | dlt_offline_trace_storage_dir_info (char *path, char *file_name, char *newest, char *oldest) |
void | dlt_offline_trace_file_name (char *log_file_name, char *name, unsigned int idx) |
unsigned int | dlt_offline_trace_get_idx_of_log_file (char *file) |
DltReturnValue | dlt_offline_trace_create_new_file (DltOfflineTrace *trace) |
unsigned long | dlt_offline_trace_get_total_size (DltOfflineTrace *trace) |
int | dlt_offline_trace_delete_oldest_file (DltOfflineTrace *trace) |
DltReturnValue | dlt_offline_trace_check_size (DltOfflineTrace *trace) |
DltReturnValue | dlt_offline_trace_init (DltOfflineTrace *trace, const char *directory, int fileSize, int maxSize, int filenameTimestampBased) |
DltReturnValue | dlt_offline_trace_write (DltOfflineTrace *trace, unsigned char *data1, int size1, unsigned char *data2, int size2, unsigned char *data3, int size3) |
DltReturnValue | dlt_offline_trace_free (DltOfflineTrace *trace) |
Definition in file dlt_offline_trace.c.
DltReturnValue dlt_offline_trace_check_size | ( | DltOfflineTrace * | trace | ) |
Definition at line 354 of file dlt_offline_trace.c.
References DltOfflineTrace::directory, dlt_offline_trace_delete_oldest_file(), dlt_offline_trace_get_total_size(), DLT_RETURN_ERROR, DLT_RETURN_OK, dlt_vlog(), DltOfflineTrace::fileSize, and DltOfflineTrace::maxSize.
Referenced by dlt_offline_trace_init(), and dlt_offline_trace_write().
DltReturnValue dlt_offline_trace_create_new_file | ( | DltOfflineTrace * | trace | ) |
Definition at line 208 of file dlt_offline_trace.c.
References DltOfflineTrace::directory, dlt_offline_trace_file_name(), dlt_offline_trace_get_idx_of_log_file(), dlt_offline_trace_storage_dir_info(), DLT_OFFLINETRACE_FILENAME_BASE, DLT_OFFLINETRACE_FILENAME_MAX_SIZE, DLT_RETURN_ERROR, DLT_RETURN_OK, DltOfflineTrace::filename, DltOfflineTrace::filenameTimestampBased, NULL, and DltOfflineTrace::ohandle.
Referenced by dlt_offline_trace_init(), and dlt_offline_trace_write().
int dlt_offline_trace_delete_oldest_file | ( | DltOfflineTrace * | trace | ) |
Definition at line 301 of file dlt_offline_trace.c.
References DltOfflineTrace::directory, DLT_OFFLINETRACE_FILENAME_TO_COMPARE, and NULL.
Referenced by dlt_offline_trace_check_size().
void dlt_offline_trace_file_name | ( | char * | log_file_name, |
char * | name, | ||
unsigned int | idx | ||
) |
creates filename with index
log | file name created with index |
filename | base |
index | to be used for file name creation |
Definition at line 168 of file dlt_offline_trace.c.
References DLT_OFFLINETRACE_FILENAME_BASE, DLT_OFFLINETRACE_FILENAME_DELI, DLT_OFFLINETRACE_FILENAME_EXT, and DLT_OFFLINETRACE_FILENAME_MAX_SIZE.
Referenced by dlt_offline_trace_create_new_file().
DltReturnValue dlt_offline_trace_free | ( | DltOfflineTrace * | buf | ) |
Uninitialise the offline trace This function call closes currently used log file. This function must be called after usage of offline trace
trace | pointer to offline trace structure |
Definition at line 440 of file dlt_offline_trace.c.
References DLT_RETURN_ERROR, DLT_RETURN_OK, and DltOfflineTrace::ohandle.
Referenced by dlt_daemon_local_cleanup().
unsigned int dlt_offline_trace_get_idx_of_log_file | ( | char * | file | ) |
generates index for log file name
filename | supplied to create index |
Definition at line 181 of file dlt_offline_trace.c.
References NULL.
Referenced by dlt_offline_trace_create_new_file().
unsigned long dlt_offline_trace_get_total_size | ( | DltOfflineTrace * | trace | ) |
Get size of currently used offline trace buffer
Definition at line 264 of file dlt_offline_trace.c.
References DltOfflineTrace::directory, DLT_OFFLINETRACE_FILENAME_BASE, and NULL.
Referenced by dlt_offline_trace_check_size().
DltReturnValue dlt_offline_trace_init | ( | DltOfflineTrace * | trace, |
const char * | directory, | ||
int | fileSize, | ||
int | maxSize, | ||
int | filenameTimestampBased | ||
) |
Initialise the offline trace This function call opens the currently used log file. A check of the complete size of the offline trace is done during startup. Old files are deleted, if there is not enough space left to create new file. This function must be called before using further offline trace functions.
trace | pointer to offline trace structure |
directory | directory where to store offline trace files |
fileSize | maximum size of one offline trace file. |
maxSize | maximum size of complete offline trace in bytes. . |
filenameTimestampBased | filename to be created on timestamp based or index based |
Definition at line 384 of file dlt_offline_trace.c.
References DltOfflineTrace::directory, dlt_offline_trace_check_size(), dlt_offline_trace_create_new_file(), DltOfflineTrace::filenameTimestampBased, DltOfflineTrace::fileSize, and DltOfflineTrace::maxSize.
Referenced by dlt_daemon_local_init_p2().
unsigned int dlt_offline_trace_storage_dir_info | ( | char * | path, |
char * | file_name, | ||
char * | newest, | ||
char * | oldest | ||
) |
Provides info about the offline logs storage directory
path | of the storage directory |
filename | to search for |
pointer | to store newest filename |
pointer | to store oldest filename |
Definition at line 70 of file dlt_offline_trace.c.
References DLT_OFFLINETRACE_FILENAME_MAX_SIZE, and NULL.
Referenced by dlt_offline_trace_create_new_file().
DltReturnValue dlt_offline_trace_write | ( | DltOfflineTrace * | trace, |
unsigned char * | data1, | ||
int | size1, | ||
unsigned char * | data2, | ||
int | size2, | ||
unsigned char * | data3, | ||
int | size3 | ||
) |
Write data into offline trace If the current used log file exceeds the max file size, new log file is created. A check of the complete size of the offline trace is done before new file is created. Old files are deleted, if there is not enough space left to create new file.
trace | pointer to offline trace structure |
data1 | pointer to first data block to be written, null if not used |
size1 | size in bytes of first data block to be written, 0 if not used |
data2 | pointer to second data block to be written, null if not used |
size2 | size in bytes of second data block to be written, 0 if not used |
data3 | pointer to third data block to be written, null if not used |
size3 | size in bytes of third data block to be written, 0 if not used |
Definition at line 398 of file dlt_offline_trace.c.
References dlt_offline_trace_check_size(), dlt_offline_trace_create_new_file(), DLT_RETURN_ERROR, DLT_RETURN_OK, DltOfflineTrace::fileSize, and DltOfflineTrace::ohandle.
Referenced by dlt_daemon_client_send(), and dlt_daemon_process_user_message_log().