2 * @licence app begin@
\r
3 * Copyright (C) 2012 BMW AG
\r
5 * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
\r
7 * Contributions are licensed to the GENIVI Alliance under one or more
\r
8 * Contribution License Agreements.
\r
11 * This Source Code Form is subject to the terms of the
\r
12 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
\r
13 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
\r
16 * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de> BMW 2011-2012
\r
18 * \file dlt-daemon.h
\r
19 * For further information see http://www.genivi.org/.
\r
24 /*******************************************************************************
\r
26 ** SRC-MODULE: dlt-daemon.h **
\r
28 ** TARGET : linux **
\r
32 ** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
\r
39 ** PLATFORM DEPENDANT [yes/no]: yes **
\r
41 ** TO BE CHANGED BY USER [yes/no]: no **
\r
43 *******************************************************************************/
\r
45 /*******************************************************************************
\r
46 ** Author Identity **
\r
47 ********************************************************************************
\r
49 ** Initials Name Company **
\r
50 ** -------- ------------------------- ---------------------------------- **
\r
51 ** aw Alexander Wenzel BMW **
\r
52 ** mk Markus Klein Fraunhofer ESK **
\r
53 *******************************************************************************/
\r
55 /*******************************************************************************
\r
56 ** Author Identity **
\r
57 ********************************************************************************
\r
59 ** Initials Name Company **
\r
60 ** -------- ------------------------- ---------------------------------- **
\r
61 ** aw Alexander Wenzel BMW **
\r
62 ** mk Markus Klein Fraunhofer ESK **
\r
63 *******************************************************************************/
\r
65 #ifndef DLT_DAEMON_H
\r
66 #define DLT_DAEMON_H
\r
68 #include <limits.h> /* for NAME_MAX */
\r
70 #include "dlt_daemon_common.h"
\r
71 #include "dlt_user_shared.h"
\r
72 #include "dlt_user_shared_cfg.h"
\r
75 #include <dlt_offline_trace.h>
\r
76 #include <sys/time.h>
\r
80 * The flags of a dlt daemon.
\r
84 int aflag; /**< (Boolean) Print DLT messages; payload as ASCII */
\r
85 int sflag; /**< (Boolean) Print DLT messages; payload as hex */
\r
86 int xflag; /**< (Boolean) Print DLT messages; only headers */
\r
87 int vflag; /**< (Boolean) Verbose mode */
\r
88 int dflag; /**< (Boolean) Daemonize */
\r
89 int lflag; /**< (Boolean) Send DLT messages with serial header */
\r
90 int rflag; /**< (Boolean) Send automatic get log info response during context registration */
\r
91 int mflag; /**< (Boolean) Sync to serial header on serial connection */
\r
92 int nflag; /**< (Boolean) Sync to serial header on all TCP connections */
\r
93 char evalue[NAME_MAX + 1]; /**< (String: ECU ID) Set ECU ID (Default: ECU1) */
\r
94 char bvalue[NAME_MAX + 1]; /**< (String: Baudrate) Serial device baudrate (Default: 115200) */
\r
95 char yvalue[NAME_MAX + 1]; /**< (String: Devicename) Additional support for serial device */
\r
96 char ivalue[NAME_MAX + 1]; /**< (String: Directory) Directory where to store the persistant configuration (Default: /tmp) */
\r
97 char cvalue[NAME_MAX + 1]; /**< (String: Directory) Filename of DLT configuration file (Default: /etc/dlt.conf) */
\r
98 int sharedMemorySize; /**< (int) Size of shared memory (Default: 100000) */
\r
99 int sendMessageTime; /**< (Boolean) Send periodic Message Time if client is connected (Default: 0) */
\r
100 char offlineTraceDirectory[256]; /**< (String: Directory) Store DLT messages to local directory (Default: /etc/dlt.conf) */
\r
101 int offlineTraceFileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */
\r
102 int offlineTraceMaxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */
\r
103 int loggingMode; /**< (int) The logging console for internal logging of dlt-daemon (Default: 0) */
\r
104 int loggingLevel; /**< (int) The logging level for internal logging of dlt-daemon (Default: 6) */
\r
105 char loggingFilename[256]; /**< (String: Filename) The logging filename if internal logging mode is log to file (Default: /tmp/log) */
\r
106 int sendECUSoftwareVersion; /**< (Boolean) Send ECU software version perdiodically */
\r
107 char pathToECUSoftwareVersion[256]; /**< (String: Filename) The file from which to read the ECU version from. */
\r
111 * The global parameters of a dlt daemon.
\r
115 DltDaemonFlags flags; /**< flags of the daemon */
\r
116 int fp; /**< handle for own fifo */
\r
117 int sock; /**< handle for tcp connection to client */
\r
118 int fdserial; /**< handle for serial connection */
\r
119 int fdmax; /**< highest number of used handles */
\r
120 fd_set master; /**< master set of handles */
\r
121 fd_set read_fds; /**< read set of handles */
\r
122 DltFile file; /**< struct for file access */
\r
123 //int ohandle; /**< handle to output file */
\r
124 DltMessage msg; /**< one dlt message */
\r
125 DltReceiver receiver; /**< receiver for fifo connection */
\r
126 DltReceiver receiverSock; /**< receiver for socket connection */
\r
127 DltReceiver receiverSerial; /**< receiver for serial connection */
\r
128 int client_connections; /**< counter for nr. of client connections */
\r
129 size_t baudrate; /**< Baudrate of serial connection */
\r
130 #ifdef DLT_SHM_ENABLE
\r
131 DltShm dlt_shm; /**< Shared memory handling */
\r
133 DltOfflineTrace offlineTrace; /**< Offline trace handling */
\r
134 #if defined(DLT_SYSTEMD_WATCHDOG_ENABLE)
\r
135 uint32_t lastOperationTime;
\r
142 unsigned long long wakeups_missed;
\r
143 } DltDaemonPeriodicData;
\r
148 DltDaemonLocal *daemon_local;
\r
149 } DltDaemonTimingPacketThreadData;
\r
151 typedef DltDaemonTimingPacketThreadData DltDaemonECUVersionThreadData;
\r
153 /* Function prototypes */
\r
154 void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
155 int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
156 int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
157 int dlt_daemon_local_connection_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
158 int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
160 void dlt_daemon_daemonize(int verbose);
\r
161 void dlt_daemon_signal_handler(int sig);
\r
163 int dlt_daemon_process_client_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
164 int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
165 int dlt_daemon_process_client_messages_serial(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
166 int dlt_daemon_process_user_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
168 int dlt_daemon_process_user_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
169 int dlt_daemon_send_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
170 int dlt_daemon_process_user_message_register_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
171 int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
172 int dlt_daemon_process_user_message_register_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
173 int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
174 int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
175 #ifdef DLT_SHM_ENABLE
\r
176 int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
178 int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
179 int dlt_daemon_process_user_message_log_mode(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
181 int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
182 void dlt_daemon_timingpacket_thread(void *ptr);
\r
183 void dlt_daemon_ecu_version_thread(void *ptr);
\r
184 #if defined(DLT_SYSTEMD_WATCHDOG_ENABLE)
\r
185 void dlt_daemon_systemd_watchdog_thread(void *ptr);
\r
187 int dlt_daemon_make_periodic (unsigned int period, DltDaemonPeriodicData *info, int verbose);
\r
188 void dlt_daemon_wait_period(DltDaemonPeriodicData *info, int verbose);
\r
190 #endif /* DLT_DAEMON_H */
\r