summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2011-09-27 18:07:07 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2011-09-27 18:07:07 +0200
commit0db98cde8dfe99261e87d772e6b1d52dda3c67e6 (patch)
tree5931b7123dd0cd1da4688f1538289c8920c5f16b
parent9e988e62b4a4c88621f34e053c3ab8567d8c299a (diff)
downloadDLT-daemon-0db98cde8dfe99261e87d772e6b1d52dda3c67e6.tar.gz
Offline trace memory partly implemented.
-rw-r--r--include/dlt/dlt_shm.h5
-rwxr-xr-xinclude/dlt/dlt_version.h2
-rwxr-xr-xsrc/daemon/CMakeLists.txt2
-rwxr-xr-xsrc/daemon/dlt-daemon.c52
-rwxr-xr-xsrc/daemon/dlt-daemon.h15
-rw-r--r--testscripts/dlt.conf14
6 files changed, 72 insertions, 18 deletions
diff --git a/include/dlt/dlt_shm.h b/include/dlt/dlt_shm.h
index 5b7d335..c12a43a 100644
--- a/include/dlt/dlt_shm.h
+++ b/include/dlt/dlt_shm.h
@@ -65,6 +65,9 @@
** aw Alexander Wenzel BMW **
*******************************************************************************/
+#ifndef DLT_SHM_H
+#define DLT_SHM_H
+
#define DLT_SHM_KEY 11771
#define DLT_SHM_SIZE 100000
#define DLT_SHM_SEM 22771
@@ -94,3 +97,5 @@ extern void dlt_shm_status(DltShm *buf);
extern int dlt_shm_free_client(DltShm *buf);
extern int dlt_shm_free_server(DltShm *buf);
+
+#endif /* DLT_SHM_H */
diff --git a/include/dlt/dlt_version.h b/include/dlt/dlt_version.h
index 05c62c7..30152fd 100755
--- a/include/dlt/dlt_version.h
+++ b/include/dlt/dlt_version.h
@@ -7,6 +7,6 @@
#define PACKAGE_MAJOR_VERSION "2"
#define PACKAGE_MINOR_VERSION "3"
#define PACKAGE_PATCH_LEVEL "0"
-#define PACKAGE_REVISION "v2.3.0-13-gd28ed93"
+#define PACKAGE_REVISION "v2.3.0-20-g9e988e6"
#endif
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
diff --git a/testscripts/dlt.conf b/testscripts/dlt.conf
index b5bf7be..4129396 100644
--- a/testscripts/dlt.conf
+++ b/testscripts/dlt.conf
@@ -28,14 +28,20 @@ ECUId = ENAT
SharedMemorySize = 4000000
# Directory where to store the persistant configuration (Default: /tmp)
-PersistanceStoragePath = ~/tmp
+PersistanceStoragePath = /home/alex/tmp
########################################################################
-# Local file output configuration #
+# Offline Trace memory #
########################################################################
-# Store DLT messages to local log file
-# LocalLogFilename = ~/tmp/local_log.dlt
+# Store DLT messages to local directory, if not set offline Trace is off (Default: off)
+OfflineTraceDirectory = /home/alex/tmp
+
+# Maximum size in bytes of one trace file (Default: 1000000)
+OfflineTraceFileSize = 1000000
+
+# Maximum size of all trace files (Default: 4000000)
+OfflineTraceMaxSize = 4000000
########################################################################
# Local console output configuration #