diff options
Diffstat (limited to 'src')
30 files changed, 260 insertions, 260 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 675d958..41cc807 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -214,7 +214,7 @@ int option_file_parser(DltDaemonLocal *daemon_local) pch = strtok (line," =\r\n"); token[0]=0; value[0]=0; - + while (pch != NULL) { if(strcmp(pch,"#")==0) @@ -234,7 +234,7 @@ int option_file_parser(DltDaemonLocal *daemon_local) pch = strtok (NULL, " =\r\n"); } - + if(token[0] && value[0]) { /* parse arguments here */ @@ -393,7 +393,7 @@ int option_file_parser(DltDaemonLocal *daemon_local) else { fprintf(stderr, "Cannot open configuration file: %s\n",filename); - } + } return 0; } @@ -425,7 +425,7 @@ int main(int argc, char* argv[]) } return -1; } - + /* Initialize internal logging facility */ dlt_log_set_filename(daemon_local.flags.loggingFilename); dlt_log_set_level(daemon_local.flags.loggingLevel); @@ -489,8 +489,8 @@ int main(int argc, char* argv[]) create_timer_fd(&daemon_local, 60, 60, &daemon_local.timer_sixty_s, "ECU version"); } - // For offline tracing we still can use the same states - // as for socket sending. Using this trick we see the traces + // For offline tracing we still can use the same states + // as for socket sending. Using this trick we see the traces // In the offline trace AND in the socket stream. if(daemon_local.flags.yvalue[0]) dlt_daemon_change_state(&daemon,DLT_DAEMON_STATE_SEND_DIRECT); @@ -705,7 +705,7 @@ int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, in signal(SIGHUP, dlt_daemon_signal_handler); /* hangup signal */ signal(SIGQUIT, dlt_daemon_signal_handler); signal(SIGINT, dlt_daemon_signal_handler); - + return 0; } @@ -757,7 +757,7 @@ int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, in return -1; } #endif - + /* prepare main loop */ if (dlt_message_init(&(daemon_local->msg),daemon_local->flags.vflag)==-1) { @@ -783,13 +783,13 @@ int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, in return -1; } } - + /* configure sending timing packets */ - if (daemon_local->flags.sendMessageTime) + if (daemon_local->flags.sendMessageTime) { daemon->timingpackets = 1; } - + /* Binary semaphore for thread */ if (sem_init(&dlt_daemon_mutex, 0, 1)==-1) { @@ -1152,10 +1152,10 @@ void dlt_daemon_daemonize(int verbose) } /* dlt_daemon_daemonize() */ /* This function logs str to the configured output sink (socket, serial, offline trace). - To avoid recursion this function must be called only from DLT highlevel functions. + To avoid recursion this function must be called only from DLT highlevel functions. E. g. calling it to output a failure when the open of the offline trace file fails would cause an endless loop because dlt_daemon_log_internal() would itself again try - to open the offline trace file. + to open the offline trace file. This is a dlt-daemon only function. The libdlt has no equivalent function available. */ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, char *str, int verbose) { @@ -1166,18 +1166,18 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha uint16_t uiSize; uint32_t uiExtraSize; int ret; - + PRINT_FUNCTION_VERBOSE(verbose); // Set storageheader msg.storageheader = (DltStorageHeader *)(msg.headerbuffer); dlt_set_storageheader(msg.storageheader, daemon->ecuid); - // Set standardheader + // Set standardheader msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader)); msg.standardheader->htyp = DLT_HTYP_UEH | DLT_HTYP_WEID | DLT_HTYP_WSID | DLT_HTYP_WTMS | DLT_HTYP_PROTOCOL_VERSION1; msg.standardheader->mcnt = uiMsgCount++; - + uiExtraSize = DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp)+(DLT_IS_HTYP_UEH(msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0); msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + uiExtraSize; @@ -1247,7 +1247,7 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha } free(msg.databuffer); - + return 0; } @@ -1333,7 +1333,7 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon, DltDaemonLocal *daemon_ dlt_log(LOG_WARNING,"Can't send contents of ringbuffer to clients\n"); return -1; } - + /* send new log state to all applications */ daemon->connectionState = 1; dlt_daemon_user_send_all_log_state(daemon,verbose); @@ -2104,12 +2104,12 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemo { if(ret!=DLT_MESSAGE_ERROR_SIZE) { - /* This is a normal usecase: The daemon reads the data in 10kb chunks. + /* This is a normal usecase: The daemon reads the data in 10kb chunks. Thus the last trace in this chunk is probably not complete and will be completed with the next chunk read. This happens always when the FIFO is filled with more than 10kb before - the daemon is able to read from the FIFO. - Thus the loglevel of this message is set to DEBUG. - A cleaner solution would be to check more in detail whether the message is not complete (normal usecase) + the daemon is able to read from the FIFO. + Thus the loglevel of this message is set to DEBUG. + A cleaner solution would be to check more in detail whether the message is not complete (normal usecase) or the headers are corrupted (error case). */ dlt_log(LOG_DEBUG,"Can't read messages from receiver\n"); } @@ -2235,10 +2235,10 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon, DltDaemonLocal *d } userheader = (DltUserHeader*) (daemon_local->receiver.buf); - + //dlt_shm_status(&(daemon_local->dlt_shm)); while (1) - { + { /* log message in SHM */ if((size = dlt_shm_copy(&(daemon_local->dlt_shm),rcv_buffer,10000)) <= 0) break; @@ -2246,13 +2246,13 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon, DltDaemonLocal *d break; dlt_log(LOG_WARNING,"Can't read messages from shm\n"); return -1; - } + } bytes_to_be_removed = daemon_local->msg.headersize+daemon_local->msg.datasize-sizeof(DltStorageHeader)+sizeof(DltUserHeader); if (daemon_local->msg.found_serialheader) { bytes_to_be_removed += sizeof(dltSerialHeader); } - + /* set overwrite ecu id */ if (daemon_local->flags.evalue[0]) { @@ -2381,14 +2381,14 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon, DltDaemonLocal *d if(userheader->message == DLT_USER_MESSAGE_LOG_SHM) { /* dlt message was sent, remove from buffer if log message from shm */ dlt_shm_remove(&(daemon_local->dlt_shm)); - } + } } else { /* dlt message was not sent, keep in buffer */ break; } - + } /* keep not read data in buffer */ @@ -2397,7 +2397,7 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon, DltDaemonLocal *d dlt_log(LOG_WARNING,"Can't remove bytes from receiver for user message overflow\n"); return -1; } - + return 0; } #endif @@ -2680,8 +2680,8 @@ int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_ daemon->connectionState = 0; dlt_daemon_user_send_all_log_state(daemon,verbose); - // For offline tracing we still can use the same states - // as for socket sending. Using this trick we see the traces + // For offline tracing we still can use the same states + // as for socket sending. Using this trick we see the traces // In the offline trace AND in the socket stream. if(daemon_local->flags.yvalue[0] == 0) dlt_daemon_change_state(daemon,DLT_DAEMON_STATE_BUFFER); diff --git a/src/daemon/dlt-daemon_cfg.h b/src/daemon/dlt-daemon_cfg.h index b92c595..8870217 100755 --- a/src/daemon/dlt-daemon_cfg.h +++ b/src/daemon/dlt-daemon_cfg.h @@ -79,11 +79,11 @@ #define DLT_DAEMON_ECU_VERSION_THREAD_STACKSIZE 100000 /* Size of receive buffer for fifo connection (from user application) */ -#define DLT_DAEMON_RCVBUFSIZE 10024 +#define DLT_DAEMON_RCVBUFSIZE 10024 /* Size of receive buffer for socket connection (from dlt client) */ -#define DLT_DAEMON_RCVBUFSIZESOCK 10024 +#define DLT_DAEMON_RCVBUFSIZESOCK 10024 /* Size of receive buffer for serial connection (from dlt client) */ -#define DLT_DAEMON_RCVBUFSIZESERIAL 10024 +#define DLT_DAEMON_RCVBUFSIZESERIAL 10024 /* Size of buffer for text output */ #define DLT_DAEMON_TEXTSIZE 10024 @@ -95,15 +95,15 @@ #define DLT_DAEMON_DESCSIZE 256 /* Name of daemon lock file, contain process id of dlt daemon instance */ -#define DLT_DAEMON_LOCK_FILE "dltd.lock" +#define DLT_DAEMON_LOCK_FILE "dltd.lock" /* Umask of daemon, creates files with permission 750 */ -#define DLT_DAEMON_UMASK 027 +#define DLT_DAEMON_UMASK 027 /* Permissions of daemon lock file */ #define DLT_DAEMON_LOCK_FILE_PERM 0640 /* Default ECU ID, used in storage header and transmitted to client*/ -#define DLT_DAEMON_ECU_ID "ECU1" +#define DLT_DAEMON_ECU_ID "ECU1" /* Default baudrate for serial interface */ #define DLT_DAEMON_SERIAL_DEFAULT_BAUDRATE 115200 diff --git a/src/daemon/dlt.conf b/src/daemon/dlt.conf index 1032a9a..d3ba7f3 100644 --- a/src/daemon/dlt.conf +++ b/src/daemon/dlt.conf @@ -41,7 +41,7 @@ LoggingLevel = 6 # The logging filename if internal logging mode is log to file (Default: /tmp/dlt.log) LoggingFilename = /tmp/dlt.log -# Timeout on send to client (sec) +# Timeout on send to client (sec) TimeOutOnSend = 4 # The minimum size of the Ringbuffer, used for storing temporary DLT messages, until client is connected (Default: 500000) diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c index a41dba7..c28f098 100644 --- a/src/daemon/dlt_daemon_client.c +++ b/src/daemon/dlt_daemon_client.c @@ -101,8 +101,8 @@ int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_loc } /* write message to offline trace */ - // In the SEND_BUFFER state we must skip offline tracing because the offline traces - // are going without buffering directly to the offline trace. Thus we have to filter out + // In the SEND_BUFFER state we must skip offline tracing because the offline traces + // are going without buffering directly to the offline trace. Thus we have to filter out // the traces that are coming from the buffer. if ((sock!=DLT_DAEMON_SEND_FORCE) && (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)) { diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c index 8cb97a4..ad1256e 100644 --- a/src/daemon/dlt_daemon_common.c +++ b/src/daemon/dlt_daemon_common.c @@ -146,7 +146,7 @@ int dlt_daemon_init(DltDaemon *daemon,unsigned long RingbufferMinSize,unsigned l daemon->overflow_counter = 0; daemon->runtime_context_cfg_loaded = 0; - + daemon->mode = DLT_USER_MODE_EXTERNAL; daemon->connectionState = 0; /* no logger connected */ @@ -200,10 +200,10 @@ int dlt_daemon_init(DltDaemon *daemon,unsigned long RingbufferMinSize,unsigned l { daemon->runtime_context_cfg_loaded = 1; } - + /* load configuration if available */ dlt_daemon_configuration_load(daemon,daemon->runtime_configuration, verbose); - + daemon->sendserialheader = 0; daemon->timingpackets = 0; @@ -1061,7 +1061,7 @@ int dlt_daemon_configuration_load(DltDaemon *daemon,const char *filename, int ve pch = strtok (line," =\r\n"); token[0]=0; value[0]=0; - + while (pch != NULL) { if(strcmp(pch,"#")==0) @@ -1081,7 +1081,7 @@ int dlt_daemon_configuration_load(DltDaemon *daemon,const char *filename, int ve pch = strtok (NULL, " =\r\n"); } - + if(token[0] && value[0]) { /* parse arguments here */ @@ -1109,8 +1109,8 @@ int dlt_daemon_configuration_load(DltDaemon *daemon,const char *filename, int ve { snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Cannot open configuration file: %s\n",filename); dlt_log(LOG_WARNING, str); - } - + } + return 0; } diff --git a/src/daemon/dlt_daemon_common_cfg.h b/src/daemon/dlt_daemon_common_cfg.h index f7718ef..e0f99da 100755 --- a/src/daemon/dlt_daemon_common_cfg.h +++ b/src/daemon/dlt_daemon_common_cfg.h @@ -96,14 +96,14 @@ /* Context ID used when the dlt daemon creates a control message */ #define DLT_DAEMON_CTRL_CTID "DC1" -/* Number of entries to be allocated at one in application table, +/* Number of entries to be allocated at one in application table, when no more entries are available */ #define DLT_DAEMON_APPL_ALLOC_SIZE 500 -/* Number of entries to be allocated at one in context table, +/* Number of entries to be allocated at one in context table, when no more entries are available */ #define DLT_DAEMON_CONTEXT_ALLOC_SIZE 1000 -/* Debug get log info function, +/* Debug get log info function, set to 1 to enable, 0 to disable debugging */ #define DLT_DEBUG_GETLOGINFO 0 diff --git a/src/dbus/CMakeLists.txt b/src/dbus/CMakeLists.txt index d44baab..b91496e 100644 --- a/src/dbus/CMakeLists.txt +++ b/src/dbus/CMakeLists.txt @@ -15,7 +15,7 @@ # @licence end@ ####### -include_directories( +include_directories( ${CMAKE_SOURCE_DIR}/ ${CMAKE_SOURCE_DIR}/include/dlt ${DBUS_INCLUDE_DIRS} @@ -24,7 +24,7 @@ include_directories( set(dlt_dbus_SRCS dlt-dbus.c dlt-dbus-options.c) add_executable(dlt-dbus ${dlt_dbus_SRCS}) target_link_libraries(dlt-dbus dlt ${DBUS_LIBRARIES}) - + set_target_properties(dlt-dbus PROPERTIES LINKER_LANGUAGE C) install(TARGETS dlt-dbus diff --git a/src/dbus/dlt-dbus.conf b/src/dbus/dlt-dbus.conf index 67223f5..1c00880 100644 --- a/src/dbus/dlt-dbus.conf +++ b/src/dbus/dlt-dbus.conf @@ -2,7 +2,7 @@ # ######################################################################## -# General configuration +# General configuration ######################################################################## # The application Id used for DBus Trace (Default: DBUS) diff --git a/src/examples/dlt-example-filetransfer.c b/src/examples/dlt-example-filetransfer.c index 23499ce..a56e09d 100644 --- a/src/examples/dlt-example-filetransfer.c +++ b/src/examples/dlt-example-filetransfer.c @@ -92,8 +92,8 @@ void usage() printf("-a apid - Set application id to apid (default: FLTR)\n"); printf("-c ctid - Set context id to ctid (default: FLTR)\n"); printf("-t ms - Timeout between file packages in ms (minimum 1 ms)\n"); - printf("-d - Flag to delete the file after the transfer (default: false)\n"); - printf("-i - Flag to log file infos to DLT before transfer file (default: false)\n"); + printf("-d - Flag to delete the file after the transfer (default: false)\n"); + printf("-i - Flag to log file infos to DLT before transfer file (default: false)\n"); printf("-h - This help\n"); } @@ -101,13 +101,13 @@ void usage() //!Main program dlt-test-filestransfer starts here int main(int argc, char* argv[]) -{ +{ //char str[MAXSTRLEN]; int opt, timeout; char apid[DLT_ID_SIZE]; char ctid[DLT_ID_SIZE]; - + //char version[255]; int index; int dflag = 0; @@ -172,7 +172,7 @@ int main(int argc, char* argv[]) } } } - + for (index = optind; index < argc; index++) { file = argv[index]; @@ -198,11 +198,11 @@ int main(int argc, char* argv[]) //Register the application at the dlt-daemon DLT_REGISTER_APP(apid,FLTR_APP_DESC); - + //Register the context of the main program at the dlt-daemon DLT_REGISTER_CONTEXT(fileContext,ctid,FLTR_CONTEXT_DESC); - - //More details in corresponding methods + + //More details in corresponding methods if( iflag ) { dlt_user_log_file_infoAbout(&fileContext,file); @@ -212,11 +212,11 @@ int main(int argc, char* argv[]) { printf("File couldn't be transferred. Please check the dlt log messages.\n"); } - + //Unregister the context in which the file transfer happened from the dlt-daemon DLT_UNREGISTER_CONTEXT(fileContext); //Unregister the context of the main program from the dlt-daemon DLT_UNREGISTER_APP(); - + return 0; } diff --git a/src/examples/dlt-example-non-verbose-1.xml b/src/examples/dlt-example-non-verbose-1.xml index 0a49302..e1c34e2 100755 --- a/src/examples/dlt-example-non-verbose-1.xml +++ b/src/examples/dlt-example-non-verbose-1.xml @@ -313,7 +313,7 @@ </fx:MANUFACTURER-EXTENSION> </fx:FRAME> </fx:FRAMES> - + <!--*************************** signals **************************--> <fx:SIGNALS> <!--======================= BOOL =====================--> @@ -388,9 +388,9 @@ </fx:SIGNAL> </fx:SIGNALS> </fx:ELEMENTS> - + <!--********************* PROCESSING INFORMATION *********************--> - + <fx:PROCESSING-INFORMATION> <!--*************************** codings ****************************--> <fx:CODINGS> diff --git a/src/examples/dlt-example-user-common-api.c b/src/examples/dlt-example-user-common-api.c index 061c948..dba4897 100644 --- a/src/examples/dlt-example-user-common-api.c +++ b/src/examples/dlt-example-user-common-api.c @@ -97,7 +97,7 @@ void usage() int main(int argc, char* argv[]) { #ifdef DLT_TEST_ENABLE - int cflag = 0; + int cflag = 0; char *svalue = 0; char *zvalue = 0; #endif /* DLT_TEST_ENABLE */ @@ -112,7 +112,7 @@ int main(int argc, char* argv[]) char *text; int num,maxnum; int delay; - + int state=-1,newstate; opterr = 0; @@ -200,7 +200,7 @@ int main(int argc, char* argv[]) DLT_REGISTER_CONTEXT_APP(mycontext,"TEST","LOG","Test Context for Logging"); text = message; - + if (nvalue) { maxnum = atoi(nvalue); @@ -270,7 +270,7 @@ int main(int argc, char* argv[]) printf("Client connected!\n"); } } - + if (gflag) { /* Non-verbose mode */ diff --git a/src/examples/dlt-example-user.c b/src/examples/dlt-example-user.c index 6d041c3..e428047 100755 --- a/src/examples/dlt-example-user.c +++ b/src/examples/dlt-example-user.c @@ -117,7 +117,7 @@ int main(int argc, char* argv[]) int aflag = 0; int kflag = 0; #ifdef DLT_TEST_ENABLE - int cflag = 0; + int cflag = 0; char *svalue = 0; char *zvalue = 0; #endif /* DLT_TEST_ENABLE */ @@ -133,7 +133,7 @@ int main(int argc, char* argv[]) char *text; int num,maxnum; int delay; - + int state=-1,newstate; opterr = 0; @@ -262,9 +262,9 @@ int main(int argc, char* argv[]) if(mvalue) { printf("Set log mode to %d\n",atoi(mvalue)); - dlt_set_log_mode(atoi(mvalue)); + dlt_set_log_mode(atoi(mvalue)); } - + if (gflag) { @@ -350,7 +350,7 @@ int main(int argc, char* argv[]) printf("Client connected!\n"); } } - + if (gflag) { /* Non-verbose mode */ diff --git a/src/lib/dlt_client_cfg.h b/src/lib/dlt_client_cfg.h index b611681..c2592e6 100755 --- a/src/lib/dlt_client_cfg.h +++ b/src/lib/dlt_client_cfg.h @@ -80,10 +80,10 @@ #define DLT_CLIENT_DUMMY_CON_ID "CC1" /* Size of buffer */ -#define DLT_CLIENT_TEXTBUFSIZE 512 +#define DLT_CLIENT_TEXTBUFSIZE 512 /* Size of receive buffer */ -#define DLT_CLIENT_RCVBUFSIZE 10024 +#define DLT_CLIENT_RCVBUFSIZE 10024 /* Initial baudrate */ #if !defined (__WIN32__) && !defined(_MSC_VER) diff --git a/src/lib/dlt_filetransfer.c b/src/lib/dlt_filetransfer.c index 9b1996f..8dc6e8f 100644 --- a/src/lib/dlt_filetransfer.c +++ b/src/lib/dlt_filetransfer.c @@ -180,7 +180,7 @@ char* getFileCreationDate2(const char* file,int *ok){ */ int isFile (const char* file) { - struct stat st; + struct stat st; return (stat (file, &st) == 0); } @@ -216,7 +216,7 @@ int checkUserBufferForFreeSpace() * @return If the file is successfully deleted, a zero value is returned.If the file can not be deleted a nonzero value is returned. */ int doRemoveFile(const char*filename){ - return remove( filename); + return remove( filename); } void dlt_user_log_file_errorMessage(DltContext *fileContext, const char *filename, int errorCode){ @@ -247,7 +247,7 @@ void dlt_user_log_file_errorMessage(DltContext *fileContext, const char *filenam DLT_INT(package_count), DLT_UINT(BUFFER_SIZE), DLT_STRING("FLER") - ); + ); } else { DLT_LOG(*fileContext,DLT_LOG_ERROR, DLT_STRING("FLER"), @@ -268,7 +268,7 @@ void dlt_user_log_file_errorMessage(DltContext *fileContext, const char *filenam * @return Returns 0 if everything was okey.If there was a failure a value < 0 will be returned. */ int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename){ - + if(isFile(filename)) { int ok; @@ -307,7 +307,7 @@ int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename){ * In the next step some generic informations about the file will be logged to dlt. * Now the header will be logged to dlt. See the method dlt_user_log_file_header for more informations. * Then the method dlt_user_log_data will be called with the parameter to log all packages in a loop with some timeout. - * At last dlt_user_log_end is called to signal that the complete file transfer was okey. This is important for the plugin of the dlt viewer. + * At last dlt_user_log_end is called to signal that the complete file transfer was okey. This is important for the plugin of the dlt viewer. * @param fileContext Specific context to log the file to dlt * @param filename Absolute file path * @param deleteFlag Flag if the file will be deleted after transfer. 1->delete, 0->notDelete @@ -315,28 +315,28 @@ int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename){ * @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned. */ int dlt_user_log_file_complete(DltContext *fileContext, const char *filename, int deleteFlag, int timeout) -{ +{ if(!isFile(filename)) { dlt_user_log_file_errorMessage(fileContext,filename, DLT_FILETRANSFER_ERROR_FILE_COMPLETE); return DLT_FILETRANSFER_ERROR_FILE_COMPLETE; } - + if(dlt_user_log_file_header(fileContext,filename) != 0) { return DLT_FILETRANSFER_ERROR_FILE_COMPLETE1; } - + if(dlt_user_log_file_data(fileContext, filename,DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES,timeout) != 0) { return DLT_FILETRANSFER_ERROR_FILE_COMPLETE2; } - + if(dlt_user_log_file_end(fileContext,filename, deleteFlag) != 0) { return DLT_FILETRANSFER_ERROR_FILE_COMPLETE3; - } - + } + return 0; } @@ -352,7 +352,7 @@ int dlt_user_log_file_complete(DltContext *fileContext, const char *filename, in int dlt_user_log_file_packagesCount(DltContext *fileContext, const char *filename){ int packages; long filesize; - + if(isFile(filename)) { packages = 1; @@ -363,15 +363,15 @@ int dlt_user_log_file_packagesCount(DltContext *fileContext, const char *filenam return -1; } if(filesize < BUFFER_SIZE) - { + { return packages; - } - else + } + else { packages = filesize/BUFFER_SIZE; - + if(filesize%BUFFER_SIZE == 0) - { + { return packages; } else @@ -473,7 +473,7 @@ int dlt_user_log_file_header(DltContext *fileContext,const char *filename){ DLT_STRING(fcreationdate); DLT_UINT(dlt_user_log_file_packagesCount(fileContext,filename)), DLT_UINT(BUFFER_SIZE), - DLT_STRING("FLST") + DLT_STRING("FLST") ); return 0; @@ -497,17 +497,17 @@ int dlt_user_log_file_data(DltContext *fileContext,const char *filename, int pac FILE *file; int pkgNumber; long readBytes; - + if(isFile(filename)) { - + file = fopen (filename,"rb"); if (file == NULL) { dlt_user_log_file_errorMessage(fileContext,filename,DLT_FILETRANSFER_ERROR_FILE_DATA); return DLT_FILETRANSFER_ERROR_FILE_DATA; } - + if( (packageToTransfer != DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES && packageToTransfer > dlt_user_log_file_packagesCount(fileContext,filename)) || packageToTransfer <= 0) { DLT_LOG(*fileContext,DLT_LOG_ERROR, @@ -524,7 +524,7 @@ int dlt_user_log_file_data(DltContext *fileContext,const char *filename, int pac } readBytes = 0; - + if(packageToTransfer != DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES) { // If a single package should be transferred. The user has to check that the free space in the user buffer > 50% @@ -598,16 +598,16 @@ int dlt_user_log_file_data(DltContext *fileContext,const char *filename, int pac doTimeout(timeout); } } - + fclose(file); - + return 0; - + } else { dlt_user_log_file_errorMessage(fileContext,filename,DLT_FILETRANSFER_ERROR_FILE_DATA); return DLT_FILETRANSFER_ERROR_FILE_DATA; } - + } //!Transfer the end of the file as a dlt logs. /**The end of the file must be logged to dlt because the end contains inforamtion about the file serial number. @@ -638,14 +638,14 @@ int dlt_user_log_file_end(DltContext *fileContext,const char *filename,int delet DLT_UINT(fserial), DLT_STRING("FLFI") ); - + if(deleteFlag){ if( doRemoveFile(filename) != 0 ){ dlt_user_log_file_errorMessage(fileContext,filename,DLT_FILETRANSFER_ERROR_FILE_END); return -1; } } - + return 0; }else{ dlt_user_log_file_errorMessage(fileContext,filename,DLT_FILETRANSFER_ERROR_FILE_END); diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index 1a8f274..28c7381 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -185,10 +185,10 @@ int dlt_init(void) /* create and open DLT user FIFO */ snprintf(filename,DLT_USER_MAX_FILENAME_LENGTH,"%s/dlt%d",DLT_USER_DIR,getpid()); - + /* Try to delete existing pipe, ignore result of unlink */ unlink(filename); - + ret=mkfifo(filename, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP ); if (ret==-1) { @@ -219,8 +219,8 @@ int dlt_init(void) dlt_user.dlt_log_handle = open(DLT_USER_FIFO, O_WRONLY | O_NONBLOCK | O_CLOEXEC ); if (dlt_user.dlt_log_handle==-1) { - /* This is a normal usecase. It is OK that the daemon (and thus the FIFO /tmp/dlt) - starts later and some DLT users have already been started before. + /* This is a normal usecase. It is OK that the daemon (and thus the FIFO /tmp/dlt) + starts later and some DLT users have already been started before. Thus it is OK if the FIFO can't be opened. */ snprintf(str,DLT_USER_BUFFER_LENGTH,"FIFO %s cannot be opened. Retrying later...\n",DLT_USER_FIFO); dlt_log(LOG_INFO, str); @@ -232,16 +232,16 @@ int dlt_init(void) /* init shared memory */ if (dlt_shm_init_client(&(dlt_user.dlt_shm),DLT_SHM_KEY) < 0) { - /* This is a normal usecase. It is OK that the daemon (and thus the FIFO /tmp/dlt) - starts later and some DLT users have already been started before. + /* This is a normal usecase. It is OK that the daemon (and thus the FIFO /tmp/dlt) + starts later and some DLT users have already been started before. Thus it is OK if the FIFO can't be opened. */ snprintf(str,DLT_USER_BUFFER_LENGTH,"Shared memory %d cannot be created. Retrying later...\n",DLT_SHM_KEY); dlt_log(LOG_INFO, str); - //return 0; - } + //return 0; + } #endif } - + if (dlt_receiver_init(&(dlt_user.receiver),dlt_user.dlt_user_handle, DLT_USER_RCVBUF_MAX_SIZE)==-1) { @@ -509,7 +509,7 @@ int dlt_user_atexit_blow_out_user_buffer(void){ DLT_SEM_LOCK(); count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer)); DLT_SEM_FREE(); - + if (count > 0) { while(dlt_uptime() < exitTime ) @@ -528,8 +528,8 @@ int dlt_user_atexit_blow_out_user_buffer(void){ dlt_user.overflow_counter=0; } } - } - + } + if (dlt_user.dlt_log_handle != -1) { ret = dlt_user_log_resend_buffer(); @@ -1212,7 +1212,7 @@ int dlt_forward_msg(void *msgdata,size_t size) { snprintf(str,DLT_USER_BUFFER_LENGTH,"Buffer full! %u messages discarded!\n",dlt_user.overflow_counter); dlt_log(LOG_WARNING, str); - dlt_user.overflow_counter=0; + dlt_user.overflow_counter=0; } } @@ -2698,7 +2698,7 @@ int dlt_user_trace_network_segmented(DltContext *handle, DltNetworkTraceType nw_ } free(thread_data->header); free(thread_data->payload); - free(thread_data); + free(thread_data); char str[256]; snprintf(str,255,"NWTSegmented: Could not write into queue: %s \n",strerror(errno)); dlt_log(LOG_WARNING, str); @@ -3440,7 +3440,7 @@ DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype) #ifdef DLT_SHM_ENABLE if(dlt_user.dlt_log_handle!=-1) dlt_shm_push(&dlt_user.dlt_shm,msg.headerbuffer+sizeof(DltStorageHeader), msg.headersize-sizeof(DltStorageHeader), - log->buffer, log->size,0,0); + log->buffer, log->size,0,0); /* log to FIFO */ ret = dlt_user_log_out3(dlt_user.dlt_log_handle, @@ -3463,10 +3463,10 @@ DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype) ret = dlt_user_log_out3(dlt_user.dlt_log_handle, &(userheader), sizeof(DltUserHeader), msg.headerbuffer+sizeof(DltStorageHeader), msg.headersize-sizeof(DltStorageHeader), - log->buffer, log->size); -#endif + log->buffer, log->size); +#endif } - + /* store message in ringbuffer, if an error has occured */ if (ret!=DLT_RETURN_OK) { @@ -4146,7 +4146,7 @@ int dlt_user_log_resend_buffer(void) int num,count; int size; DltReturnValue ret; - + /* Send content of ringbuffer */ DLT_SEM_LOCK(); count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer)); @@ -4160,7 +4160,7 @@ int dlt_user_log_resend_buffer(void) if (size>0) { -#ifdef DLT_SHM_ENABLE +#ifdef DLT_SHM_ENABLE dlt_shm_push(&dlt_user.dlt_shm,dlt_user.resend_buffer+sizeof(DltUserHeader),size-sizeof(DltUserHeader),0,0,0,0); /* log to FIFO */ @@ -4170,21 +4170,21 @@ int dlt_user_log_resend_buffer(void) ret = dlt_user_log_out3(dlt_user.dlt_log_handle, dlt_user.resend_buffer,size,0,0,0,0); #endif - /* in case of error, keep message in ringbuffer */ + /* in case of error, keep message in ringbuffer */ if (ret==DLT_RETURN_OK) { dlt_buffer_remove(&(dlt_user.startup_buffer)); } else { - /* keep message in ringbuffer */ + /* keep message in ringbuffer */ DLT_SEM_FREE(); return -1; } } DLT_SEM_FREE(); } - + return 0; } @@ -4214,8 +4214,8 @@ void dlt_user_log_reattach_to_daemon(void) { snprintf(str,DLT_USER_BUFFER_LENGTH,"Loging disabled, Shared memory %d cannot be created!\n",DLT_SHM_KEY); dlt_log(LOG_WARNING, str); - //return 0; - } + //return 0; + } #endif dlt_log(LOG_NOTICE, "Logging (re-)enabled!\n"); @@ -4306,7 +4306,7 @@ int dlt_user_check_buffer(int *total_size, int *used_size) *total_size = dlt_buffer_get_total_size(&(dlt_user.startup_buffer)); *used_size = dlt_buffer_get_used_size(&(dlt_user.startup_buffer)); #endif - + return 0; /* ok */ } diff --git a/src/lib/dlt_user_cfg.h b/src/lib/dlt_user_cfg.h index 850429e..a8f9d8d 100755 --- a/src/lib/dlt_user_cfg.h +++ b/src/lib/dlt_user_cfg.h @@ -73,9 +73,9 @@ /*************/ /* Size of receive buffer */ -#define DLT_USER_RCVBUF_MAX_SIZE 10024 +#define DLT_USER_RCVBUF_MAX_SIZE 10024 -/* Size of ring buffer */ +/* Size of ring buffer */ #define DLT_USER_RINGBUFFER_MIN_SIZE 50000 #define DLT_USER_RINGBUFFER_MAX_SIZE 500000 #define DLT_USER_RINGBUFFER_STEP_SIZE 50000 @@ -83,7 +83,7 @@ /* Temporary buffer length */ #define DLT_USER_BUFFER_LENGTH 255 -/* Number of context entries, which will be allocated, +/* Number of context entries, which will be allocated, if no more context entries are available */ #define DLT_USER_CONTEXT_ALLOC_SIZE 500 @@ -124,7 +124,7 @@ #define DLT_USER_DEFAULT_MSGID 0xffff /* delay in receiver routine in usec (100000 usec = 100ms) */ -#define DLT_USER_RECEIVE_DELAY 100000 +#define DLT_USER_RECEIVE_DELAY 100000 /* Name of environment variable for local print mode */ #define DLT_USER_ENV_LOCAL_PRINT_MODE "DLT_LOCAL_PRINT_MODE" diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c index 1fa2766..98852fd 100755 --- a/src/shared/dlt_common.c +++ b/src/shared/dlt_common.c @@ -89,7 +89,7 @@ int dlt_buffer_reset(DltBuffer *buf); int dlt_buffer_increase_size(DltBuffer *buf); int dlt_buffer_minimize_size(DltBuffer *buf); void dlt_buffer_write_block(DltBuffer *buf,int *write, const unsigned char *data,unsigned int size); -void dlt_buffer_read_block(DltBuffer *buf,int *read,unsigned char *data,unsigned int size); +void dlt_buffer_read_block(DltBuffer *buf,int *read,unsigned char *data,unsigned int size); void dlt_print_hex(uint8_t *ptr,int size) { @@ -561,7 +561,7 @@ int dlt_filter_find(DltFilter *filter,const char *apid,const char *ctid, int ver /* apid matches, now check for ctid */ if (ctid==0) { - /* check if empty ctid matches */ + /* check if empty ctid matches */ //if (memcmp(filter->ctid[num],"",DLT_ID_SIZE)==0)//coverity complains here about Out-of-bounds access. char empty_ctid[DLT_ID_SIZE]=""; if (memcmp(filter->ctid[num],empty_ctid,DLT_ID_SIZE)==0) @@ -1986,7 +1986,7 @@ void dlt_log_set_filename(const char *filename) void dlt_log_init(int mode) { logging_mode = mode; - + if(logging_mode == DLT_LOG_TO_FILE) { /* internal logging to file */ @@ -2278,7 +2278,7 @@ int dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint buf->min_size = size; buf->max_size = size; buf->step_size = 0; - + // Init pointers head = (DltBufferHead*)buf->shm; head->read = 0; @@ -2289,7 +2289,7 @@ int dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint // clear memory memset(buf->mem,0,buf->size); - + snprintf(str,sizeof(str),"Buffer: Size %d\n",buf->size); dlt_log(LOG_DEBUG, str); @@ -2305,7 +2305,7 @@ int dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char *ptr, uint buf->min_size = size; buf->max_size = size; buf->step_size = 0; - + // Init pointers buf->mem = (unsigned char *)(buf->shm + sizeof(DltBufferHead)); buf->size = buf->min_size - sizeof(DltBufferHead); @@ -2341,7 +2341,7 @@ int dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size dlt_log(LOG_EMERG, str); return -1; } - + // Init pointers head = (DltBufferHead*)buf->shm; head->read = 0; @@ -2352,7 +2352,7 @@ int dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size // clear memory memset(buf->mem,0,buf->size); - + //snprintf(str,sizeof(str),"Buffer: Size %d bytes\n",buf->size); //dlt_log(LOG_INFO, str); @@ -2509,14 +2509,14 @@ int dlt_buffer_minimize_size(DltBuffer *buf) /* free old data */ free(buf->shm); - + /* update data */ buf->shm = new_ptr; buf->mem = new_ptr+sizeof(DltBufferHead); buf->size = buf->min_size - sizeof(DltBufferHead); - /* reset pointers and counters */ - ((int*)(buf->shm))[0] = 0; // pointer to write memory + /* reset pointers and counters */ + ((int*)(buf->shm))[0] = 0; // pointer to write memory ((int*)(buf->shm))[1] = 0; // pointer to read memory ((int*)(buf->shm))[2] = 0; // number of packets @@ -2537,7 +2537,7 @@ int dlt_buffer_reset(DltBuffer *buf) dlt_log(LOG_WARNING,"Buffer: Buffer reset triggered.\n"); /* reset pointers and counters */ - ((int*)(buf->shm))[0] = 0; // pointer to write memory + ((int*)(buf->shm))[0] = 0; // pointer to write memory ((int*)(buf->shm))[1] = 0; // pointer to read memory ((int*)(buf->shm))[2] = 0; // number of packets @@ -2578,17 +2578,17 @@ int dlt_buffer_push3(DltBuffer *buf,const unsigned char *data1,unsigned int size { dlt_log(LOG_ERR,"Buffer: Pointer out of range\n"); dlt_buffer_reset(buf); - return -1; // ERROR + return -1; // ERROR } // calculate free size if(read>write) free_size = read - write; else if(count && (write == read)) - free_size = 0; + free_size = 0; else free_size = buf->size - write + read; - + // check size if(free_size < (int)(sizeof(DltBufferBlockHead)+size1+size2+size3)) { // try to increase size if possible @@ -2649,7 +2649,7 @@ int dlt_buffer_get(DltBuffer *buf,unsigned char *data, int max_size,int delete) { dlt_log(LOG_ERR,"Buffer: Pointer out of range\n"); dlt_buffer_reset(buf); - return -1; // ERROR + return -1; // ERROR } // check if data is in there @@ -2659,13 +2659,13 @@ int dlt_buffer_get(DltBuffer *buf,unsigned char *data, int max_size,int delete) dlt_log(LOG_ERR,"Buffer: SHM should be empty, but is not\n"); dlt_buffer_reset(buf); } - return -1; // ERROR + return -1; // ERROR } // calculate used size if(write>read) used_size = write - read; - else + else used_size = buf->size - read + write; // first check size @@ -2713,29 +2713,29 @@ int dlt_buffer_get(DltBuffer *buf,unsigned char *data, int max_size,int delete) if(delete) { // update buffer pointers - ((int*)(buf->shm))[1] = read; // set new read pointer + ((int*)(buf->shm))[1] = read; // set new read pointer } } else { if(delete) { if( (read+head.size) <= buf->size) - ((int*)(buf->shm))[1] = read+head.size; // set new read pointer + ((int*)(buf->shm))[1] = read+head.size; // set new read pointer else - ((int*)(buf->shm))[1] = read+head.size-buf->size; // set new read pointer + ((int*)(buf->shm))[1] = read+head.size-buf->size; // set new read pointer } } if(delete) { ((int*)(buf->shm))[2] -= 1; // decrease counter - + if(((int*)(buf->shm))[2] == 0) { // try to minimize size dlt_buffer_minimize_size(buf); } } - - return head.size; // OK + + return head.size; // OK } int dlt_buffer_pull(DltBuffer *buf,unsigned char *data, int max_size) @@ -2767,7 +2767,7 @@ void dlt_buffer_info(DltBuffer *buf) dlt_log(LOG_DEBUG, str); snprintf(str,sizeof(str),"Buffer: Buffer start address: %lX\n",(unsigned long)buf->mem); dlt_log(LOG_DEBUG, str); - + } void dlt_buffer_status(DltBuffer *buf) @@ -2822,11 +2822,11 @@ int dlt_buffer_get_used_size(DltBuffer *buf) if(count == 0) return 0; - + if(write>read) return (write - read); - - return (buf->size - read + write); + + return (buf->size - read + write); } int dlt_buffer_get_message_count(DltBuffer *buf) @@ -3119,7 +3119,7 @@ uint32_t dlt_uptime(void) struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC,&ts)==0) - { + { return ( (uint32_t)ts.tv_sec*10000 + (uint32_t)ts.tv_nsec/100000 );// in 0.1 ms = 100 us } else diff --git a/src/shared/dlt_common_cfg.h b/src/shared/dlt_common_cfg.h index 7a34850..2278049 100755 --- a/src/shared/dlt_common_cfg.h +++ b/src/shared/dlt_common_cfg.h @@ -88,7 +88,7 @@ /* Number of indices to be allocated at one, if no more indeces are left */ #define DLT_COMMON_INDEX_ALLOC 1000 -/* If limited output is called, +/* If limited output is called, this is the maximum number of characters to be printed out */ #define DLT_COMMON_ASCII_LIMIT_MAX_CHARS 20 diff --git a/src/shared/dlt_offline_trace.c b/src/shared/dlt_offline_trace.c index 404b4f1..9925a7a 100644 --- a/src/shared/dlt_offline_trace.c +++ b/src/shared/dlt_offline_trace.c @@ -62,7 +62,7 @@ #include <fcntl.h> #include <unistd.h> #include <dirent.h> - + #include <dlt_offline_trace.h> int dlt_offline_trace_create_new_file(DltOfflineTrace *trace) { @@ -90,7 +90,7 @@ int dlt_offline_trace_create_new_file(DltOfflineTrace *trace) { return -1; } /* if */ - return 0; /* OK */ + return 0; /* OK */ } unsigned long dlt_offline_trace_get_total_size(DltOfflineTrace *trace) { @@ -125,9 +125,9 @@ unsigned long dlt_offline_trace_get_total_size(DltOfflineTrace *trace) { } closedir(dir); - + /* return size */ - return size; + return size; } int dlt_offline_trace_delete_oldest_file(DltOfflineTrace *trace) { @@ -164,9 +164,9 @@ int dlt_offline_trace_delete_oldest_file(DltOfflineTrace *trace) { printf("Old offline trace file %s cannot be stat-ed",filename); } } - } + } closedir(dir); - + /* delete file */ if(filename_oldest[0]) { if(remove(filename_oldest)) { @@ -178,13 +178,13 @@ int dlt_offline_trace_delete_oldest_file(DltOfflineTrace *trace) { printf("No file to be removed!\n"); return -1; /* ERROR */ } - + /* return size of deleted file*/ - return size_oldest; + return size_oldest; } int dlt_offline_trace_check_size(DltOfflineTrace *trace) { - + /* check size of complete offline trace */ while((int)dlt_offline_trace_get_total_size(trace) > (trace->maxSize-trace->fileSize)) { @@ -193,10 +193,10 @@ int dlt_offline_trace_check_size(DltOfflineTrace *trace) { return -1; } } - - return 0; /* OK */ + + return 0; /* OK */ } - + int dlt_offline_trace_init(DltOfflineTrace *trace,const char *directory,int fileSize,int maxSize) { /* init parameters */ @@ -222,31 +222,31 @@ int dlt_offline_trace_write(DltOfflineTrace *trace,unsigned char *data1,int size /* close old file */ close(trace->ohandle); trace->ohandle = -1; - + /* check complete offline trace size, remove old logs if needed */ dlt_offline_trace_check_size(trace); - + /* create new file */ dlt_offline_trace_create_new_file(trace); } - + /* write data into log file */ if(data1 && (trace->ohandle >= 0)) { if(write(trace->ohandle,data1,size1)!=size1) { printf("Offline trace write failed!\n"); - return -1; + return -1; } } if(data2 && (trace->ohandle >= 0)) { if(write(trace->ohandle,data2,size2)!=size2) { printf("Offline trace write failed!\n"); - return -1; + return -1; } } if(data3 && (trace->ohandle >= 0)) { if(write(trace->ohandle,data3,size3)!=size3) { printf("Offline trace write failed!\n"); - return -1; + return -1; } } @@ -257,7 +257,7 @@ int dlt_offline_trace_free(DltOfflineTrace *trace) { if(trace->ohandle <= 0) return -1; - + /* close last used log file */ close(trace->ohandle); diff --git a/src/shared/dlt_shm.c b/src/shared/dlt_shm.c index 3286057..d188e2d 100644 --- a/src/shared/dlt_shm.c +++ b/src/shared/dlt_shm.c @@ -87,10 +87,10 @@ void dlt_shm_print_hex(char *ptr,int size) void dlt_shm_pv(int id,int operation) { static struct sembuf semaphor; - + semaphor.sem_op = operation; semaphor.sem_flg = SEM_UNDO; - + if(semop(id, &semaphor,1) == -1) { dlt_log(LOG_WARNING,"SHM: semop() failed"); } @@ -115,14 +115,14 @@ int dlt_shm_init_server(DltShm *buf,int key,int size) { { dlt_log(LOG_WARNING,"SHM: shmctl() failed"); return -1; /* ERROR */ - } + } // Now we attach the segment to our data space. if ((ptr = shmat(buf->shmid, NULL, 0)) == (unsigned char *) -1) { dlt_log(LOG_WARNING,"SHM: shmat() failed"); return -1; /* ERROR */ } - + // Init semaphore if( (buf->semid = semget(DLT_SHM_SEM,1,S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT|IPC_EXCL)) == -1 ) { if( (buf->semid = semget(DLT_SHM_SEM,1,S_IRWXU|S_IRWXG|S_IRWXO|IPC_EXCL)) == -1 ) { @@ -134,7 +134,7 @@ int dlt_shm_init_server(DltShm *buf,int key,int size) { dlt_log(LOG_WARNING,"SHM: semctl() failed"); return -1; /* ERROR */ } - + // init buffer dlt_buffer_init_static_server(&(buf->buffer),ptr,shm_buf.shm_segsz); @@ -160,14 +160,14 @@ int dlt_shm_init_client(DltShm *buf,int key) { { dlt_log(LOG_WARNING,"SHM: shmctl() failed"); return -1; /* ERROR */ - } + } // Now we attach the segment to our data space. if ((ptr = shmat(buf->shmid, NULL, 0)) == (unsigned char *) -1) { dlt_log(LOG_WARNING,"shmat() failed"); return -1; /* ERROR */ } - + // Init semaphore if( (buf->semid = semget(DLT_SHM_SEM,0,0)) == -1 ) { dlt_log(LOG_WARNING,"SHM: semget() failed"); @@ -176,7 +176,7 @@ int dlt_shm_init_client(DltShm *buf,int key) { // init buffer dlt_buffer_init_static_client(&(buf->buffer),ptr,shm_buf.shm_segsz); - + return 0; /* OK */ } @@ -276,7 +276,7 @@ int dlt_shm_remove(DltShm *buf) } int dlt_shm_free_server(DltShm *buf) { - + if(shmdt(buf->buffer.shm)) { dlt_log(LOG_WARNING,"SHM: shmdt() failed"); return -1; /* ERROR */ @@ -297,7 +297,7 @@ int dlt_shm_free_server(DltShm *buf) { buf->semid = 0; return dlt_buffer_free_static(&(buf->buffer)); - + } int dlt_shm_free_client(DltShm *buf) { @@ -310,6 +310,6 @@ int dlt_shm_free_client(DltShm *buf) { // Reset parameters buf->shmid = 0; buf->semid = 0; - + return dlt_buffer_free_static(&(buf->buffer)); } diff --git a/src/system/CMakeLists.txt b/src/system/CMakeLists.txt index fb11624..2213867 100644 --- a/src/system/CMakeLists.txt +++ b/src/system/CMakeLists.txt @@ -19,7 +19,7 @@ if(WITH_SYSTEMD_WATCHDOG OR WITH_SYSTEMD OR WITH_SYSTEMD_JOURNAL) message( STATUS "Added ${systemd_SRCS} to dlt-system") endif(WITH_SYSTEMD_WATCHDOG OR WITH_SYSTEMD OR WITH_SYSTEMD_JOURNAL) -set(dlt_system_SRCS dlt-system.c dlt-system-options.c dlt-system-process-handling.c +set(dlt_system_SRCS dlt-system.c dlt-system-options.c dlt-system-process-handling.c dlt-system-filetransfer.c dlt-system-logfile.c dlt-system-processes.c dlt-system-shell.c dlt-system-syslog.c dlt-system-watchdog.c dlt-system-journal.c) add_executable(dlt-system ${dlt_system_SRCS} ${systemd_SRCS}) @@ -28,7 +28,7 @@ if(WITH_SYSTEMD_JOURNAL) else(WITH_SYSTEMD_JOURNAL) target_link_libraries(dlt-system dlt ${ZLIB_LIBRARIES}) endif(WITH_SYSTEMD_JOURNAL) - + set_target_properties(dlt-system PROPERTIES LINKER_LANGUAGE C) diff --git a/src/system/dlt-system-journal.c b/src/system/dlt-system-journal.c index 7cccb4b..03c785c 100644 --- a/src/system/dlt-system-journal.c +++ b/src/system/dlt-system-journal.c @@ -150,7 +150,7 @@ void journal_thread(void *v_conf) buffer_transport[DLT_SYSTEM_JOURNAL_BUFFER_SIZE]; int loglevel,systemd_loglevel; char* systemd_log_levels[] = { "Emergency","Alert","Critical","Error","Warning","Notice","Informational","Debug" }; - + DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("dlt-system-journal, in thread.")); @@ -158,14 +158,14 @@ void journal_thread(void *v_conf) DLT_REGISTER_CONTEXT(journalContext, conf->Journal.ContextId, "Journal Adapter"); r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY/*SD_JOURNAL_LOCAL_ONLY|SD_JOURNAL_RUNTIME_ONLY*/); - printf("journal open return %d\n", r); + printf("journal open return %d\n", r); if (r < 0) { DLT_LOG(dltsystem, DLT_LOG_ERROR, DLT_STRING("dlt-system-journal, cannot open journal:"),DLT_STRING(strerror(-r))); printf("journal open failed: %s\n", strerror(-r)); return; } - + if(conf->Journal.CurrentBoot) { /* show only current boot entries */ @@ -176,7 +176,7 @@ void journal_thread(void *v_conf) DLT_STRING("dlt-system-journal failed to get boot id:"),DLT_STRING(strerror(-r))); sd_journal_close(j); return; - + } sd_id128_to_string(boot_id, match + 9); r = sd_journal_add_match(j,match,strlen(match)); @@ -186,9 +186,9 @@ void journal_thread(void *v_conf) DLT_STRING("dlt-system-journal failed to get match:"),DLT_STRING(strerror(-r))); sd_journal_close(j); return; - + } - } + } if(conf->Journal.Follow) { @@ -200,7 +200,7 @@ void journal_thread(void *v_conf) DLT_STRING("dlt-system-journal failed to seek to tail:"),DLT_STRING(strerror(-r))); sd_journal_close(j); return; - + } r = sd_journal_previous_skip(j, 10); if(r<0) @@ -209,13 +209,13 @@ void journal_thread(void *v_conf) DLT_STRING("dlt-system-journal failed to seek back 10 entries:"),DLT_STRING(strerror(-r))); sd_journal_close(j); return; - + } - + } - + while(!threads.shutdown) - { + { r = sd_journal_next(j); if(r<0) @@ -224,7 +224,7 @@ void journal_thread(void *v_conf) DLT_STRING("dlt-system-journal failed to get next entry:"),DLT_STRING(strerror(-r))); sd_journal_close(j); return; - + } else if(r>0) { @@ -236,7 +236,7 @@ void journal_thread(void *v_conf) DLT_STRING("dlt-system-journal failed to call sd_journal_get_realtime_usec(): "),DLT_STRING(strerror(-r))); sd_journal_close(j); return; - + } /* get data from journal entry, empty string if invalid fields */ @@ -287,12 +287,12 @@ void journal_thread(void *v_conf) loglevel = DLT_LOG_INFO; break; } - } + } if(systemd_loglevel>=0 && systemd_loglevel<=7) snprintf(buffer_priority,DLT_SYSTEM_JOURNAL_BUFFER_SIZE,"%s:",systemd_log_levels[systemd_loglevel]); else snprintf(buffer_priority,DLT_SYSTEM_JOURNAL_BUFFER_SIZE,"prio_unknown:"); - + /* write log entry */ DLT_LOG(journalContext, loglevel, DLT_STRING(buffer_time),DLT_STRING(buffer_process),DLT_STRING(buffer_priority),DLT_STRING(buffer_message)); @@ -300,17 +300,17 @@ void journal_thread(void *v_conf) } else { - r = sd_journal_wait(j,1000000); + r = sd_journal_wait(j,1000000); if(r<0) { DLT_LOG(dltsystem, DLT_LOG_ERROR, DLT_STRING("dlt-system-journal failed to call sd_journal_get_realtime_usec(): "),DLT_STRING(strerror(-r))); sd_journal_close(j); return; - + } } - + if(journal_checkUserBufferForFreeSpace()==-1) { // buffer is nearly full diff --git a/src/system/dlt-system-shell.c b/src/system/dlt-system-shell.c index a235fde..8dce12e 100644 --- a/src/system/dlt-system-shell.c +++ b/src/system/dlt-system-shell.c @@ -67,7 +67,7 @@ DLT_DECLARE_CONTEXT(shellContext) int dlt_shell_injection_callback(uint32_t service_id, void *data, uint32_t length) { (void) length; - + DLT_LOG(shellContext,DLT_LOG_DEBUG, DLT_STRING("dlt-system-shell, injection callback")); char text[DLT_SHELL_COMMAND_MAX_LENGTH]; @@ -76,14 +76,14 @@ int dlt_shell_injection_callback(uint32_t service_id, void *data, uint32_t lengt if(length<=DLT_SHELL_COMMAND_MAX_LENGTH-1) { strncpy(text,data,length); - text[length] = 0; + text[length] = 0; } else { strncpy(text,data,DLT_SHELL_COMMAND_MAX_LENGTH-1); - text[DLT_SHELL_COMMAND_MAX_LENGTH-1] = 0; + text[DLT_SHELL_COMMAND_MAX_LENGTH-1] = 0; } - + DLT_LOG(shellContext,DLT_LOG_DEBUG, DLT_STRING("dlt-system-shell, injection injection id:"), DLT_UINT32(service_id)); @@ -105,7 +105,7 @@ int dlt_shell_injection_callback(uint32_t service_id, void *data, uint32_t lengt { DLT_LOG(shellContext,DLT_LOG_INFO, DLT_STRING("Shell command executed:"), - DLT_STRING(text)); + DLT_STRING(text)); } break; default: diff --git a/src/system/dlt-system.conf b/src/system/dlt-system.conf index 7d5b0c0..1097b2c 100644 --- a/src/system/dlt-system.conf +++ b/src/system/dlt-system.conf @@ -2,14 +2,14 @@ # ######################################################################## -# General configuration +# General configuration ######################################################################## # The application Id used for the System manager (Default: SYS) ApplicationId = SYS ######################################################################## -# Shell configuration +# Shell configuration ######################################################################## # Be careful when you enable this feature. The user can send any kind of @@ -20,7 +20,7 @@ ApplicationId = SYS ShellEnable = 0 ######################################################################## -# Syslog Adapter configuration +# Syslog Adapter configuration ######################################################################## # Enable the Syslog Adapter (Default: 0) @@ -33,7 +33,7 @@ SyslogContextId = SYSL SyslogPort = 47111 ######################################################################## -# Systemd Journal Adapter configuration +# Systemd Journal Adapter configuration ######################################################################## # This feature is only available, when dlt is compiled with @@ -70,7 +70,7 @@ JournalFollow = 0 JournalMapLogLevels = 1 ######################################################################## -# Filetransfer Manager +# Filetransfer Manager ######################################################################## # Enable the Filetransfer (Default: 0) @@ -111,7 +111,7 @@ FiletransferCompressionLevel = 5 ######################################################################## -# Log short files, especially from proc filesystem +# Log short files, especially from proc filesystem ######################################################################## # Enable the logging of files (Default: 0) @@ -170,7 +170,7 @@ LogFileContextId = STAT # LogFileContextId = IOM ######################################################################## -# Log Processes +# Log Processes ######################################################################## # Enable the logging of processes (Default: 0) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index b1052ca..557e403 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -55,7 +55,7 @@ add_executable(dlt-test-filetransfer ${dlt_test_filetransfer_SRCS}) target_link_libraries(dlt-test-filetransfer dlt) set_target_properties(dlt-test-filetransfer PROPERTIES LINKER_LANGUAGE C) -install(TARGETS dlt-test-multi-process dlt-test-multi-process-client dlt-test-user dlt-test-client dlt-test-stress-user dlt-test-stress-client dlt-test-stress dlt-test-filetransfer +install(TARGETS dlt-test-multi-process dlt-test-multi-process-client dlt-test-user dlt-test-client dlt-test-stress-user dlt-test-stress-client dlt-test-stress dlt-test-filetransfer RUNTIME DESTINATION bin COMPONENT base) diff --git a/src/tests/dlt-test-filetransfer-image.png b/src/tests/dlt-test-filetransfer-image.png Binary files differindex dbc570e..dac59d3 100755 --- a/src/tests/dlt-test-filetransfer-image.png +++ b/src/tests/dlt-test-filetransfer-image.png diff --git a/src/tests/dlt-test-filetransfer.c b/src/tests/dlt-test-filetransfer.c index 6374b2d..46a6845 100644 --- a/src/tests/dlt-test-filetransfer.c +++ b/src/tests/dlt-test-filetransfer.c @@ -108,7 +108,7 @@ int testFile1Run1(){ //Just some log to the main context DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF1P1 - dlt_user_log_file_complete"),DLT_STRING(file1)); - //Here's the line where the dlt file transfer is called. The method call needs a context, the absolute file path, will the file be deleted after transfer and the timeout between the packages + //Here's the line where the dlt file transfer is called. The method call needs a context, the absolute file path, will the file be deleted after transfer and the timeout between the packages transferResult = dlt_user_log_file_complete(&fileContext,file1,0,20); if(transferResult < 0 ) { @@ -117,16 +117,16 @@ int testFile1Run1(){ } //Just some log to the main context DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Finished testF1P1"),DLT_STRING(file1)); - + printTestResultPositiveExpected(__FUNCTION__,transferResult); return transferResult; } -//!Test the file transfer with the condition that the transferred file is smaller as the file transfer buffer using single package transfer +//!Test the file transfer with the condition that the transferred file is smaller as the file transfer buffer using single package transfer int testFile1Run2(){ int total_size, used_size; - + //Get the information how many packages have the file countPackages = dlt_user_log_file_packagesCount(&fileContext,file1); if(countPackages < 0 ) @@ -137,8 +137,8 @@ int testFile1Run2(){ } //Just some log to the main context DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF1P2 - transfer single package"),DLT_STRING(file1)); - - //Logs the header of the file transfer. For more details see Mainpage.c. + + //Logs the header of the file transfer. For more details see Mainpage.c. //The header gives information about the file serial number, filename (with absolute path), filesize, packages of file, buffer size transferResult = dlt_user_log_file_header(&fileContext,file1); if(transferResult >= 0) @@ -154,7 +154,7 @@ int testFile1Run2(){ break; } - //Logs one single package to the file context + //Logs one single package to the file context transferResult = dlt_user_log_file_data(&fileContext,file1,i,20); if(transferResult < 0) { @@ -165,7 +165,7 @@ int testFile1Run2(){ } //Logs the end of the file transfer. For more details see Mainpage.c - //The end gives just information about the file serial number but is needed to signal that the file transfer has correctly finished and needed for the file transfer plugin of the dlt viewer. + //The end gives just information about the file serial number but is needed to signal that the file transfer has correctly finished and needed for the file transfer plugin of the dlt viewer. transferResult = dlt_user_log_file_end(&fileContext,file1,0); if(transferResult < 0) { @@ -180,7 +180,7 @@ int testFile1Run2(){ printTestResultPositiveExpected(__FUNCTION__,transferResult); return transferResult; } - + //Just some log to main context DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Finished testF1P2 - transfer single package"),DLT_STRING(file1)); printTestResultPositiveExpected(__FUNCTION__,transferResult); @@ -208,7 +208,7 @@ int testFile2Run1(){ //!Test the file transfer with the condition that the transferred file is bigger as the file transfer buffer using single package transfer int testFile2Run2(){ int total_size, used_size; - + //Get the information how many packages have the file countPackages = dlt_user_log_file_packagesCount(&fileContext,file2); if(countPackages < 0 ) @@ -217,16 +217,16 @@ int testFile2Run2(){ printTestResultPositiveExpected(__FUNCTION__,countPackages); return -1; } - + //Just some log to the main context DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF2P2 - transfer single package"),DLT_STRING(file2)); - - //Logs the header of the file transfer. For more details see Mainpage.c. + + //Logs the header of the file transfer. For more details see Mainpage.c. //The header gives information about the file serial number, filename (with absolute path), filesize, packages of file, buffer size transferResult = dlt_user_log_file_header(&fileContext,file2); if( transferResult >= 0){ - - //Loop to log all packages + + //Loop to log all packages for(i=1;i<=countPackages;i++) { dlt_user_check_buffer(&total_size, &used_size); @@ -271,7 +271,7 @@ int testFile2Run2(){ //!Test the file transfer with the condition that the transferred file does not exist using dlt_user_log_file_complete. int testFile3Run1(){ - + //Just some log to the main context DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF3P1"),DLT_STRING(file3_1)); @@ -307,13 +307,13 @@ int testFile3Run2(){ } //Just some log to the main context DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF3P1"),DLT_STRING(file3_2)); - - //Logs the header of the file transfer. For more details see Mainpage.c. + + //Logs the header of the file transfer. For more details see Mainpage.c. //The header gives information about the file serial number, filename (with absolute path), filesize, packages of file, buffer size transferResult = dlt_user_log_file_header(&fileContext,file3_2); if( transferResult >= 0){ - - //Loop to log all packages + + //Loop to log all packages for(i=1;i<=countPackages;i++) { //Logs one single package to the file context @@ -343,10 +343,10 @@ int testFile3Run2(){ //!Logs some information about the file. int testFile3Run3(){ - + //Just some log to the main context DLT_LOG(mainContext,DLT_LOG_INFO,DLT_STRING("Started testF3P2"),DLT_STRING(file3_3)); - + //Here's the line where the dlt file file info is called. The method call logs some information to dlt about the file, filesize, file serial number and number of packages transferResult = dlt_user_log_file_infoAbout(&fileContext,file3_3); if(transferResult < 0) diff --git a/src/tests/dlt-test-multi-process.c b/src/tests/dlt-test-multi-process.c index 53dbffb..93fd069 100755 --- a/src/tests/dlt-test-multi-process.c +++ b/src/tests/dlt-test-multi-process.c @@ -207,7 +207,7 @@ int main(int argc, char **argv) if(signal(SIGTERM, quit_handler) == SIG_IGN) signal(SIGTERM, SIG_IGN); // kill (nice) - printf("Setup done. Listening. My pid: %d\n", getpid()); + printf("Setup done. Listening. My pid: %d\n", getpid()); fflush(stdout); int err = wait_for_death(); diff --git a/src/tests/dlt-test-stress-client.c b/src/tests/dlt-test-stress-client.c index 36044d0..28c2c9e 100644 --- a/src/tests/dlt-test-stress-client.c +++ b/src/tests/dlt-test-stress-client.c @@ -116,14 +116,14 @@ typedef struct int tests_failed; int sock; - + // test values unsigned long bytes_received; unsigned long time_elapsed; int last_value; int count_received_messages; int count_not_received_messages; - + } DltTestclientData; /** @@ -489,14 +489,14 @@ int dlt_testclient_message_callback(DltMessage *message, void *data) DLT_MSG_READ_VALUE(value_tmp,ptr,datalength,int32_t); value=DLT_ENDIAN_GET_32(message->standardheader->htyp, value_tmp); //printf("%d\n",value); - + if(value < dltdata->last_value) { - if(dltdata->nvalue == dltdata->count_received_messages) - printf("PASSED: %d Msg received, %d not received\n",dltdata->count_received_messages,dltdata->count_not_received_messages); + if(dltdata->nvalue == dltdata->count_received_messages) + printf("PASSED: %d Msg received, %d not received\n",dltdata->count_received_messages,dltdata->count_not_received_messages); else printf("FAILED: %d Msg received, %d not received\n",dltdata->count_received_messages,dltdata->count_not_received_messages); - + dltdata->last_value = 0; dltdata->count_received_messages = 0; dltdata->count_not_received_messages = value -1; diff --git a/src/tests/dlt-test-stress-user.c b/src/tests/dlt-test-stress-user.c index 6a6f4a6..355f510 100644 --- a/src/tests/dlt-test-stress-user.c +++ b/src/tests/dlt-test-stress-user.c @@ -245,7 +245,7 @@ int testall(int count,int repeat,int delay,int size) { buffer[num] = num; } - + /* Test All: Test all start */ //printf("Test1: Test all\n"); //DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test1: Test all")); @@ -258,11 +258,11 @@ int testall(int count,int repeat,int delay,int size) usleep(delay); } } - + /* wait 5 seconds after test */ //sleep(5); //DLT_LOG(context_info,DLT_LOG_INFO,DLT_STRING("Test1: finished")); - + return 0; } |