automotive-dlt
dlt_user.c File Reference
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <syslog.h>
#include <semaphore.h>
#include <pthread.h>
#include <sys/time.h>
#include <math.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/uio.h>
#include <limits.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdbool.h>
#include "dlt_user.h"
#include "dlt_common.h"
#include "dlt_user_shared.h"
#include "dlt_user_shared_cfg.h"
#include "dlt_user_cfg.h"
Include dependency graph for dlt_user.c:

Go to the source code of this file.

Data Structures

struct  s_segmented_data
 

Macros

#define DLT_LOG_FATAL_RESET_TRAP(LOGLEVEL)
 
#define DLT_MAX_TRACE_SEGMENT_SIZE   1024
 
#define DLT_MESSAGE_QUEUE_NAME   "/dlt_message_queue"
 
#define DLT_DELAYED_RESEND_INDICATOR_PATTERN   0xFFFF
 

Functions

void dlt_lock_mutex (pthread_mutex_t *mutex)
 
void dlt_unlock_mutex (pthread_mutex_t *mutex)
 
static void dlt_user_receiverthread_function (void *ptr)
 
static void dlt_user_atexit_handler (void)
 
static DltReturnValue dlt_user_log_init (DltContext *handle, DltContextData *log)
 
static DltReturnValue dlt_user_log_send_log (DltContextData *log, int mtype)
 
static DltReturnValue dlt_user_log_send_register_application (void)
 
static DltReturnValue dlt_user_log_send_unregister_application (void)
 
static DltReturnValue dlt_user_log_send_register_context (DltContextData *log)
 
static DltReturnValue dlt_user_log_send_unregister_context (DltContextData *log)
 
static DltReturnValue dlt_send_app_ll_ts_limit (const char *appid, DltLogLevelType loglevel, DltTraceStatusType tracestatus)
 
static DltReturnValue dlt_user_log_send_log_mode (DltUserLogMode mode)
 
static DltReturnValue dlt_user_log_send_marker ()
 
static DltReturnValue dlt_user_print_msg (DltMessage *msg, DltContextData *log)
 
static DltReturnValue dlt_user_log_check_user_message (void)
 
static void dlt_user_log_reattach_to_daemon (void)
 
static DltReturnValue dlt_user_log_send_overflow (void)
 
static void dlt_user_trace_network_segmented_thread (void *unused)
 
static void dlt_user_trace_network_segmented_thread_segmenter (s_segmented_data *data)
 
static DltReturnValue dlt_user_queue_resend (void)
 
static int dlt_start_threads ()
 
static void dlt_stop_threads ()
 
static void dlt_fork_pre_fork_handler ()
 
static void dlt_fork_parent_fork_handler ()
 
static void dlt_fork_child_fork_handler ()
 
DltReturnValue dlt_user_check_library_version (const char *user_major_version, const char *user_minor_version)
 
DltReturnValue dlt_init (void)
 
DltReturnValue dlt_init_file (const char *name)
 
DltReturnValue dlt_init_message_queue (void)
 
DltReturnValue dlt_init_common (void)
 
int dlt_user_atexit_blow_out_user_buffer (void)
 
DltReturnValue dlt_free (void)
 
DltReturnValue dlt_check_library_version (const char *user_major_version, const char *user_minor_version)
 
DltReturnValue dlt_register_app (const char *appid, const char *description)
 
DltReturnValue dlt_register_context (DltContext *handle, const char *contextid, const char *description)
 
DltReturnValue dlt_register_context_ll_ts (DltContext *handle, const char *contextid, const char *description, int loglevel, int tracestatus)
 
DltReturnValue dlt_unregister_app (void)
 
DltReturnValue dlt_unregister_context (DltContext *handle)
 
DltReturnValue dlt_set_application_ll_ts_limit (DltLogLevelType loglevel, DltTraceStatusType tracestatus)
 
int dlt_get_log_state ()
 
DltReturnValue dlt_set_log_mode (DltUserLogMode mode)
 
int dlt_set_resend_timeout_atexit (uint32_t timeout_in_milliseconds)
 
DltReturnValue dlt_forward_msg (void *msgdata, size_t size)
 
