From bd7d2785c0a33d61ea5068e4aecaffba05626150 Mon Sep 17 00:00:00 2001 From: Manikandan C Date: Fri, 9 Nov 2018 10:17:06 +0100 Subject: Protocol: DLT Service ID Enum instead of defines Signed-off-by: Christoph Lipka --- include/dlt/dlt_protocol.h | 79 ++++++++++++++++++++++++---------------- src/daemon/CMakeLists.txt | 2 +- src/lib/CMakeLists.txt | 2 +- src/shared/dlt_protocol.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+), 33 deletions(-) create mode 100644 src/shared/dlt_protocol.c diff --git a/include/dlt/dlt_protocol.h b/include/dlt/dlt_protocol.h index 53dea25..45df907 100644 --- a/include/dlt/dlt_protocol.h +++ b/include/dlt/dlt_protocol.h @@ -173,37 +173,54 @@ /* * Definitions of DLT services. */ -#define DLT_SERVICE_ID_SET_LOG_LEVEL 0x01 /**< Service ID: Set log level */ -#define DLT_SERVICE_ID_SET_TRACE_STATUS 0x02 /**< Service ID: Set trace status */ -#define DLT_SERVICE_ID_GET_LOG_INFO 0x03 /**< Service ID: Get log info */ -#define DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL 0x04 /**< Service ID: Get dafault log level */ -#define DLT_SERVICE_ID_STORE_CONFIG 0x05 /**< Service ID: Store configuration */ -#define DLT_SERVICE_ID_RESET_TO_FACTORY_DEFAULT 0x06 /**< Service ID: Reset to factory defaults */ -#define DLT_SERVICE_ID_SET_COM_INTERFACE_STATUS 0x07 /**< Service ID: Set communication interface status */ -#define DLT_SERVICE_ID_SET_COM_INTERFACE_MAX_BANDWIDTH 0x08 /**< Service ID: Set communication interface maximum bandwidth */ -#define DLT_SERVICE_ID_SET_VERBOSE_MODE 0x09 /**< Service ID: Set verbose mode */ -#define DLT_SERVICE_ID_SET_MESSAGE_FILTERING 0x0A /**< Service ID: Set message filtering */ -#define DLT_SERVICE_ID_SET_TIMING_PACKETS 0x0B /**< Service ID: Set timing packets */ -#define DLT_SERVICE_ID_GET_LOCAL_TIME 0x0C /**< Service ID: Get local time */ -#define DLT_SERVICE_ID_USE_ECU_ID 0x0D /**< Service ID: Use ECU id */ -#define DLT_SERVICE_ID_USE_SESSION_ID 0x0E /**< Service ID: Use session id */ -#define DLT_SERVICE_ID_USE_TIMESTAMP 0x0F /**< Service ID: Use timestamp */ -#define DLT_SERVICE_ID_USE_EXTENDED_HEADER 0x10 /**< Service ID: Use extended header */ -#define DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL 0x11 /**< Service ID: Set default log level */ -#define DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS 0x12 /**< Service ID: Set default trace status */ -#define DLT_SERVICE_ID_GET_SOFTWARE_VERSION 0x13 /**< Service ID: Get software version */ -#define DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW 0x14 /**< Service ID: Message buffer overflow */ -#define DLT_SERVICE_ID_LAST_ENTRY 0x15 /**< Service ID: Last entry to avoid any further modifications in dependent code */ -#define DLT_SERVICE_ID_UNREGISTER_CONTEXT 0xf01 /**< Service ID: Message unregister context */ -#define DLT_SERVICE_ID_CONNECTION_INFO 0xf02 /**< Service ID: Message connection info */ -#define DLT_SERVICE_ID_TIMEZONE 0xf03 /**< Service ID: Timezone */ -#define DLT_SERVICE_ID_MARKER 0xf04 /**< Service ID: Marker */ -#define DLT_SERVICE_ID_OFFLINE_LOGSTORAGE 0xf05 /**< Service ID: Offline log storage */ -#define DLT_SERVICE_ID_PASSIVE_NODE_CONNECT 0xf0E /**< Service ID: (Dis)Connect passive Node */ -#define DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS 0xf0F /**< Service ID: Passive Node status information */ -#define DLT_SERVICE_ID_SET_ALL_LOG_LEVEL 0xf10 /**< Service ID: set all log level */ -#define DLT_SERVICE_ID_SET_ALL_TRACE_STATUS 0xf11 /**< Service ID: Set all trace status */ -#define DLT_SERVICE_ID_CALLSW_CINJECTION 0xFFF /**< Service ID: Message Injection (minimal ID) */ +#define DLT_SERVICE_ID_CALLSW_CINJECTION 0xFFF + +enum dlt_services { + DLT_SERVICE_ID = 0x00, + DLT_SERVICE_ID_SET_LOG_LEVEL = 0x01, + DLT_SERVICE_ID_SET_TRACE_STATUS = 0x02, + DLT_SERVICE_ID_GET_LOG_INFO = 0x03, + DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL = 0x04, + DLT_SERVICE_ID_STORE_CONFIG = 0x05, + DLT_SERVICE_ID_RESET_TO_FACTORY_DEFAULT = 0x06, + DLT_SERVICE_ID_SET_COM_INTERFACE_STATUS = 0x07, + DLT_SERVICE_ID_SET_COM_INTERFACE_MAX_BANDWIDTH = 0x08, + DLT_SERVICE_ID_SET_VERBOSE_MODE = 0x09, + DLT_SERVICE_ID_SET_MESSAGE_FILTERING = 0x0A, + DLT_SERVICE_ID_SET_TIMING_PACKETS = 0x0B, + DLT_SERVICE_ID_GET_LOCAL_TIME = 0x0C, + DLT_SERVICE_ID_USE_ECU_ID = 0x0D, + DLT_SERVICE_ID_USE_SESSION_ID = 0x0E, + DLT_SERVICE_ID_USE_TIMESTAMP = 0x0F, + DLT_SERVICE_ID_USE_EXTENDED_HEADER = 0x10, + DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL = 0x11, + DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS = 0x12, + DLT_SERVICE_ID_GET_SOFTWARE_VERSION = 0x13, + DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW = 0x14, + DLT_SERVICE_ID_LAST_ENTRY +}; + +enum dlt_user_services { + DLT_USER_SERVICE_ID = 0xF00, + DLT_SERVICE_ID_UNREGISTER_CONTEXT = 0xF01, + DLT_SERVICE_ID_CONNECTION_INFO = 0xF02, + DLT_SERVICE_ID_TIMEZONE = 0xF03, + DLT_SERVICE_ID_MARKER = 0xF04, + DLT_SERVICE_ID_OFFLINE_LOGSTORAGE = 0xF05, + DLT_SERVICE_ID_SET_FILTER_LEVEL = 0xF06, + DLT_SERVICE_ID_GET_FILTER_STATUS = 0xF07, + DLT_SERVICE_ID_PASSIVE_NODE_CONNECT = 0xF08, + DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS = 0xF09, + DLT_SERVICE_ID_SET_ALL_LOG_LEVEL = 0xF0A, + DLT_SERVICE_ID_SET_ALL_TRACE_STATUS = 0xF0B, + DLT_USER_SERVICE_ID_LAST_ENTRY +}; + +/* Need to be adapted if another service is added */ +extern const char *const dlt_service_names[]; +extern const char *const dlt_user_service_names[]; + +extern const char *dlt_get_service_name(unsigned int id); /* * Definitions of DLT service response status diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index 9a22ccd..2f5c27a 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -20,7 +20,7 @@ if(WITH_SYSTEMD_WATCHDOG OR WITH_SYSTEMD) message( STATUS "Added ${systemd_SRCS} to dlt-daemon") endif(WITH_SYSTEMD_WATCHDOG OR WITH_SYSTEMD) -set(dlt_daemon_SRCS dlt-daemon.c dlt_daemon_common.c dlt_daemon_connection.c dlt_daemon_event_handler.c ${CMAKE_SOURCE_DIR}/src/gateway/dlt_gateway.c dlt_daemon_socket.c dlt_daemon_unix_socket.c dlt_daemon_serial.c dlt_daemon_client.c dlt_daemon_offline_logstorage.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_user_shared.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_common.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_shm.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_offline_trace.c ${CMAKE_SOURCE_DIR}/src/offlinelogstorage/dlt_offline_logstorage.c ${CMAKE_SOURCE_DIR}/src/lib/dlt_client.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_config_file_parser.c ${CMAKE_SOURCE_DIR}/src/offlinelogstorage/dlt_offline_logstorage_behavior.c) +set(dlt_daemon_SRCS dlt-daemon.c dlt_daemon_common.c dlt_daemon_connection.c dlt_daemon_event_handler.c ${CMAKE_SOURCE_DIR}/src/gateway/dlt_gateway.c dlt_daemon_socket.c dlt_daemon_unix_socket.c dlt_daemon_serial.c dlt_daemon_client.c dlt_daemon_offline_logstorage.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_user_shared.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_common.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_shm.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_offline_trace.c ${CMAKE_SOURCE_DIR}/src/offlinelogstorage/dlt_offline_logstorage.c ${CMAKE_SOURCE_DIR}/src/lib/dlt_client.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_config_file_parser.c ${CMAKE_SOURCE_DIR}/src/offlinelogstorage/dlt_offline_logstorage_behavior.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_protocol.c) add_executable(dlt-daemon ${dlt_daemon_SRCS} ${systemd_SRCS}) target_link_libraries(dlt-daemon rt ${CMAKE_THREAD_LIBS_INIT}) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 02b39fe..d20d954 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -15,7 +15,7 @@ # @licence end@ ####### -set(dlt_LIB_SRCS dlt_user dlt_client dlt_filetransfer dlt_env_ll ${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 dlt_env_ll ${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 ${CMAKE_SOURCE_DIR}/src/shared/dlt_protocol.c) add_library(dlt ${dlt_LIB_SRCS}) target_link_libraries(dlt rt ${CMAKE_THREAD_LIBS_INIT}) diff --git a/src/shared/dlt_protocol.c b/src/shared/dlt_protocol.c new file mode 100644 index 0000000..78c335f --- /dev/null +++ b/src/shared/dlt_protocol.c @@ -0,0 +1,90 @@ +/* + * @licence app begin@ + * SPDX license identifier: MPL-2.0 + * + * Copyright (C) 2016 Advanced Driver Information Technology. + * This code is developed by Advanced Driver Information Technology. + * Copyright of Advanced Driver Information Technology, Bosch and DENSO. + * + * This file is part of GENIVI Project DLT - Diagnostic Log and Trace. + * + * This Source Code Form is subject to the terms of the + * Mozilla Public License (MPL), 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/. + * + * For further information see http://www.genivi.org/. + * @licence end@ + */ + +/*! + * \author + * Christoph Lipka + * + * \copyright Copyright © 2016 Advanced Driver Information Technology. \n + * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/. + * + * \file dlt_protocol.c + */ + +#include "dlt_protocol.h" + +const char *const dlt_service_names[] = +{ + "DLT_SERVICE_ID", + "DLT_SERVICE_ID_SET_LOG_LEVEL", + "DLT_SERVICE_ID_SET_TRACE_STATUS", + "DLT_SERVICE_ID_GET_LOG_INFO", + "DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL", + "DLT_SERVICE_ID_STORE_CONFIG", + "DLT_SERVICE_ID_RESET_TO_FACTORY_DEFAULT", + "DLT_SERVICE_ID_SET_COM_INTERFACE_STATUS", + "DLT_SERVICE_ID_SET_COM_INTERFACE_MAX_BANDWIDTH", + "DLT_SERVICE_ID_SET_VERBOSE_MODE", + "DLT_SERVICE_ID_SET_MESSAGE_FILTERING", + "DLT_SERVICE_ID_SET_TIMING_PACKETS", + "DLT_SERVICE_ID_GET_LOCAL_TIME", + "DLT_SERVICE_ID_USE_ECU_ID", + "DLT_SERVICE_ID_USE_SESSION_ID", + "DLT_SERVICE_ID_USE_TIMESTAMP", + "DLT_SERVICE_ID_USE_EXTENDED_HEADER", + "DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL", + "DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS", + "DLT_SERVICE_ID_GET_SOFTWARE_VERSION", + "DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW" +}; +const char *const dlt_user_service_names[] = +{ + "DLT_USER_SERVICE_ID", + "DLT_SERVICE_ID_UNREGISTER_CONTEXT", + "DLT_SERVICE_ID_CONNECTION_INFO", + "DLT_SERVICE_ID_TIMEZONE", + "DLT_SERVICE_ID_MARKER", + "DLT_SERVICE_ID_OFFLINE_LOGSTORAGE", + "DLT_SERVICE_ID_SET_FILTER_LEVEL", + "DLT_SERVICE_ID_GET_FILTER_STATUS", + "DLT_SERVICE_ID_PASSIVE_NODE_CONNECT", + "DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS", + "DLT_SERVICE_ID_SET_ALL_LOG_LEVEL" +}; + +const char *dlt_get_service_name(unsigned int id) +{ + if (id == DLT_SERVICE_ID_CALLSW_CINJECTION) + { + return "DLT_SERVICE_ID_CALLSW_CINJECTION"; + } + else if ((id == DLT_SERVICE_ID) || (id >= DLT_USER_SERVICE_ID_LAST_ENTRY) || + (id >= DLT_SERVICE_ID_LAST_ENTRY && id <= DLT_USER_SERVICE_ID)) + { + return "UNDEFINED"; + } + else if ((id > DLT_SERVICE_ID) && (id < DLT_SERVICE_ID_LAST_ENTRY)) + { + return dlt_service_names[id]; + } + else /* user services */ + { + return dlt_user_service_names[id&0xFF]; + } +} -- cgit v1.2.1