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
79 * The flags of a dlt daemon.
\r
83 int aflag; /**< (Boolean) Print DLT messages; payload as ASCII */
\r
84 int sflag; /**< (Boolean) Print DLT messages; payload as hex */
\r
85 int xflag; /**< (Boolean) Print DLT messages; only headers */
\r
86 int vflag; /**< (Boolean) Verbose mode */
\r
87 int dflag; /**< (Boolean) Daemonize */
\r
88 int lflag; /**< (Boolean) Send DLT messages with serial header */
\r
89 int rflag; /**< (Boolean) Send automatic get log info response during context registration */
\r
90 int mflag; /**< (Boolean) Sync to serial header on serial connection */
\r
91 int nflag; /**< (Boolean) Sync to serial header on all TCP connections */
\r
92 char evalue[NAME_MAX + 1]; /**< (String: ECU ID) Set ECU ID (Default: ECU1) */
\r
93 char bvalue[NAME_MAX + 1]; /**< (String: Baudrate) Serial device baudrate (Default: 115200) */
\r
94 char yvalue[NAME_MAX + 1]; /**< (String: Devicename) Additional support for serial device */
\r
95 char ivalue[NAME_MAX + 1]; /**< (String: Directory) Directory where to store the persistant configuration (Default: /tmp) */
\r
96 char cvalue[NAME_MAX + 1]; /**< (String: Directory) Filename of DLT configuration file (Default: /etc/dlt.conf) */
\r
97 int sharedMemorySize; /**< (int) Size of shared memory (Default: 100000) */
\r
98 int sendMessageTime; /**< (Boolean) Send periodic Message Time if client is connected (Default: 0) */
\r
99 char offlineTraceDirectory[256]; /**< (String: Directory) Store DLT messages to local directory (Default: /etc/dlt.conf) */
\r
100 int offlineTraceFileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */
\r
101 int offlineTraceMaxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */
\r
102 int loggingMode; /**< (int) The logging console for internal logging of dlt-daemon (Default: 0) */
\r
103 int loggingLevel; /**< (int) The logging level for internal logging of dlt-daemon (Default: 6) */
\r
104 char loggingFilename[256]; /**< (String: Filename) The logging filename if internal logging mode is log to file (Default: /tmp/log) */
\r
105 int sendECUSoftwareVersion;
\r
106 char pathToECUSoftwareVersion[256];
\r
110 * The global parameters of a dlt daemon.
\r
114 DltDaemonFlags flags; /**< flags of the daemon */
\r
115 int fp; /**< handle for own fifo */
\r
116 int sock; /**< handle for tcp connection to client */
\r
117 int fdserial; /**< handle for serial connection */
\r
118 int fdmax; /**< highest number of used handles */
\r
119 fd_set master; /**< master set of handles */
\r
120 fd_set read_fds; /**< read set of handles */
\r
121 DltFile file; /**< struct for file access */
\r
122 //int ohandle; /**< handle to output file */
\r
123 DltMessage msg; /**< one dlt message */
\r
124 DltReceiver receiver; /**< receiver for fifo connection */
\r
125 DltReceiver receiverSock; /**< receiver for socket connection */
\r
126 DltReceiver receiverSerial; /**< receiver for serial connection */
\r
127 int client_connections; /**< counter for nr. of client connections */
\r
128 size_t baudrate; /**< Baudrate of serial connection */
\r
129 #ifdef DLT_SHM_ENABLE
\r
130 DltShm dlt_shm; /**< Shared memory handling */
\r
132 DltOfflineTrace offlineTrace; /**< Offline trace handling */
\r
138 unsigned long long wakeups_missed;
\r
139 } DltDaemonPeriodicData;
\r
144 DltDaemonLocal *daemon_local;
\r
145 } DltDaemonTimingPacketThreadData;
\r
147 typedef DltDaemonTimingPacketThreadData DltDaemonECUVersionThreadData;
\r
149 /* Function prototypes */
\r
150 void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
151 int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
152 int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
153 int dlt_daemon_local_connection_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
155 void dlt_daemon_daemonize(int verbose);
\r
156 void dlt_daemon_signal_handler(int sig);
\r
158 int dlt_daemon_process_client_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
159 int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
160 int dlt_daemon_process_client_messages_serial(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
161 int dlt_daemon_process_user_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
163 int dlt_daemon_process_user_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
164 int dlt_daemon_process_user_message_register_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
165 int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
166 int dlt_daemon_process_user_message_register_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
167 int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
168 int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
169 #ifdef DLT_SHM_ENABLE
\r
170 int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
172 int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
173 int dlt_daemon_process_user_message_log_mode(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
175 int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
\r
176 void dlt_daemon_timingpacket_thread(void *ptr);
\r
177 void dlt_daemon_ecu_version_thread(void *ptr);
\r
178 #if defined(DLT_SYSTEMD_WATCHDOG_ENABLE)
\r
179 void dlt_daemon_systemd_watchdog_thread(void *ptr);
\r
181 int dlt_daemon_make_periodic (unsigned int period, DltDaemonPeriodicData *info, int verbose);
\r
182 void dlt_daemon_wait_period(DltDaemonPeriodicData *info, int verbose);
\r
184 #endif /* DLT_DAEMON_H */
\r