DltReturnValue dlt_user_log_write_start (DltContext *handle, DltContextData *log, DltLogLevelType loglevel)
 
DltReturnValue dlt_user_log_write_start_id (DltContext *handle, DltContextData *log, DltLogLevelType loglevel, uint32_t messageid)
 
DltReturnValue dlt_user_log_write_finish (DltContextData *log)
 
DltReturnValue dlt_user_log_write_raw (DltContextData *log, void *data, uint16_t length)
 
DltReturnValue dlt_user_log_write_raw_formatted (DltContextData *log, void *data, uint16_t length, DltFormatType type)
 
DltReturnValue dlt_user_log_write_float32 (DltContextData *log, float32_t data)
 
DltReturnValue dlt_user_log_write_float64 (DltContextData *log, float64_t data)
 
DltReturnValue dlt_user_log_write_uint (DltContextData *log, unsigned int data)
 
DltReturnValue dlt_user_log_write_uint8 (DltContextData *log, uint8_t data)
 
DltReturnValue dlt_user_log_write_uint16 (DltContextData *log, uint16_t data)
 
DltReturnValue dlt_user_log_write_uint32 (DltContextData *log, uint32_t data)
 
DltReturnValue dlt_user_log_write_uint64 (DltContextData *log, uint64_t data)
 
DltReturnValue dlt_user_log_write_uint8_formatted (DltContextData *log, uint8_t data, DltFormatType type)
 
DltReturnValue dlt_user_log_write_uint16_formatted (DltContextData *log, uint16_t data, DltFormatType type)
 
DltReturnValue dlt_user_log_write_uint32_formatted (DltContextData *log, uint32_t data, DltFormatType type)
 
DltReturnValue dlt_user_log_write_uint64_formatted (DltContextData *log, uint64_t data, DltFormatType type)
 
DltReturnValue dlt_user_log_write_ptr (DltContextData *log, void *data)
 
DltReturnValue dlt_user_log_write_int (DltContextData *log, int data)
 
DltReturnValue dlt_user_log_write_int8 (DltContextData *log, int8_t data)
 
DltReturnValue dlt_user_log_write_int16 (DltContextData *log, int16_t data)
 
DltReturnValue dlt_user_log_write_int32 (DltContextData *log, int32_t data)
 
DltReturnValue dlt_user_log_write_int64 (DltContextData *log, int64_t data)
 
DltReturnValue dlt_user_log_write_bool (DltContextData *log, uint8_t data)
 
DltReturnValue dlt_user_log_write_string (DltContextData *log, const char *text)
 
DltReturnValue dlt_user_log_write_constant_string (DltContextData *log, const char *text)
 
DltReturnValue dlt_user_log_write_utf8_string (DltContextData *log, const char *text)
 
DltReturnValue dlt_register_injection_callback (DltContext *handle, uint32_t service_id, int(*dlt_injection_callback)(uint32_t service_id, void *data, uint32_t length))
 
DltReturnValue dlt_register_log_level_changed_callback (DltContext *handle, void(*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE], uint8_t log_level, uint8_t trace_status))
 
int check_buffer (void)
 
DltReturnValue dlt_user_trace_network_segmented_start (uint32_t *id, DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len)
 
DltReturnValue dlt_user_trace_network_segmented_segment (uint32_t id, DltContext *handle, DltNetworkTraceType nw_trace_type, int sequence, uint16_t payload_len, void *payload)
 
DltReturnValue dlt_user_trace_network_segmented_end (uint32_t id, DltContext *handle, DltNetworkTraceType nw_trace_type)
 
DltReturnValue dlt_user_trace_network_segmented (DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload)
 
DltReturnValue dlt_user_trace_network (DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload)
 
DltReturnValue dlt_user_trace_network_truncated (DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload, int allow_truncate)
 
DltReturnValue dlt_log_string (DltContext *handle, DltLogLevelType loglevel, const char *text)
 
DltReturnValue dlt_log_string_int (DltContext *handle, DltLogLevelType loglevel, const char *text, int data)
 
DltReturnValue dlt_log_string_uint (DltContext *handle, DltLogLevelType loglevel, const char *text, unsigned int data)
 
DltReturnValue dlt_log_int (DltContext *handle, DltLogLevelType loglevel, int data)
 
