summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/daemon/CMakeLists.txt2
-rwxr-xr-xsrc/daemon/dlt-daemon.c52
-rwxr-xr-xsrc/daemon/dlt-daemon.h15
3 files changed, 56 insertions, 13 deletions
diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt
index 5c3c25e..c309a91 100755
--- a/src/daemon/CMakeLists.txt
+++ b/src/daemon/CMakeLists.txt
@@ -35,7 +35,7 @@
# @licence end@
########
-set(dlt_daemon_SRCS dlt-daemon dlt_daemon_common ${CMAKE_SOURCE_DIR}/src/shared/dlt_user_shared.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_common.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_shm.c)
+set(dlt_daemon_SRCS dlt-daemon dlt_daemon_common ${CMAKE_SOURCE_DIR}/src/shared/dlt_user_shared.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_common.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_shm.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_offline_trace.c)
add_executable(dlt-daemon ${dlt_daemon_SRCS})
IF(GPROF_DLT_DAEMON)
SET(CMAKE_C_FLAGS "-pg")
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index 3a71138..7dcf025 100755
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -227,6 +227,9 @@ int option_file_parser(DltDaemonLocal *daemon_local)
/* set default values for configuration */
daemon_local->flags.sharedMemorySize = DLT_SHM_SIZE;
daemon_local->flags.sendMessageTime = 0;
+ daemon_local->flags.offlineTraceDirectory[0] = 0;
+ daemon_local->flags.offlineTraceFileSize = 1000000;
+ daemon_local->flags.offlineTraceMaxSize = 0;
/* open configuration file */
if(daemon_local->flags.cvalue[0])
@@ -334,11 +337,6 @@ int option_file_parser(DltDaemonLocal *daemon_local)
strncpy(daemon_local->flags.evalue,value,sizeof(daemon_local->flags.evalue));
printf("Option: %s=%s\n",token,value);
}
- else if(strcmp(token,"LocalLogFilename")==0)
- {
- strncpy(daemon_local->flags.ovalue,value,sizeof(daemon_local->flags.ovalue));
- printf("Option: %s=%s\n",token,value);
- }
else if(strcmp(token,"PersistanceStoragePath")==0)
{
strncpy(daemon_local->flags.ivalue,value,sizeof(daemon_local->flags.ivalue));
@@ -349,6 +347,21 @@ int option_file_parser(DltDaemonLocal *daemon_local)
daemon_local->flags.sharedMemorySize = atoi(value);
printf("Option: %s=%s\n",token,value);
}
+ else if(strcmp(token,"OfflineTraceDirectory")==0)
+ {
+ strncpy(daemon_local->flags.offlineTraceDirectory,value,sizeof(daemon_local->flags.offlineTraceDirectory));
+ printf("Option: %s=%s\n",token,value);
+ }
+ else if(strcmp(token,"OfflineTraceFileSize")==0)
+ {
+ daemon_local->flags.offlineTraceFileSize = atoi(value);
+ printf("Option: %s=%s\n",token,value);
+ }
+ else if(strcmp(token,"OfflineTraceMaxSize")==0)
+ {
+ daemon_local->flags.offlineTraceMaxSize = atoi(value);
+ printf("Option: %s=%s\n",token,value);
+ }
else
{
fprintf(stderr, "Unknown option: %s=%s\n",token,value);
@@ -532,6 +545,7 @@ int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, in
signal(SIGQUIT, dlt_daemon_signal_handler);
signal(SIGINT, dlt_daemon_signal_handler);
+#if 0
/* open DLT output file */
daemon_local->ohandle=-1;
if (daemon_local->flags.ovalue[0])
@@ -546,7 +560,17 @@ int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, in
return -1;
} /* if */
} /* if */
-
+#endif
+ /* init offline trace */
+ if(daemon_local->flags.offlineTraceDirectory[0])
+ {
+ if (dlt_offline_trace_init(&(daemon_local->offlineTrace),daemon_local->flags.offlineTraceDirectory,daemon_local->flags.offlineTraceFileSize,daemon_local->flags.offlineTraceMaxSize)==-1)
+ {
+ dlt_log(LOG_ERR,"Could not initialize offline trace\n");
+ return -1;
+ }
+ }
+
return 0;
}
@@ -822,10 +846,15 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
dlt_message_free(&(daemon_local->msg),daemon_local->flags.vflag);
close(daemon_local->fp);
+ /* free shared memory */
+ if(daemon_local->flags.offlineTraceDirectory[0])
+ dlt_offline_trace_free(&(daemon_local->offlineTrace));
+#if 0
if (daemon_local->flags.ovalue[0])
{
close(daemon_local->ohandle);
} /* if */
+#endif
/* Ignore result */
dlt_file_free(&(daemon_local->file),daemon_local->flags.vflag);
@@ -1742,6 +1771,7 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemo
/* print message header only */
} /* if */
+#if 0
/* if file output enabled write message */
if (daemon_local->flags.ovalue[0])
{
@@ -1755,9 +1785,17 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemo
dlt_log(LOG_ERR,"Writing to output file failed!\n");
}
} /* if */
-
+#endif
sent=0;
+ /* write message to offline trace */
+ if(daemon_local->flags.offlineTraceDirectory[0])
+ {
+ dlt_offline_trace_write(&(daemon_local->offlineTrace),daemon_local->msg.headerbuffer,daemon_local->msg.headersize,
+ daemon_local->msg.databuffer,daemon_local->msg.datasize,0,0);
+ sent = 1;
+ }
+
/* look if TCP connection to client is available */
for (j = 0; j <= daemon_local->fdmax; j++)
{
diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h
index 6a84008..4c8f121 100755
--- a/src/daemon/dlt-daemon.h
+++ b/src/daemon/dlt-daemon.h
@@ -84,6 +84,8 @@
#include "dlt_user_shared.h"
#include "dlt_user_shared_cfg.h"
+#include <dlt_offline_trace.h>
+
/**
* The flags of a dlt daemon.
*/
@@ -98,14 +100,16 @@ typedef struct
int rflag; /**< (Boolean) Send automatic get log info response during context registration */
int mflag; /**< (Boolean) Sync to serial header on serial connection */
int nflag; /**< (Boolean) Sync to serial header on all TCP connections */
- char ovalue[256]; /**< (String: Filename) Store DLT messages to local log file */
char evalue[256]; /**< (String: ECU ID) Set ECU ID (Default: ECU1) */
char bvalue[256]; /**< (String: Baudrate) Serial device baudrate (Default: 115200) */
char yvalue[256]; /**< (String: Devicename) Additional support for serial device */
char ivalue[256]; /**< (String: Directory) Directory where to store the persistant configuration (Default: /tmp) */
char cvalue[256]; /**< (String: Directory) Filename of DLT configuration file (Default: /etc/dlt.conf) */
- int sharedMemorySize; /**< (String: Directory) FSize of shared memory (Default: 100000) */
- int sendMessageTime; /**< (Boolean) Send periodic Message Time if client is connected (Default: 0) */
+ int sharedMemorySize; /**< (int) Size of shared memory (Default: 100000) */
+ int sendMessageTime; /**< (Boolean) Send periodic Message Time if client is connected (Default: 0) */
+ char offlineTraceDirectory[256]; /**< (String: Directory) Store DLT messages to local directory (Default: /etc/dlt.conf) */
+ int offlineTraceFileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */
+ int offlineTraceMaxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */
} DltDaemonFlags;
/**
@@ -121,14 +125,15 @@ typedef struct
fd_set master; /**< master set of handles */
fd_set read_fds; /**< read set of handles */
DltFile file; /**< struct for file access */
- int ohandle; /**< handle to output file */
+ //int ohandle; /**< handle to output file */
DltMessage msg; /**< one dlt message */
DltReceiver receiver; /**< receiver for fifo connection */
DltReceiver receiverSock; /**< receiver for socket connection */
DltReceiver receiverSerial; /**< receiver for serial connection */
int client_connections; /**< counter for nr. of client connections */
size_t baudrate; /**< Baudrate of serial connection */
- DltShm dlt_shm;
+ DltShm dlt_shm; /**< Shared memory handling */
+ DltOfflineTrace offlineTrace; /**< Offline trace handling */
} DltDaemonLocal;
typedef struct