summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--automotive-dlt.spec.in1
-rw-r--r--include/dlt/dlt_user.h9
-rw-r--r--include/dlt/dlt_user_macros.h28
-rw-r--r--src/lib/CMakeLists.txt2
-rw-r--r--src/lib/dlt_user.c3
-rw-r--r--src/shared/dlt_queue.c172
-rw-r--r--src/shared/dlt_queue.h142
-rw-r--r--src/tests/CMakeLists.txt7
-rw-r--r--src/tests/dlt-test-queue.c94
9 files changed, 36 insertions, 422 deletions
diff --git a/automotive-dlt.spec.in b/automotive-dlt.spec.in
index c9f6763..7dea8b3 100644
--- a/automotive-dlt.spec.in
+++ b/automotive-dlt.spec.in
@@ -98,7 +98,6 @@ rm -rf $RPM_BUILD_ROOT
%{_bindir}/dlt-test-filetransfer
%{_bindir}/dlt-test-multi-process
%{_bindir}/dlt-test-multi-process-client
-%{_bindir}/dlt-test-queue
%attr(0755,root,root)
%{_bindir}/dlt-daemon
diff --git a/include/dlt/dlt_user.h b/include/dlt/dlt_user.h
index 60d163f..cfbd2d8 100644
--- a/include/dlt/dlt_user.h
+++ b/include/dlt/dlt_user.h
@@ -364,8 +364,8 @@ int dlt_user_log_write_raw(DltContextData *log,void *data,uint16_t length);
int dlt_user_trace_network(DltContext *handle, DltNetworkTraceType nw_trace_type, uint16_t header_len, void *header, uint16_t payload_len, void *payload);
/**
- * Trace network message, truncated if necessary
- * @param handle pointer to an object containing information about one special logging context
+ * Trace network message, truncated if necessary.
+ * @param handle pointer to an object containing information about logging context
* @param nw_trace_type type of network trace (DLT_NW_TRACE_IPC, DLT_NW_TRACE_CAN, DLT_NW_TRACE_FLEXRAY, or DLT_NW_TRACE_MOST)
* @param header_len length of network message header
* @param header pointer to network message header
@@ -379,7 +379,9 @@ int dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTraceType nw_
/**
* Trace network message in segmented asynchronous mode.
* The sending of the data is done in a separate thread.
- * @param handle pointer to an object containing information about one special logging context
+ * Please note that handle must exist for the lifetime of the application, because
+ * data chunks are sent asynchronously in undetermined future time.
+ * @param handle pointer to an object containing information about logging context
* @param nw_trace_type type of network trace (DLT_NW_TRACE_IPC, DLT_NW_TRACE_CAN, DLT_NW_TRACE_FLEXRAY, or DLT_NW_TRACE_MOST)
* @param header_len length of network message header
* @param header pointer to network message header
@@ -597,6 +599,7 @@ int dlt_log_uint(DltContext *handle,DltLogLevelType loglevel, unsigned int data)
*/
int dlt_log_raw(DltContext *handle,DltLogLevelType loglevel, void *data,uint16_t length);
+
/**
* Forward a complete DLT message to the DLT daemon
* @param msgdata Message data of DLT message
diff --git a/include/dlt/dlt_user_macros.h b/include/dlt/dlt_user_macros.h
index d3d6f42..20f605d 100644
--- a/include/dlt/dlt_user_macros.h
+++ b/include/dlt/dlt_user_macros.h
@@ -289,6 +289,34 @@ extern DltContext CONTEXT;
}while(0)
/**
+ * Trace network message, allow truncation
+ * @param CONTEXT object containing information about one special logging context
+ * @param TYPE type of network trace message
+ * @param HEADERLEN length of network message header
+ * @param HEADER pointer to network message header
+ * @param PAYLOADLEN length of network message payload
+ * @param PAYLOAD pointer to network message payload
+ */
+#define DLT_TRACE_NETWORK_TRUNCATED(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \
+ do { \
+ dlt_user_trace_network_truncated(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD, 1); \
+ }while(0)
+
+/**
+ * Trace network message, segment large messages
+ * @param CONTEXT object containing information about one special logging context
+ * @param TYPE type of network trace message
+ * @param HEADERLEN length of network message header
+ * @param HEADER pointer to network message header
+ * @param PAYLOADLEN length of network message payload
+ * @param PAYLOAD pointer to network message payload
+ */
+#define DLT_TRACE_NETWORK_SEGMENTED(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \
+ do { \
+ dlt_user_trace_network_segmented(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \
+ }while(0)
+
+/**
* Send log message with string parameter.
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index bd0e4df..cceccd2 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -14,7 +14,7 @@
# @licence end@
########q
-set(dlt_LIB_SRCS dlt_user dlt_client dlt_filetransfer ${CMAKE_SOURCE_DIR}/src/shared/dlt_queue.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_common.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_user_shared.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_shm.c)
+set(dlt_LIB_SRCS dlt_user dlt_client dlt_filetransfer ${CMAKE_SOURCE_DIR}/src/shared/dlt_common.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_user_shared.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_shm.c)
add_library(dlt ${dlt_LIB_SRCS})
target_link_libraries(dlt rt ${CMAKE_THREAD_LIBS_INIT})
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index 92c1233..da30734 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -88,7 +88,6 @@
#include "dlt_user_shared.h"
#include "dlt_user_shared_cfg.h"
#include "dlt_user_cfg.h"
-#include "dlt_queue.h"
static DltUser dlt_user;
static int dlt_user_initialised = 0;
@@ -114,8 +113,6 @@ typedef struct {
void *payload;
} s_segmented_data;
-dlt_queue *dlt_segmented_nwt_queue;
-
/* Function prototypes for internally used functions */
static void dlt_user_receiverthread_function(void *ptr);
static void dlt_user_atexit_handler(void);
diff --git a/src/shared/dlt_queue.c b/src/shared/dlt_queue.c
deleted file mode 100644
index b9b4855..0000000
--- a/src/shared/dlt_queue.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * @licence app begin@
- * Copyright (C) 2012 BMW AG
- *
- * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Lassi Marttala <lassi.lm.marttala@partner.bmw.de> BMW 2012
- *
- * \file dlt_queue.h
- * For further information see http://www.genivi.org/.
- * @licence end@
- */
-
-
-/*******************************************************************************
-** **
-** SRC-MODULE: dlt_queue.h **
-** **
-** TARGET : linux **
-** **
-** PROJECT : DLT **
-** **
-** AUTHOR : Lassi Marttala <lassi.lm.marttala@partner.bmw.de> **
-** **
-** PURPOSE : Linked list based dynamic queue **
-** **
-** REMARKS : **
-** **
-** PLATFORM DEPENDANT [yes/no]: no **
-** **
-** TO BE CHANGED BY USER [yes/no]: no **
-** **
-*******************************************************************************/
-
-/*******************************************************************************
-** Author Identity **
-********************************************************************************
-** **
-** Initials Name Company **
-** -------- ------------------------- ---------------------------------- **
-** lm Lassi Marttala Eureka GmbH **
-*******************************************************************************/
-#include <stdlib.h>
-#include <semaphore.h>
-
-#include "dlt_queue.h"
-
-// Thread safety
-static sem_t dlt_queue_mutex;
-#define DLT_QUEUE_SEM_LOCK() { sem_wait(&dlt_queue_mutex); }
-#define DLT_QUEUE_SEM_FREE() { sem_post(&dlt_queue_mutex); }
-
-dlt_queue_item *dlt_queue_create_item()
-{
- dlt_queue_item *item = malloc(sizeof(dlt_queue_item));
- item->item = NULL;
- item->item_size = 0;
- item->next_item = NULL;
- return item;
-}
-
-void dlt_queue_free_item(dlt_queue_item *item)
-{
- if(item != NULL)
- {
- free(item);
- item = NULL;
- }
-}
-
-dlt_queue *dlt_queue_create()
-{
- static int init_done = 0;
- if(!init_done)
- {
- init_done = 1;
- sem_init(&dlt_queue_mutex, 0, 1);
- }
- return (dlt_queue *)malloc(sizeof(dlt_queue));
-}
-
-void dlt_queue_free(dlt_queue *queue)
-{
- if(queue != NULL)
- {
- free(queue);
- queue = NULL;
- }
-}
-
-void dlt_queue_push(dlt_queue_item *item, dlt_queue *queue)
-{
- DLT_QUEUE_SEM_LOCK()
- item->next_item = NULL;
- // Empty queue
- if(dlt_queue_is_empty(queue))
- {
- queue->head = item;
- queue->tail = item;
- }
- // Exactly one item
- else if(queue->head == queue->tail)
- {
- queue->head->next_item = (struct dlt_queue_item *)item;
- queue->tail = item;
- }
- // Default case
- else
- {
- queue->tail->next_item = (struct dlt_queue_item *)item;
- queue->tail = item;
- }
- DLT_QUEUE_SEM_FREE()
-}
-
-dlt_queue_item *dlt_queue_pop(dlt_queue *queue)
-{
- DLT_QUEUE_SEM_LOCK()
- dlt_queue_item *retval = NULL;
- // Empty queue
- if(dlt_queue_is_empty(queue))
- {
- retval = NULL;
- }
- // Exactly one item
- else if(queue->head == queue->tail)
- {
- retval = queue->head;
- retval->next_item = NULL;
- queue->head = NULL;
- queue->tail = NULL;
- }
- // Default case
- else
- {
- retval = queue->head;
- queue->head = (dlt_queue_item *)retval->next_item;
- retval->next_item = NULL;
- }
- DLT_QUEUE_SEM_FREE()
- return retval;
-}
-
-int dlt_queue_is_empty(dlt_queue *queue)
-{
- if(queue->head == NULL && queue->tail == NULL)
- return 1;
- return 0;
-}
-
-int dlt_queue_item_count(dlt_queue *queue)
-{
- DLT_QUEUE_SEM_LOCK()
- int retval = 0;
- dlt_queue_item *ptr = queue->head;
- while(ptr != NULL)
- {
- ptr = (dlt_queue_item *) ptr->next_item;
- retval++;
- }
- DLT_QUEUE_SEM_FREE()
- return retval;
-}
diff --git a/src/shared/dlt_queue.h b/src/shared/dlt_queue.h
deleted file mode 100644
index 40eda03..0000000
--- a/src/shared/dlt_queue.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * @licence app begin@
- * Copyright (C) 2012 BMW AG
- *
- * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Lassi Marttala <lassi.lm.marttala@partner.bmw.de> BMW 2012
- *
- * \file dlt_common_cfg.h
- * For further information see http://www.genivi.org/.
- * @licence end@
- */
-
-
-/*******************************************************************************
-** **
-** SRC-MODULE: dlt_queue.h **
-** **
-** TARGET : linux **
-** **
-** PROJECT : DLT **
-** **
-** AUTHOR : Lassi Marttala <lassi.lm.marttala@partner.bmw.de> **
-** **
-** PURPOSE : Linked list based dynamic queue **
-** **
-** REMARKS : **
-** **
-** PLATFORM DEPENDANT [yes/no]: no **
-** **
-** TO BE CHANGED BY USER [yes/no]: no **
-** **
-*******************************************************************************/
-
-/*******************************************************************************
-** Author Identity **
-********************************************************************************
-** **
-** Initials Name Company **
-** -------- ------------------------- ---------------------------------- **
-** lm Lassi Marttala Eureka GmbH **
-*******************************************************************************/
-#ifndef __DLT_QUEUE_H_
-#define __DLT_QUEUE_H_
-#include <stdint.h>
-
-/**
- * \brief One item in the linked list
- */
-typedef struct {
- void *item;
- uint16_t item_size;
- struct dlt_queue_item *next_item;
-}dlt_queue_item;
-
-/**
- * \brief Linked list of items
- */
-typedef struct {
- dlt_queue_item *head;
- dlt_queue_item *tail;
-} dlt_queue;
-
-/**
- * \brief Create new empty queue item
- * Allocates a new item and returns a pointer to it
- * @return Pointer to the new item
- */
-dlt_queue_item *dlt_queue_create_item();
-
-/**
- * \brief Free an queue item
- * Frees the memory of the queue item
- * @param item Pointer to the item to be freed
- */
-void dlt_queue_free_item(dlt_queue_item *item);
-
-/**
- * \brief Create a new empty queue
- * Queue is created with no items in it.
- * User is responsible for calling dlt_queue_free after
- * the queue is not needed anymore.
- * @return New allocated queue
- */
-dlt_queue *dlt_queue_create();
-
-/**
- * \brief Delete a queue
- * Free the memory of the queue structure.
- * Queued items are NOT freed. User must first pop all the items
- * to remove the from queue and fere their memory themself.
- * @param queue the queue to be freed
- */
-void dlt_queue_free(dlt_queue *queue);
-
-/**
- * \brief Push an item to the end of the queue
- * Add a new item to the queue. It is now the new tail item.
- * Queue does not take ownership of the item. User still must
- * handle the freeing of the memory.
- * @param item New item to add to the queue
- * @param queue Queue to add the item to.
- */
-void dlt_queue_push(dlt_queue_item *item, dlt_queue *queue);
-
-/**
- * \brief Pop an item from the head of the queue
- * Remove an item from the head of the queue and return it.
- * @param queue Queue to pop from
- * @return Pointer to the popped item
- */
-dlt_queue_item *dlt_queue_pop(dlt_queue *queue);
-
-/**
- * \brief Checks if the queue is empty
- * Checks if the head and and tail are null pointers
- * and returns the result.
- * @param queue Queue to check
- * @return 1 if queue is empty, 0 if not.
- */
-int dlt_queue_is_empty(dlt_queue *queue);
-
-/**
- * \brief Counts the items in the queue
- * Walks the item chain and reports the number of items in
- * the queue. If you only need to know if there are items
- * or not, please use dlt_queue_is_empty, which is cheaper
- * than counting the items.
- * @param queue Queue to check
- * @return number of items.
- */
-int dlt_queue_item_count(dlt_queue *queue);
-#endif
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index e91ab58..b84bec9 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -13,11 +13,6 @@
#
# @licence end@
########
-set(dlt_test_queue_SRCS dlt-test-queue)
-add_executable(dlt-test-queue ${dlt_test_queue_SRCS})
-target_link_libraries(dlt-test-queue dlt)
-set_target_properties(dlt-test-queue PROPERTIES LINKER_LANGUAGE C)
-
set(dlt_test_multi_process_SRCS dlt-test-multi-process)
add_executable(dlt-test-multi-process ${dlt_test_multi_process_SRCS})
target_link_libraries(dlt-test-multi-process dlt)
@@ -58,7 +53,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-queue 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-queue.c b/src/tests/dlt-test-queue.c
deleted file mode 100644
index 774ea8f..0000000
--- a/src/tests/dlt-test-queue.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * @licence app begin@
- * Copyright (C) 2012 BMW AG
- *
- * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Lassi Marttala <lassi.lm.marttala@partner.bmw.de> BMW 2012
- *
- * \file dlt-test-queue.h
- * For further information see http://www.genivi.org/.
- * @licence end@
- */
-
-
-/*******************************************************************************
-** **
-** SRC-MODULE: dlt_queue.h **
-** **
-** TARGET : linux **
-** **
-** PROJECT : DLT **
-** **
-** AUTHOR : Lassi Marttala <lassi.lm.marttala@partner.bmw.de> **
-** **
-** PURPOSE : Test for queue implementation **
-** **
-** REMARKS : **
-** **
-** PLATFORM DEPENDANT [yes/no]: no **
-** **
-** TO BE CHANGED BY USER [yes/no]: no **
-** **
-*******************************************************************************/
-
-/*******************************************************************************
-** Author Identity **
-********************************************************************************
-** **
-** Initials Name Company **
-** -------- ------------------------- ---------------------------------- **
-** lm Lassi Marttala Eureka GmbH **
-*******************************************************************************/
-
-#include "dlt_queue.h"
-#include <stdio.h>
-#include <string.h>
-
-int main(void)
-{
- char *item_content = "item_content\n";
- int item_len = strlen(item_content) + 1;
- dlt_queue *queue = dlt_queue_create();
- printf("#1\tdlt_queue_is_empty returns\t%d\n", dlt_queue_is_empty(queue));
-
- dlt_queue_item *first = dlt_queue_create_item();
- first->item = item_content;
- first->item_size = item_len;
- dlt_queue_push(first, queue);
-
- printf("#2\tdlt_queue_is_empty returns\t%d\n", dlt_queue_is_empty(queue));
- printf("#3\tdlt_queue_item_count returns\t%d\n", dlt_queue_item_count(queue));
-
- dlt_queue_item *tret = dlt_queue_pop(queue);
- printf("#4\tItem content after pop:\t%d:%s", tret->item_size, (char *)tret->item);
- dlt_queue_free_item(tret);
-
- int i=0;
- for(i=0;i<5;i++)
- {
- dlt_queue_item *newitem = dlt_queue_create_item();
- newitem->item = item_content;
- newitem->item_size = i;
- dlt_queue_push(newitem, queue);
- }
- printf("#5\tdlt_queue_item_count returns\t%d\n", dlt_queue_item_count(queue));
- while(!dlt_queue_is_empty(queue))
- {
- dlt_queue_item *olditem = dlt_queue_pop(queue);
- printf("#6\tItem size (item number):%d\n", olditem->item_size);
- dlt_queue_free_item(olditem);
- }
- printf("#7\tdlt_queue_is_empty returns\t%d\n", dlt_queue_is_empty(queue));
- printf("#8\tdlt_queue_item_count returns\t%d\n", dlt_queue_item_count(queue));
- return 0;
-}