DltReturnValue dlt_log_uint (DltContext *handle, DltLogLevelType loglevel, unsigned int data)
 
DltReturnValue dlt_log_raw (DltContext *handle, DltLogLevelType loglevel, void *data, uint16_t length)
 
DltReturnValue dlt_log_marker ()
 
DltReturnValue dlt_verbose_mode (void)
 
DltReturnValue dlt_nonverbose_mode (void)
 
DltReturnValue dlt_use_extended_header_for_non_verbose (int8_t use_extende_header_for_non_verbose)
 
DltReturnValue dlt_with_session_id (int8_t with_session_id)
 
DltReturnValue dlt_with_timestamp (int8_t with_timestamp)
 
DltReturnValue dlt_with_ecu_id (int8_t with_ecu_id)
 
DltReturnValue dlt_enable_local_print (void)
 
DltReturnValue dlt_disable_local_print (void)
 
void dlt_user_receiverthread_function (__attribute__((unused)) void *ptr)
 
DltReturnValue dlt_user_log_resend_buffer (void)
 
DltReturnValue dlt_user_check_buffer (int *total_size, int *used_size)
 

Variables

static DltUser dlt_user
 
static bool dlt_user_initialised = false
 
static int dlt_user_freeing = 0
 
static char dlt_user_dir [NAME_MAX+1]
 
static char dlt_daemon_fifo [NAME_MAX+1]
 
static char str [DLT_USER_BUFFER_LENGTH]
 
static sem_t dlt_mutex
 
static pthread_t dlt_receiverthread_handle
 
static int atexit_registered = 0
 
static int atfork_registered = 0
 
pthread_mutex_t mq_mutex
 
pthread_cond_t mq_init_condition
 

Detailed Description

Author
Alexander Wenzel alexa.nosp@m.nder.nosp@m..aw.w.nosp@m.enze.nosp@m.l@bmw.nosp@m..de Markus Klein Marku.nosp@m.s.Kl.nosp@m.ein@e.nosp@m.sk.f.nosp@m.raunh.nosp@m.ofer.nosp@m..de Mikko Rapeli mikko.nosp@m..rap.nosp@m.eli@b.nosp@m.mw.d.nosp@m.e

Definition in file dlt_user.c.

Macro Definition Documentation

#define DLT_DELAYED_RESEND_INDICATOR_PATTERN   0xFFFF

Definition at line 100 of file dlt_user.c.

Referenced by dlt_user_queue_resend(), and dlt_user_trace_network_segmented_thread().

#define DLT_LOG_FATAL_RESET_TRAP (   LOGLEVEL)

Definition at line 75 of file dlt_user.c.

Referenced by dlt_user_log_write_start_id().

#define DLT_MAX_TRACE_SEGMENT_SIZE   1024
#define DLT_MESSAGE_QUEUE_NAME   "/dlt_message_queue"

Definition at line 99 of file dlt_user.c.

Referenced by dlt_free(), and dlt_init_message_queue().

Function Documentation

int check_buffer ( void  )

NW Trace related

Definition at line 2501 of file dlt_user.c.

References dlt_user_check_buffer().

Referenced by dlt_user_trace_network_segmented_segment().

static void dlt_fork_child_fork_handler ( )
static

Definition at line 4646 of file dlt_user.c.

References dlt_free(), dlt_log_free(), and dlt_user_initialised.

Referenced by dlt_init().

static void dlt_fork_parent_fork_handler ( )
static
static void dlt_fork_pre_fork_handler ( )
static

Definition at line 4624 of file dlt_user.c.

References dlt_stop_threads().

Referenced by dlt_init().

DltReturnValue dlt_init_message_queue ( void  )
void dlt_lock_mutex ( pthread_mutex_t *  mutex)
void dlt_stop_threads ( )
static
void dlt_unlock_mutex ( pthread_mutex_t *  mutex)

Definition at line 121 of file dlt_user.c.

Referenced by dlt_init_message_queue(), and dlt_user_trace_network_segmented_thread().

void dlt_user_atexit_handler ( void  )
static
DltReturnValue dlt_user_log_send_log ( DltContextData log,
int  mtype 
)
static

Definition at line 3407 of file dlt_user.c.

