#include <sys/prctl.h>
#endif
+#include <sys/types.h> /* needed for getpid() */
+#include <unistd.h>
+
+
#include "dlt_user.h"
#include "dlt_user_shared.h"
#include "dlt_user_shared_cfg.h"
memset(&(dlt_user.dlt_shm),0,sizeof(DltShm));
#endif
+ /* create dlt pipes directory */
+ ret=mkdir(DLT_USER_DIR, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_ISVTX );
+ if (ret==-1 && errno != EEXIST)
+ {
+ snprintf(str,DLT_USER_BUFFER_LENGTH,"FIFO user dir %s cannot be created!\n", DLT_USER_DIR);
+ dlt_log(LOG_ERR, str);
+ return -1;
+ }
+
+ /* if dlt pipes directory is created by the application also chmod the directory */
+ if(ret == 0)
+ {
+ // S_ISGID cannot be set by mkdir, let's reassign right bits
+ ret=chmod(DLT_USER_DIR, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH | S_ISGID | S_ISVTX );
+ if (ret==-1)
+ {
+ snprintf(str,DLT_USER_BUFFER_LENGTH,"FIFO user dir %s cannot be chmoded!\n", DLT_USER_DIR);
+ dlt_log(LOG_ERR, str);
+ return -1;
+ }
+ }
+
/* create and open DLT user FIFO */
snprintf(filename,DLT_USER_MAX_FILENAME_LENGTH,"%s/dlt%d",DLT_USER_DIR,getpid());
/* Verbose mode is enabled by default */
dlt_user.verbose_mode = 1;
+ /* Use extended header for non verbose is enabled by default */
+ dlt_user.use_extende_header_for_non_verbose = DLT_USER_USE_EXTENDED_HEADER_FOR_NONVERBOSE;
+
+ /* WIth session id is enabled by default */
+ dlt_user.with_session_id = DLT_USER_WITH_SESSION_ID;
+
+ /* With timestamp is enabled by default */
+ dlt_user.with_timestamp= DLT_USER_WITH_TIMESTAMP;
+
+ /* With timestamp is enabled by default */
+ dlt_user.with_ecu_id= DLT_USER_WITH_ECU_ID;
+
/* Local print is disabled by default */
dlt_user.enable_local_print = 0;
return 0;
}
+int dlt_user_log_write_constant_string(DltContextData *log, const char *text)
+{
+ /* Send parameter only in verbose mode */
+ if (dlt_user.verbose_mode)
+ {
+ return dlt_user_log_write_string(log,text);
+ }
+
+ return 0;
+}
+
int dlt_user_log_write_utf8_string(DltContextData *log, const char *text)
{
uint16_t arg_size;
return 0;
}
+int dlt_use_extended_header_for_non_verbose(int8_t use_extende_header_for_non_verbose)
+{
+ if (dlt_user_initialised==0)
+ {
+ if (dlt_init()<0)
+ {
+ return -1;
+ }
+ }
+
+ /* Set use_extende_header_for_non_verbose */
+ dlt_user.use_extende_header_for_non_verbose = use_extende_header_for_non_verbose;
+
+ return 0;
+}
+
+int dlt_with_session_id(int8_t with_session_id)
+{
+ if (dlt_user_initialised==0)
+ {
+ if (dlt_init()<0)
+ {
+ return -1;
+ }
+ }
+
+ /* Set use_extende_header_for_non_verbose */
+ dlt_user.with_session_id = with_session_id;
+
+ return 0;
+}
+
+int dlt_with_timestamp(int8_t with_timestamp)
+{
+ if (dlt_user_initialised==0)
+ {
+ if (dlt_init()<0)
+ {
+ return -1;
+ }
+ }
+
+ /* Set with_timestamp */
+ dlt_user.with_timestamp = with_timestamp;
+
+ return 0;
+}
+
+int dlt_with_ecu_id(int8_t with_ecu_id)
+{
+ if (dlt_user_initialised==0)
+ {
+ if (dlt_init()<0)
+ {
+ return -1;
+ }
+ }
+
+ /* Set with_timestamp */
+ dlt_user.with_ecu_id = with_ecu_id;
+
+ return 0;
+}
+
int dlt_enable_local_print(void)
{
if (dlt_user_initialised==0)
}
msg.standardheader = (DltStandardHeader*)(msg.headerbuffer + sizeof(DltStorageHeader));
- msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_PROTOCOL_VERSION1 ;
+ msg.standardheader->htyp = DLT_HTYP_PROTOCOL_VERSION1 ;
+
+ /* send ecu id */
+ if(dlt_user.with_ecu_id)
+ {
+ msg.standardheader->htyp |= DLT_HTYP_WEID;
+ }
+
+ /* send timestamp */
+ if(dlt_user.with_timestamp)
+ {
+ msg.standardheader->htyp |= DLT_HTYP_WTMS;
+ }
+
+ /* send session id */
+ if(dlt_user.with_session_id)
+ {
+ msg.standardheader->htyp |= DLT_HTYP_WSID;
+ msg.headerextra.seid = getpid();
+ }
if (dlt_user.verbose_mode)
{
else
{
/* In non-verbose, send extended header if desired */
-#if (DLT_USER_USE_EXTENDED_HEADER_FOR_NONVERBOSE==1)
- msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_UEH );
-#endif
+ if(dlt_user.use_extende_header_for_non_verbose)
+ msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_UEH );
}
#if (BYTE_ORDER==BIG_ENDIAN)