diff options
-rw-r--r-- | include/dlt/dlt_shm.h | 70 | ||||
-rwxr-xr-x | include/dlt/dlt_version.h | 2 | ||||
-rwxr-xr-x | src/daemon/dlt-daemon.c | 200 | ||||
-rwxr-xr-x | src/daemon/dlt-daemon.h | 2 | ||||
-rw-r--r-- | src/shared/dlt_shm.c | 73 | ||||
-rw-r--r-- | testscripts/dlt.conf | 3 |
6 files changed, 222 insertions, 128 deletions
diff --git a/include/dlt/dlt_shm.h b/include/dlt/dlt_shm.h index c660bb6..e9a8d07 100644 --- a/include/dlt/dlt_shm.h +++ b/include/dlt/dlt_shm.h @@ -1,3 +1,69 @@ +/* +* Dlt- Diagnostic Log and Trace user library +* @licence app begin@ + * + * Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de> + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + * Public License, version 2.1, for more details. + * + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along + * with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>. + * + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may + * also be applicable to programs even in cases in which the program is not a library in the technical sense. + * + * Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may + * license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to + * license your linked modules under the GNU Lesser General Public License, version 2.1, you + * may use the program under the following exception. + * + * As a special exception, the copyright holders of DLT give you permission to combine DLT + * with software programs or libraries that are released under any license unless such a combination is not + * permitted by the license of such a software program or library. You may copy and distribute such a + * system following the terms of the GNU Lesser General Public License, version 2.1, including this + * special exception, for DLT and the licenses of the other code concerned. + * + * Note that people who make modified versions of DLT are not obligated to grant this special exception + * for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, + * version 2.1, gives permission to release a modified version without this exception; this exception + * also makes it possible to release a modified version which carries forward this exception. + * + * @licence end@ +*/ + + +/******************************************************************************* +** ** +** SRC-MODULE: dlt_shm.h ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de ** +** ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ + +/******************************************************************************* +** Author Identity ** +******************************************************************************** +** ** +** Initials Name Company ** +** -------- ------------------------- ---------------------------------- ** +** aw Alexander Wenzel BMW ** +*******************************************************************************/ #define DLT_SHM_KEY 11771 #define DLT_SHM_SIZE (1024*4000) @@ -18,8 +84,8 @@ typedef struct extern int dlt_shm_init_client(DltShm *buf,int key); extern int dlt_shm_init_server(DltShm *buf,int key,int size); -extern int dlt_shm_push(DltShm *buf,const char *data1, int size1,const char *data2, int size2,const char *data3, int size3); -extern int dlt_shm_pull(DltShm *buf,char *data, int size); +extern int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size1,const unsigned char *data2,unsigned int size2,const unsigned char *data3,unsigned int size3); +extern int dlt_shm_pull(DltShm *buf,unsigned char *data, int size); extern void dlt_shm_info(DltShm *buf); extern void dlt_shm_status(DltShm *buf); diff --git a/include/dlt/dlt_version.h b/include/dlt/dlt_version.h index 37b45b9..05c62c7 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-g0eaf6ec" +#define PACKAGE_REVISION "v2.3.0-13-gd28ed93" #endif diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 6b2155d..4c68abc 100755 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -149,7 +149,6 @@ void usage() printf(" -b baudrate Serial device baudrate (Default: 115200)\n"); printf(" -e ecuid Set ECU ID (Default: ECU1)\n"); printf(" -o filename Store DLT messages to local log file\n"); - printf(" -f filename Enable filtering of messages\n"); printf(" -u size Size of the ringbuffer in bytes (Default: 10024)\n"); printf(" -i directory Directory where to store the persistant configuration (Default: /tmp)\n"); printf(" -c filename DLT daemon configuration file (Default: /etc/dlt.conf)\n"); @@ -173,7 +172,7 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[]) opterr = 0; - while ((c = getopt (argc, argv, "hvasxdlrmnf:o:e:b:y:u:i:c:")) != -1) + while ((c = getopt (argc, argv, "hvasxdlrmno:e:b:y:u:i:c:")) != -1) { switch (c) { @@ -222,11 +221,6 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[]) daemon_local->flags.nflag = 1; break; } - case 'f': - { - strncpy(daemon_local->flags.fvalue,optarg,sizeof(daemon_local->flags.fvalue)); - break; - } case 'o': { strncpy(daemon_local->flags.ovalue,optarg,sizeof(daemon_local->flags.ovalue)); @@ -404,10 +398,6 @@ int option_file_parser(DltDaemonLocal *daemon_local) { strncpy(daemon_local->flags.ovalue,pch,sizeof(daemon_local->flags.ovalue)); } - if(strcmp(token,"FilterFilename")==0) - { - strncpy(daemon_local->flags.fvalue,pch,sizeof(daemon_local->flags.fvalue)); - } if(strcmp(token,"RingbufferSize")==0) { strncpy(daemon_local->flags.uvalue,pch,sizeof(daemon_local->flags.uvalue)); @@ -590,26 +580,6 @@ int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, in return -1; } - /* first parse filter file if filter parameter is used */ - if (daemon_local->flags.fvalue[0]) - { - if (dlt_filter_load(&(daemon_local->filter),daemon_local->flags.fvalue,daemon_local->flags.vflag)<0) - { - dlt_log(LOG_ERR,"Could not load filters\n"); - /* Return value ignored, dlt daemon will exit */ - dlt_file_free(&(daemon_local->file),daemon_local->flags.vflag); - return -1; - } /* if */ - - if (dlt_file_set_filter(&(daemon_local->file),&(daemon_local->filter),daemon_local->flags.vflag)==-1) - { - dlt_log(LOG_ERR,"Could not apply filters\n"); - /* Return value ignored, dlt daemon will exit */ - dlt_file_free(&(daemon_local->file),daemon_local->flags.vflag); - return -1; - } - } /* if */ - signal(SIGPIPE,SIG_IGN); signal(SIGTERM, dlt_daemon_signal_handler); /* software termination signal from kill */ @@ -1759,10 +1729,10 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon, DltDae int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose) { - int bytes_to_be_removed; + //int bytes_to_be_removed; int j,sent,third_value; ssize_t ret; - char rcv_buffer[10000]; + uint8_t rcv_buffer[10000]; int size; static char text[DLT_DAEMON_TEXTSIZE]; @@ -1814,114 +1784,110 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemo } } - if ((daemon_local->flags.fvalue[0]==0) || - (daemon_local->flags.fvalue[0] && (dlt_message_filter_check(&(daemon_local->msg),&(daemon_local->filter),verbose)==1))) + /* if no filter set or filter is matching display message */ + if (daemon_local->flags.xflag) { - /* if no filter set or filter is matching display message */ - if (daemon_local->flags.xflag) + if (dlt_message_print_hex(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1) { - if (dlt_message_print_hex(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1) - { - dlt_log(LOG_ERR,"dlt_message_print_hex() failed!\n"); - } - } /* if */ - else if (daemon_local->flags.aflag) + dlt_log(LOG_ERR,"dlt_message_print_hex() failed!\n"); + } + } /* if */ + else if (daemon_local->flags.aflag) + { + if (dlt_message_print_ascii(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1) { - if (dlt_message_print_ascii(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1) - { - dlt_log(LOG_ERR,"dlt_message_print_ascii() failed!\n"); - } - } /* if */ - else if (daemon_local->flags.sflag) + dlt_log(LOG_ERR,"dlt_message_print_ascii() failed!\n"); + } + } /* if */ + else if (daemon_local->flags.sflag) + { + if (dlt_message_print_header(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1) { - if (dlt_message_print_header(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1) - { - dlt_log(LOG_ERR,"dlt_message_print_header() failed!\n"); - } - /* print message header only */ - } /* if */ + dlt_log(LOG_ERR,"dlt_message_print_header() failed!\n"); + } + /* print message header only */ + } /* if */ - /* if file output enabled write message */ - if (daemon_local->flags.ovalue[0]) + /* if file output enabled write message */ + if (daemon_local->flags.ovalue[0]) + { + /* write message to output buffer */ + if (dlt_user_log_out2(daemon_local->ohandle, + daemon_local->msg.headerbuffer, + daemon_local->msg.headersize, + daemon_local->msg.databuffer, + daemon_local->msg.datasize) !=DLT_RETURN_OK) { - /* write message to output buffer */ - if (dlt_user_log_out2(daemon_local->ohandle, - daemon_local->msg.headerbuffer, - daemon_local->msg.headersize, - daemon_local->msg.databuffer, - daemon_local->msg.datasize) !=DLT_RETURN_OK) - { - dlt_log(LOG_ERR,"Writing to output file failed!\n"); - } - } /* if */ + dlt_log(LOG_ERR,"Writing to output file failed!\n"); + } + } /* if */ - sent=0; + sent=0; - /* look if TCP connection to client is available */ - for (j = 0; j <= daemon_local->fdmax; j++) + /* look if TCP connection to client is available */ + for (j = 0; j <= daemon_local->fdmax; j++) + { + /* send to everyone! */ + if (FD_ISSET(j, &(daemon_local->master))) { - /* send to everyone! */ - if (FD_ISSET(j, &(daemon_local->master))) + /* except the listener and ourselves */ + if (daemon_local->flags.yvalue!=0) { - /* except the listener and ourselves */ - if (daemon_local->flags.yvalue!=0) - { - third_value = daemon_local->fdserial; - } - else - { - third_value = daemon_local->sock; - } + third_value = daemon_local->fdserial; + } + else + { + third_value = daemon_local->sock; + } + + if ((j != daemon_local->fp) && (j != daemon_local->sock) && (j != third_value)) + { + DLT_DAEMON_SEM_LOCK(); - if ((j != daemon_local->fp) && (j != daemon_local->sock) && (j != third_value)) + if (daemon_local->flags.lflag) { - DLT_DAEMON_SEM_LOCK(); + send(j,dltSerialHeader,sizeof(dltSerialHeader),0); + } - if (daemon_local->flags.lflag) - { - send(j,dltSerialHeader,sizeof(dltSerialHeader),0); - } + send(j,daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader),0); + send(j,daemon_local->msg.databuffer,daemon_local->msg.datasize,0); - send(j,daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader),0); - send(j,daemon_local->msg.databuffer,daemon_local->msg.datasize,0); + DLT_DAEMON_SEM_FREE(); - DLT_DAEMON_SEM_FREE(); + sent=1; + } /* if */ + else if ((j == daemon_local->fdserial) && (daemon_local->flags.yvalue[0])) + { + DLT_DAEMON_SEM_LOCK(); - sent=1; - } /* if */ - else if ((j == daemon_local->fdserial) && (daemon_local->flags.yvalue[0])) + if (daemon_local->flags.lflag) { - DLT_DAEMON_SEM_LOCK(); - - if (daemon_local->flags.lflag) - { - ret=write(j,dltSerialHeader,sizeof(dltSerialHeader)); - } + ret=write(j,dltSerialHeader,sizeof(dltSerialHeader)); + } - ret=write(j,daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader)); - ret=write(j,daemon_local->msg.databuffer,daemon_local->msg.datasize); + ret=write(j,daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader)); + ret=write(j,daemon_local->msg.databuffer,daemon_local->msg.datasize); - DLT_DAEMON_SEM_FREE(); + DLT_DAEMON_SEM_FREE(); - sent=1; - } - } /* if */ - } /* for */ + sent=1; + } + } /* if */ + } /* for */ - /* Message was not sent to client, so store it in client ringbuffer */ - if (sent==0) + /* Message was not sent to client, so store it in client ringbuffer */ + if (sent==0) + { + if (dlt_ringbuffer_put3(&(daemon->client_ringbuffer), + daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader), + daemon_local->msg.databuffer,daemon_local->msg.datasize, + 0, 0 + )<0) { - if (dlt_ringbuffer_put3(&(daemon->client_ringbuffer), - daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader), - daemon_local->msg.databuffer,daemon_local->msg.datasize, - 0, 0 - )<0) - { - dlt_log(LOG_ERR,"Storage of message in history buffer failed! Message discarded.\n"); - } + dlt_log(LOG_ERR,"Storage of message in history buffer failed! Message discarded.\n"); } - } + /* keep not read data in buffer */ /*bytes_to_be_removed = daemon_local->msg.headersize+daemon_local->msg.datasize-sizeof(DltStorageHeader)+sizeof(DltUserHeader); if (daemon_local->msg.found_serialheader) diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h index 2c8e1ca..1e21ee6 100755 --- a/src/daemon/dlt-daemon.h +++ b/src/daemon/dlt-daemon.h @@ -99,7 +99,6 @@ typedef struct 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 fvalue[256]; /**< (String: Filename) Enable filtering of messages */
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 */
@@ -121,7 +120,6 @@ typedef struct fd_set master; /**< master set of handles */
fd_set read_fds; /**< read set of handles */
DltFile file; /**< struct for file access */
- DltFilter filter; /**< struct for filter access */
int ohandle; /**< handle to output file */
DltMessage msg; /**< one dlt message */
DltReceiver receiver; /**< receiver for fifo connection */
diff --git a/src/shared/dlt_shm.c b/src/shared/dlt_shm.c index bb8163e..709a389 100644 --- a/src/shared/dlt_shm.c +++ b/src/shared/dlt_shm.c @@ -1,3 +1,70 @@ +/* +* Dlt- Diagnostic Log and Trace user library +* @licence app begin@ + * + * Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de> + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + * Public License, version 2.1, for more details. + * + * You should have received a copy of the GNU Lesser General Public License, version 2.1, along + * with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>. + * + * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may + * also be applicable to programs even in cases in which the program is not a library in the technical sense. + * + * Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may + * license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to + * license your linked modules under the GNU Lesser General Public License, version 2.1, you + * may use the program under the following exception. + * + * As a special exception, the copyright holders of DLT give you permission to combine DLT + * with software programs or libraries that are released under any license unless such a combination is not + * permitted by the license of such a software program or library. You may copy and distribute such a + * system following the terms of the GNU Lesser General Public License, version 2.1, including this + * special exception, for DLT and the licenses of the other code concerned. + * + * Note that people who make modified versions of DLT are not obligated to grant this special exception + * for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, + * version 2.1, gives permission to release a modified version without this exception; this exception + * also makes it possible to release a modified version which carries forward this exception. + * + * @licence end@ +*/ + + +/******************************************************************************* +** ** +** SRC-MODULE: dlt_shm.c ** +** ** +** TARGET : linux ** +** ** +** PROJECT : DLT ** +** ** +** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de ** +** ** +** PURPOSE : ** +** ** +** REMARKS : ** +** ** +** PLATFORM DEPENDANT [yes/no]: yes ** +** ** +** TO BE CHANGED BY USER [yes/no]: no ** +** ** +*******************************************************************************/ + +/******************************************************************************* +** Author Identity ** +******************************************************************************** +** ** +** Initials Name Company ** +** -------- ------------------------- ---------------------------------- ** +** aw Alexander Wenzel BMW ** +*******************************************************************************/ + #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> @@ -81,7 +148,7 @@ int dlt_shm_init_server(DltShm *buf,int key,int size) { } int dlt_shm_init_client(DltShm *buf,int key) { - struct shmid_ds shm_buf = { 0 }; + struct shmid_ds shm_buf; // init parameters buf->shm = NULL; @@ -147,7 +214,7 @@ void dlt_shm_status(DltShm *buf) } -int dlt_shm_push(DltShm *buf,const char *data1, int size1,const char *data2, int size2,const char *data3, int size3) +int dlt_shm_push(DltShm *buf,const unsigned char *data1,unsigned int size1,const unsigned char *data2,unsigned int size2,const unsigned char *data3,unsigned int size3) { int write, read, count; @@ -232,7 +299,7 @@ int dlt_shm_push(DltShm *buf,const char *data1, int size1,const char *data2, int return 0; // OK } -int dlt_shm_pull(DltShm *buf,char *data, int max_size) +int dlt_shm_pull(DltShm *buf,unsigned char *data, int max_size) { int write, read, count, size; unsigned char status; diff --git a/testscripts/dlt.conf b/testscripts/dlt.conf index e9101e4..cafed60 100644 --- a/testscripts/dlt.conf +++ b/testscripts/dlt.conf @@ -21,9 +21,6 @@ Verbose = 1 # Set ECU ID (Default: ECU1) ECUId = ENAE -# Enable filtering of messages -# FilterFilename = ~/tmp/filter - # Size of the ringbuffer in bytes (Default: 10024) # RingbufferSize = 10024 |