References DltUser::appID, DltContextData::args_num, DltContextData::buffer, DltContext::contextID, dlt_buffer_push3(), DLT_HTOBE_16, DLT_HTYP_MSBF, DLT_HTYP_PROTOCOL_VERSION1, DLT_HTYP_UEH, DLT_HTYP_WEID, DLT_HTYP_WSID, DLT_HTYP_WTMS, DltUser::dlt_is_file, DLT_IS_HTYP_UEH, dlt_log(), DltUser::dlt_log_handle, dlt_message_init(), dlt_message_set_extraparameters(), DLT_MSIN_MSTP_SHIFT, DLT_MSIN_MTIN, DLT_MSIN_MTIN_SHIFT, DLT_MSIN_VERB, DLT_PM_AUTOMATIC, DLT_PM_FORCE_OFF, DLT_PM_FORCE_ON, DLT_RETURN_BUFFER_FULL, DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_RETURN_PIPE_ERROR, DLT_RETURN_PIPE_FULL, DLT_RETURN_WRONG_PARAMETER, DLT_SEM_FREE, DLT_SEM_LOCK, dlt_set_id(), dlt_set_storageheader(), dlt_shm_free_client(), dlt_shm_push(), DLT_STANDARD_HEADER_EXTRA_SIZE, DLT_TYPE_CONTROL, DLT_TYPE_LOG, DLT_TYPE_NW_TRACE, dlt_uptime(), DLT_USER_BUFFER_LENGTH, dlt_user_initialised, dlt_user_log_out2(), dlt_user_log_out3(), dlt_user_log_reattach_to_daemon(), dlt_user_log_resend_buffer(), dlt_user_log_send_overflow(), DLT_USER_MESSAGE_LOG, DLT_USER_MESSAGE_LOG_SHM, dlt_user_print_msg(), dlt_user_queue_resend(), dlt_user_set_userheader(), dlt_vlog(), dlt_vnlog(), DltUser::ecuID, DltUser::enable_local_print, sDltMessage::extendedheader, DltContextData::handle, sDltMessage::headerbuffer, sDltMessage::headerextra, sDltMessage::headersize, DltUser::local_print_mode, DltContextData::log_level, DltContext::mcnt, NULL, DltUser::overflow_counter, DltContextData::size, sDltMessage::standardheader, DltUser::startup_buffer, sDltMessage::storageheader, DltContextData::trace_status, DltUser::use_extende_header_for_non_verbose, DltUser::verbose_mode, DltUser::with_ecu_id, DltUser::with_session_id, and DltUser::with_timestamp.

Referenced by dlt_user_log_write_finish(), dlt_user_trace_network_segmented_end(), dlt_user_trace_network_segmented_segment(), dlt_user_trace_network_segmented_start(), and dlt_user_trace_network_truncated().

static void dlt_user_receiverthread_function ( void *  ptr)
static

Referenced by dlt_start_threads().

void dlt_user_receiverthread_function ( __attribute__((unused)) void *  ptr)

Variable Documentation

int atexit_registered = 0
static

Definition at line 91 of file dlt_user.c.

Referenced by dlt_init_common().

int atfork_registered = 0
static

Definition at line 94 of file dlt_user.c.

Referenced by dlt_init().

char dlt_daemon_fifo[NAME_MAX+1]
static

Definition at line 83 of file dlt_user.c.

Referenced by dlt_init(), and dlt_user_log_reattach_to_daemon().

sem_t dlt_mutex
static

Definition at line 87 of file dlt_user.c.

Referenced by dlt_free(), and dlt_init_common().

pthread_t dlt_receiverthread_handle
static

Definition at line 88 of file dlt_user.c.

Referenced by dlt_start_threads(), and dlt_stop_threads().

DltUser dlt_user
static

Definition at line 78 of file dlt_user.c.

char dlt_user_dir[NAME_MAX+1]
static

Definition at line 82 of file dlt_user.c.

Referenced by dlt_free(), and dlt_init().

int dlt_user_freeing = 0
static

Definition at line 80 of file dlt_user.c.

Referenced by dlt_free(), and dlt_init().

pthread_cond_t mq_init_condition
pthread_mutex_t mq_mutex