summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Herchet <frank.fh.herchet@bmw.de>2012-02-29 09:38:02 +0100
committerFrank Herchet <frank.fh.herchet@bmw.de>2012-02-29 09:40:38 +0100
commit70e2c8c1ceb26775e749157096c831fd003e724c (patch)
tree3adb9acbe351efd50092b9a357af78d0254206d1
parentaa93713377d28a8ce7821466ef828f79a18e982d (diff)
parent7abe8302898461aaa342224de2d00ce1c80eb8c2 (diff)
downloadaudiomanager-70e2c8c1ceb26775e749157096c831fd003e724c.tar.gz
* [GAM-11] Merge branch 'dlt_dependency'
Conflicts: CMakeLists.txt cmake/config.cmake
-rw-r--r--AudioManagerDaemon/CMakeLists.txt52
-rw-r--r--AudioManagerDaemon/src/DLTWrapper.cpp98
-rw-r--r--CMakeLists.txt12
-rw-r--r--cmake/config.cmake1
-rw-r--r--includes/DLTWrapper.h68
5 files changed, 210 insertions, 21 deletions
diff --git a/AudioManagerDaemon/CMakeLists.txt b/AudioManagerDaemon/CMakeLists.txt
index 8e5297c..beb1a74 100644
--- a/AudioManagerDaemon/CMakeLists.txt
+++ b/AudioManagerDaemon/CMakeLists.txt
@@ -70,12 +70,17 @@ ENDIF(WITH_SOCKETHANDLER_LOOP)
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${DLT_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}
${AUDIO_INCLUDES_FOLDER}
${INCLUDES_FOLDER}
)
+IF(WITH_DLT)
+INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
+ ${DLT_INCLUDE_DIRS}
+)
+ENDIF(WITH_DLT)
+
IF(WITH_DBUS_WRAPPER)
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
${DBUS_ARCH_INCLUDE_DIR}
@@ -86,18 +91,22 @@ ENDIF(WITH_DBUS_WRAPPER)
ADD_EXECUTABLE(AudioManager ${AUDIOMAN_SRCS_CXX})
IF(WITH_DBUS_WRAPPER)
-TARGET_LINK_LIBRARIES(AudioManager
- ${SQLITE_LIBRARIES}
- ${DLT_LIBRARIES}
- ${DBUS_LIBRARY}
-)
+ TARGET_LINK_LIBRARIES(AudioManager
+ ${SQLITE_LIBRARIES}
+ ${DBUS_LIBRARY}
+ )
ELSE(WITH_DBUS_WRAPPER)
TARGET_LINK_LIBRARIES(AudioManager
${SQLITE_LIBRARIES}
- ${DLT_LIBRARIES}
-)
+ )
ENDIF(WITH_DBUS_WRAPPER)
+IF(WITH_DLT)
+ TARGET_LINK_LIBRARIES(AudioManager
+ ${DLT_LIBRARIES}
+ )
+ENDIF(WITH_DLT)
+
IF(WITH_TESTS)
add_subdirectory (test)
ENDIF(WITH_TESTS)
@@ -123,9 +132,26 @@ INSTALL(DIRECTORY "${AUDIO_INCLUDES_FOLDER}/"
COMPONENT dev
)
-SET(ADD_DEPEND "sqlite3(>=3.6.22)" "dlt" "libdbus-1-3(>=1.2.16)")
-set_property(GLOBAL APPEND PROPERTY bin_prop "${ADD_DEPEND}")
+# General packet dependency
+SET(ADD_DEPEND_BIN_PROP "sqlite3(>=3.6.22)")
+
+# Optional packet dependency
+IF(WITH_DLT)
+ SET(ADD_DEPEND_BIN_PROP ${ADD_DEPEND_BIN_PROP} "dlt")
+ENDIF(WITH_DLT)
+
+IF(WITH_DBUS_WRAPPER)
+ SET(ADD_DEPEND_BIN_PROP ${ADD_DEPEND_BIN_PROP} "libdbus-1-3(>=1.2.16)")
+ENDIF()
+
+# Additional Dev packet dependency
+SET(ADD_DEPEND_DEV_PROP "audiomanager-bin" ${ADD_DEPEND_BIN_PROP})
+
+MESSAGE(STATUS "bin packet dependency: ${ADD_DEPEND_BIN_PROP}")
+MESSAGE(STATUS "dev dependency: ${ADD_DEPEND_DEV_PROP}")
+
+set_property(GLOBAL APPEND PROPERTY bin_prop "${ADD_DEPEND_BIN_PROP}")
+set_property(GLOBAL APPEND PROPERTY dev_prop "${ADD_DEPEND_DEV_PROP}")
+
-SET(ADD_DEPEND "audiomanager-bin" "sqlite3(>=3.6.22)" "dlt" "libdbus-1-3(>=1.2.16)")
-set_property(GLOBAL APPEND PROPERTY dev_prop "${ADD_DEPEND}")
diff --git a/AudioManagerDaemon/src/DLTWrapper.cpp b/AudioManagerDaemon/src/DLTWrapper.cpp
index 33a48e8..cdb1a1e 100644
--- a/AudioManagerDaemon/src/DLTWrapper.cpp
+++ b/AudioManagerDaemon/src/DLTWrapper.cpp
@@ -22,97 +22,187 @@
*
*/
+
#include "DLTWrapper.h"
-#include <cassert>
+#include <string.h>
+#include <sstream>
+#include <iostream>
DLTWrapper* DLTWrapper::mDLTWrapper = NULL;
-DLTWrapper *DLTWrapper::instance()
+DLTWrapper *DLTWrapper::instance(const bool enableNoDLTDebug)
{
if (!mDLTWrapper)
- mDLTWrapper = new DLTWrapper;
+ mDLTWrapper = new DLTWrapper(enableNoDLTDebug);
+ if(enableNoDLTDebug)
+ mDLTWrapper->enableNoDLTDebug(true);
return mDLTWrapper;
}
void DLTWrapper::unregisterContext(DltContext & handle)
{
+#ifdef WITH_DLT
dlt_unregister_context(&handle);
+#endif
}
-DLTWrapper::DLTWrapper() :
+DLTWrapper::DLTWrapper(const bool enableNoDLTDebug) :
+#ifndef WITH_DLT
+ mEnableNoDLTDebug(enableNoDLTDebug),
+#endif
mDltContext(), //
mDltContextData()
{
+#ifndef WITH_DLT
+ std::cout << "[DLT] Running without DLT-support" << std::endl;
+#endif
}
void DLTWrapper::registerApp(const char *appid, const char *description)
{
+#ifdef WITH_DLT
dlt_register_app(appid, description);
//register a default context
dlt_register_context(&mDltContext, "def", "default Context registered by DLTWrapper CLass");
+#endif
}
void DLTWrapper::registerContext(DltContext& handle, const char *contextid, const char *description)
{
+#ifdef WITH_DLT
dlt_register_context(&handle, contextid, description);
+#else
+ memcpy(&mDltContext.contextID,contextid,4);
+ strlen(description);
+ const size_t str_len = strlen(description);
+ if(str_len < 2000)
+ {
+ mDltContextData.context_description = new char[str_len + 1];
+ (void) strcpy(mDltContextData.context_description,description);
+ }
+#endif
}
void DLTWrapper::init(DltLogLevelType loglevel, DltContext* context)
{
if (!context)
context = &mDltContext;
+#ifdef WITH_DLT
dlt_user_log_write_start(context, &mDltContextData, loglevel);
+#endif
+
}
void DLTWrapper::send()
{
+#ifdef WITH_DLT
dlt_user_log_write_finish(&mDltContextData);
+#else
+ if(mEnableNoDLTDebug)
+ std::cout << "[" << mDltContext.contextID << "] " << std::string(mDltContextData.buffer) << std::endl;
+
+ mDltContextData.size = 0;
+#endif
}
void DLTWrapper::append(const int8_t value)
{
+#ifdef WITH_DLT
dlt_user_log_write_int8(&mDltContextData, value);
+#else
+ appendNoDLT(value);
+#endif
}
void DLTWrapper::append(const uint8_t value)
{
+#ifdef WITH_DLT
dlt_user_log_write_uint8(&mDltContextData, value);
+#else
+ appendNoDLT(value);
+#endif
}
void DLTWrapper::append(const int16_t value)
{
+#ifdef WITH_DLT
dlt_user_log_write_int16(&mDltContextData, value);
+#else
+ appendNoDLT(value);
+#endif
}
void DLTWrapper::append(const uint16_t value)
{
+#ifdef WITH_DLT
dlt_user_log_write_uint16(&mDltContextData, value);
+#else
+ appendNoDLT(value);
+#endif
}
void DLTWrapper::append(const int32_t value)
{
+#ifdef WITH_DLT
dlt_user_log_write_int32(&mDltContextData, value);
+#else
+ appendNoDLT(value);
+#endif
}
void DLTWrapper::append(const uint32_t value)
{
+#ifdef WITH_DLT
dlt_user_log_write_uint32(&mDltContextData, value);
+#else
+ appendNoDLT(value);
+#endif
}
void DLTWrapper::append(const char*& value)
{
+#ifdef WITH_DLT
dlt_user_log_write_string(&mDltContextData, value);
+#else
+ memcpy((mDltContextData.buffer+mDltContextData.size),value,strlen(value));
+ mDltContextData.size += strlen(value);
+#endif
}
void DLTWrapper::append(const std::string& value)
{
+#ifdef WITH_DLT
dlt_user_log_write_string(&mDltContextData, value.c_str());
+#else
+ memcpy((mDltContextData.buffer+mDltContextData.size),value.c_str(),value.size());
+ mDltContextData.size += value.size();
+#endif
}
void DLTWrapper::append(const bool value)
{
+#ifdef WITH_DLT
dlt_user_log_write_bool(&mDltContextData, static_cast<uint8_t>(value));
+#else
+ appendNoDLT(value);
+#endif
+}
+
+#ifndef WITH_DLT
+template<class T> void DLTWrapper::appendNoDLT(T value)
+{
+ if((mDltContextData.size + sizeof(value)) < DLT_USER_BUF_MAX_SIZE)
+ {
+ memcpy((mDltContextData.buffer+mDltContextData.size),&(value),sizeof(value));
+ mDltContextData.size += sizeof(value);
+ }
+}
+
+void DLTWrapper::enableNoDLTDebug(const bool enableNoDLTDebug)
+{
+ mEnableNoDLTDebug = enableNoDLTDebug;
}
+#endif
DLTWrapper::~DLTWrapper()
{
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad3c219..aa944de 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,8 +46,13 @@ execute_process(COMMAND git log --pretty=short WORKING_DIRECTORY ${CMAKE_CURRENT
PROJECT(AudioManagerDeamon)
+FIND_PACKAGE(PkgConfig)
+
OPTION( WITH_DBUS_WRAPPER
"Enable Dbus Wrapper Support" ON )
+
+OPTION( WITH_DLT
+ "Enable automotive-DLT Support" ON )
OPTION( WITH_TESTS
"Build together with all available unitTest" ON )
@@ -122,8 +127,11 @@ SET(INTROSPECTION_COMMAND_XML_FILE "${AUDIO_INCLUDES_FOLDER}/dbus/CommandInterfa
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/config.cmake ${CMAKE_SOURCE_DIR}/includes/config.h )
-FIND_PACKAGE(PkgConfig)
-pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0) #this is due to BUGFIX [GDLT-41]
+
+IF(WITH_DLT)
+ pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0) #this is due to BUGFIX [GDLT-41]
+ENDIF(WITH_DLT)
+
IF(WITH_DOCUMENTATION)
find_package(Doxygen)
diff --git a/cmake/config.cmake b/cmake/config.cmake
index 4d84d73..2349bb7 100644
--- a/cmake/config.cmake
+++ b/cmake/config.cmake
@@ -4,6 +4,7 @@
#cmakedefine DAEMONVERSION "@DAEMONVERSION@"
#cmakedefine WITH_DBUS_WRAPPER
+#cmakedefine WITH_DLT
#cmakedefine WITH_PPOLL
#cmakedefine WITH_TELNET
#cmakedefine GLIB_DBUS_TYPES_TOLERANT
diff --git a/includes/DLTWrapper.h b/includes/DLTWrapper.h
index dcce4ab..3a9482a 100644
--- a/includes/DLTWrapper.h
+++ b/includes/DLTWrapper.h
@@ -25,13 +25,70 @@
#ifndef DLTWRAPPER_H_
#define DLTWRAPPER_H_
+#include "config.h"
+
+#ifdef WITH_DLT
#include <dlt/dlt.h>
+#else
+
+#include <stdint.h>
+
+#define DLT_USER_BUF_MAX_SIZE 2048
+
+/**
+ * This structure is used for every context used in an application.
+ */
+typedef struct
+{
+ char contextID[4]; /**< context id */
+ int32_t log_level_pos; /**< offset in user-application context field */
+} DltContext;
+
+/**
+ * Definitions of DLT log level
+ */
+typedef enum
+{
+ DLT_LOG_DEFAULT = -1, /**< Default log level */
+ DLT_LOG_OFF = 0x00, /**< Log level off */
+ DLT_LOG_FATAL = 0x01, /**< fatal system error */
+ DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */
+ DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */
+ DLT_LOG_INFO = 0x04, /**< informational */
+ DLT_LOG_DEBUG = 0x05, /**< debug */
+ DLT_LOG_VERBOSE = 0x06 /**< highest grade of information */
+} DltLogLevelType;
+
+/**
+ * This structure is used for context data used in an application.
+ */
+typedef struct
+{
+ DltContext *handle; /**< pointer to DltContext */
+ char buffer[DLT_USER_BUF_MAX_SIZE]; /**< buffer for building log message*/
+ int32_t size; /**< payload size */
+ int32_t log_level; /**< log level */
+ int32_t trace_status; /**< trace status */
+ int32_t args_num; /**< number of arguments for extended header*/
+ uint8_t mcnt; /**< message counter */
+ char* context_description; /**< description of context */
+} DltContextData;
+
+#define DLT_DECLARE_CONTEXT(CONTEXT) \
+DltContext CONTEXT;
+
+
+#define DLT_IMPORT_CONTEXT(CONTEXT) \
+extern DltContext CONTEXT;
+
+#endif
+
#include <string>
class DLTWrapper
{
public:
- static DLTWrapper* instance();
+ static DLTWrapper* instance(const bool enableNoDLTDebug = false);
void registerApp(const char *appid, const char * description);
void registerContext(DltContext& handle, const char *contextid, const char * description);
void unregisterContext(DltContext& handle);
@@ -46,9 +103,16 @@ public:
void append(const char*& value);
void append(const std::string& value);
void append(const bool value);
+#ifndef WITH_DLT
+ void enableNoDLTDebug(const bool enableNoDLTDebug = true);
+#endif
~DLTWrapper();
private:
- DLTWrapper(); //is private because of singleton pattern
+ DLTWrapper(const bool enableNoDLTDebug); //is private because of singleton pattern
+#ifndef WITH_DLT
+ template<class T> void appendNoDLT(T value);
+ bool mEnableNoDLTDebug;
+#endif
DltContext mDltContext;
DltContextData mDltContextData;
static DLTWrapper* mDLTWrapper;