summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2011-09-26 17:26:11 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2011-09-26 17:26:11 +0200
commitbd41c67478a0ecb745c20510eab6228398ea59ea (patch)
treed31cbf4a4a8ca760835bb10c67b6b9a25d1f9f16
parent263c0316ef06a4894c1fe8982063366d32f47d8e (diff)
downloadDLT-daemon-bd41c67478a0ecb745c20510eab6228398ea59ea.tar.gz
Shared memory size parameter added to configuration.
-rw-r--r--include/dlt/dlt_shm.h2
-rwxr-xr-xsrc/daemon/dlt-daemon.c89
-rwxr-xr-xsrc/daemon/dlt-daemon.h1
-rw-r--r--testscripts/dlt.conf9
4 files changed, 65 insertions, 36 deletions
diff --git a/include/dlt/dlt_shm.h b/include/dlt/dlt_shm.h
index e9a8d07..aca92c6 100644
--- a/include/dlt/dlt_shm.h
+++ b/include/dlt/dlt_shm.h
@@ -66,7 +66,7 @@
*******************************************************************************/
#define DLT_SHM_KEY 11771
-#define DLT_SHM_SIZE (1024*4000)
+#define DLT_SHM_SIZE 100000
#define DLT_SHM_SEM 22771
typedef struct
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index 4c68abc..90f2732 100755
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -303,13 +303,15 @@ int option_file_parser(DltDaemonLocal *daemon_local)
char *pch;
const char *filename;
+ /* set default values for configuration */
+ daemon_local->flags.sharedMemorySize = DLT_SHM_SIZE;
/* open configuration file */
if(daemon_local->flags.cvalue[0])
filename = daemon_local->flags.cvalue;
else
filename = "/etc/dlt.conf";
- printf("Load configuration from file: %s\n",filename);
+ //printf("Load configuration from file: %s\n",filename);
pFile = fopen (filename,"r");
if (pFile!=NULL)
@@ -345,66 +347,89 @@ int option_file_parser(DltDaemonLocal *daemon_local)
if(token[0] && value[0])
{
/* parse arguments here */
- printf("%s = %s\n",token,value);
if(strcmp(token,"Verbose")==0)
{
- daemon_local->flags.vflag = atoi(pch);
+ daemon_local->flags.vflag = atoi(value);
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"PrintASCII")==0)
+ else if(strcmp(token,"PrintASCII")==0)
{
- daemon_local->flags.aflag = atoi(pch);
+ daemon_local->flags.aflag = atoi(value);
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"PrintHex")==0)
+ else if(strcmp(token,"PrintHex")==0)
{
- daemon_local->flags.xflag = atoi(pch);
+ daemon_local->flags.xflag = atoi(value);
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"PrintHeadersOnly")==0)
+ else if(strcmp(token,"PrintHeadersOnly")==0)
{
- daemon_local->flags.sflag = atoi(pch);
+ daemon_local->flags.sflag = atoi(value);
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"Daemonize")==0)
+ else if(strcmp(token,"Daemonize")==0)
{
- daemon_local->flags.dflag = atoi(pch);
+ daemon_local->flags.dflag = atoi(value);
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"SendSerialHeader")==0)
+ else if(strcmp(token,"SendSerialHeader")==0)
{
- daemon_local->flags.lflag = atoi(pch);
+ daemon_local->flags.lflag = atoi(value);
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"SendContextRegistration")==0)
+ else if(strcmp(token,"SendContextRegistration")==0)
{
- daemon_local->flags.rflag = atoi(pch);
+ daemon_local->flags.rflag = atoi(value);
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"RS232SyncSerialHeader")==0)
+ else if(strcmp(token,"RS232SyncSerialHeader")==0)
{
- daemon_local->flags.mflag = atoi(pch);
+ daemon_local->flags.mflag = atoi(value);
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"TCPSyncSerialHeader")==0)
+ else if(strcmp(token,"TCPSyncSerialHeader")==0)
{
- daemon_local->flags.nflag = atoi(pch);
+ daemon_local->flags.nflag = atoi(value);
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"RS232DeviceName")==0)
+ else if(strcmp(token,"RS232DeviceName")==0)
{
- strncpy(daemon_local->flags.yvalue,pch,sizeof(daemon_local->flags.yvalue));
+ strncpy(daemon_local->flags.yvalue,value,sizeof(daemon_local->flags.yvalue));
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"RS232Baudrate")==0)
+ else if(strcmp(token,"RS232Baudrate")==0)
{
- strncpy(daemon_local->flags.bvalue,pch,sizeof(daemon_local->flags.bvalue));
+ strncpy(daemon_local->flags.bvalue,value,sizeof(daemon_local->flags.bvalue));
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"ECUId")==0)
+ else if(strcmp(token,"ECUId")==0)
{
- strncpy(daemon_local->flags.evalue,pch,sizeof(daemon_local->flags.evalue));
+ strncpy(daemon_local->flags.evalue,value,sizeof(daemon_local->flags.evalue));
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"LocalLogFilename")==0)
+ else if(strcmp(token,"LocalLogFilename")==0)
{
- strncpy(daemon_local->flags.ovalue,pch,sizeof(daemon_local->flags.ovalue));
+ strncpy(daemon_local->flags.ovalue,value,sizeof(daemon_local->flags.ovalue));
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"RingbufferSize")==0)
+ else if(strcmp(token,"RingbufferSize")==0)
{
- strncpy(daemon_local->flags.uvalue,pch,sizeof(daemon_local->flags.uvalue));
+ strncpy(daemon_local->flags.uvalue,value,sizeof(daemon_local->flags.uvalue));
+ printf("Option: %s=%s\n",token,value);
}
- if(strcmp(token,"PersistanceStoragePath")==0)
+ else if(strcmp(token,"PersistanceStoragePath")==0)
{
- strncpy(daemon_local->flags.ivalue,pch,sizeof(daemon_local->flags.ivalue));
+ strncpy(daemon_local->flags.ivalue,value,sizeof(daemon_local->flags.ivalue));
+ printf("Option: %s=%s\n",token,value);
+ }
+ else if(strcmp(token,"SharedMemorySize")==0)
+ {
+ daemon_local->flags.sharedMemorySize = atoi(value);
+ printf("Option: %s=%s\n",token,value);
+ }
+ else
+ {
+ fprintf(stderr, "Unknown option: %s=%s\n",token,value);
}
}
//printf ("Token: %s\n",pch);
@@ -648,7 +673,7 @@ int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, in
dlt_log(LOG_NOTICE, str);
/* init shared memory */
- if (dlt_shm_init_server(&(daemon_local->dlt_shm),DLT_SHM_KEY,DLT_SHM_SIZE)==-1)
+ if (dlt_shm_init_server(&(daemon_local->dlt_shm),DLT_SHM_KEY,daemon_local->flags.sharedMemorySize)==-1)
{
dlt_log(LOG_ERR,"Could not initialize shared memory\n");
return -1;
diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h
index 1e21ee6..9a04235 100755
--- a/src/daemon/dlt-daemon.h
+++ b/src/daemon/dlt-daemon.h
@@ -105,6 +105,7 @@ typedef struct
char uvalue[256]; /**< (String: Ringbuffer) Size of the ringbuffer in bytes (Default: 10024) */
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 */
} DltDaemonFlags;
/**
diff --git a/testscripts/dlt.conf b/testscripts/dlt.conf
index cafed60..27ff01d 100644
--- a/testscripts/dlt.conf
+++ b/testscripts/dlt.conf
@@ -7,7 +7,7 @@
########################################################################
# Start daemon in dubug mode, so that all internal debug information is printed out on the console
-Verbose = 1
+# Verbose = 1
# Daemonize DLT daemon, if it is started as daemon
# Daemonize = 1
@@ -19,10 +19,13 @@ Verbose = 1
# SendContextRegistration = 1
# Set ECU ID (Default: ECU1)
-ECUId = ENAE
+ECUId = ENAT
# Size of the ringbuffer in bytes (Default: 10024)
-# RingbufferSize = 10024
+RingbufferSize = 100024
+
+# Size of shared memory (Default: 100000)
+SharedMemorySize = 4000000
# Directory where to store the persistant configuration (Default: /tmp)
PersistanceStoragePath = ~/tmp