2 * Dlt- Diagnostic Log and Trace daemon
\r
5 * Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de>
7 * This program is free software; you can redistribute it and/or modify it under the terms of the
8 * GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
11 * Public License, version 2.1, for more details.
13 * You should have received a copy of the GNU Lesser General Public License, version 2.1, along
14 * with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
16 * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may
17 * also be applicable to programs even in cases in which the program is not a library in the technical sense.
19 * Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may
20 * license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to
21 * license your linked modules under the GNU Lesser General Public License, version 2.1, you
22 * may use the program under the following exception.
24 * As a special exception, the copyright holders of DLT give you permission to combine DLT
25 * with software programs or libraries that are released under any license unless such a combination is not
26 * permitted by the license of such a software program or library. You may copy and distribute such a
27 * system following the terms of the GNU Lesser General Public License, version 2.1, including this
28 * special exception, for DLT and the licenses of the other code concerned.
30 * Note that people who make modified versions of DLT are not obligated to grant this special exception
31 * for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License,
32 * version 2.1, gives permission to release a modified version without this exception; this exception
33 * also makes it possible to release a modified version which carries forward this exception.
39 /*******************************************************************************
\r
41 ** SRC-MODULE: dlt_daemon_common.h **
\r
43 ** TARGET : linux **
\r
47 ** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
\r
54 ** PLATFORM DEPENDANT [yes/no]: yes **
\r
56 ** TO BE CHANGED BY USER [yes/no]: no **
\r
58 *******************************************************************************/
\r
60 /*******************************************************************************
\r
61 ** Author Identity **
\r
62 ********************************************************************************
\r
64 ** Initials Name Company **
\r
65 ** -------- ------------------------- ---------------------------------- **
\r
66 ** aw Alexander Wenzel BMW **
\r
67 ** mk Markus Klein Fraunhofer ESK **
\r
68 *******************************************************************************/
\r
70 /*******************************************************************************
\r
71 ** Revision Control History **
\r
72 *******************************************************************************/
\r
75 * $LastChangedRevision: 1670 $
\r
76 * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
\r
78 Initials Date Comment
\r
79 aw 15.02.2010 initial
\r
82 #ifndef DLT_DAEMON_COMMON_H
\r
83 #define DLT_DAEMON_COMMON_H
\r
86 \defgroup daemonapi DLT Daemon API
\r
87 \addtogroup daemonapi
\r
91 #include <semaphore.h>
\r
92 #include "dlt_common.h"
\r
98 #define DLT_DAEMON_RINGBUFFER_SIZE 100000 /**< Ring buffer size for storing log messages while no client is connected */
\r
100 #define DLT_DAEMON_STORE_TO_BUFFER -2 /**< Constant value to identify the command "store to buffer" */
\r
102 /* Use a semaphore or mutex from your OS to prevent concurrent access to the DLT buffer. */
\r
104 #define DLT_DAEMON_SEM_LOCK() { sem_wait(&dlt_daemon_mutex); }
\r
105 #define DLT_DAEMON_SEM_FREE() { sem_post(&dlt_daemon_mutex); }
\r
106 extern sem_t dlt_daemon_mutex;
\r
110 * The parameters of a daemon application.
\r
114 char apid[DLT_ID_SIZE]; /**< application id */
\r
115 pid_t pid; /**< process id of user application */
\r
116 int user_handle; /**< connection handle for connection to user application */
\r
117 char *application_description; /**< context description */
\r
118 int num_contexts; /**< number of contexts for this application */
\r
119 } DltDaemonApplication;
\r
122 * The parameters of a daemon context.
\r
126 char apid[DLT_ID_SIZE]; /**< application id */
\r
127 char ctid[DLT_ID_SIZE]; /**< context id */
\r
128 int8_t log_level; /**< the current log level of the context */
\r
129 int8_t trace_status; /**< the current trace status of the context */
\r
130 int log_level_pos; /**< offset of context in context field on user application */
\r
131 int user_handle; /**< connection handle for connection to user application */
\r
132 char *context_description; /**< context description */
\r
133 } DltDaemonContext;
\r
136 * The parameters of a daemon.
\r
140 int num_contexts; /**< Total number of all contexts in all applications */
\r
141 DltDaemonContext *contexts; /**< Pointer to contexts */
\r
142 int num_applications; /**< Number of available application */
\r
143 DltDaemonApplication *applications; /**< Pointer to applications */
\r
144 int8_t default_log_level; /**< Default log level (of daemon) */
\r
145 int8_t default_trace_status; /**< Default trace status (of daemon) */
\r
146 int message_buffer_overflow; /**< Set to one, if buffer overflow has occured, zero otherwise */
\r
147 int runtime_context_cfg_loaded; /**< Set to one, if runtime context configuration has been loaded, zero otherwise */
\r
148 char ecuid[DLT_ID_SIZE]; /**< ECU ID of daemon */
\r
149 int sendserialheader; /**< 1: send serial header; 0 don't send serial header */
\r
150 int timingpackets; /**< 1: send continous timing packets; 0 don't send continous timing packets */
\r
151 DltRingBuffer client_ringbuffer; /**< Ring-buffer for storing received logs while no client connection is available */
\r
152 char runtime_application_cfg[256]; /**< Path and filename of persistent application configuration */
\r
153 char runtime_context_cfg[256]; /**< Path and filename of persistent context configuration */
\r
157 * Initialise the dlt daemon structure
\r
158 * This function must be called before using further dlt daemon structure
\r
159 * @param daemon pointer to dlt daemon structure
\r
160 * @param runtime_directory Directory of persistent configuration
\r
161 * @param verbose if set to true verbose information is printed out.
\r
162 * @return negative value if there was an error
\r
164 int dlt_daemon_init(DltDaemon *daemon,const char *runtime_directory,int verbose);
\r
166 * De-Initialise the dlt daemon structure
\r
167 * @param daemon pointer to dlt daemon structure
\r
168 * @param verbose if set to true verbose information is printed out.
\r
169 * @return negative value if there was an error
\r
171 int dlt_daemon_free(DltDaemon *daemon,int verbose);
\r
174 * Add (new) application to internal application management
\r
175 * @param daemon pointer to dlt daemon structure
\r
176 * @param apid pointer to application id
\r
177 * @param pid process id of user application
\r
178 * @param description description of application
\r
179 * @param verbose if set to true verbose information is printed out.
\r
180 * @return Pointer to added context, null pointer on error
\r
182 DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,char *apid,pid_t pid,char *description, int verbose);
\r
184 * Delete application from internal application management
\r
185 * @param daemon pointer to dlt daemon structure
\r
186 * @param application pointer to application to be deleted
\r
187 * @param verbose if set to true verbose information is printed out.
\r
188 * @return negative value if there was an error
\r
190 int dlt_daemon_application_del(DltDaemon *daemon, DltDaemonApplication *application, int verbose);
\r
192 * Find application with specific application id
\r
193 * @param daemon pointer to dlt daemon structure
\r
194 * @param apid pointer to application id
\r
195 * @param verbose if set to true verbose information is printed out.
\r
196 * @return Pointer to application, null pointer on error or not found
\r
198 DltDaemonApplication* dlt_daemon_application_find(DltDaemon *daemon,char *apid,int verbose);
\r
200 * Load applications from file to internal context management
\r
201 * @param daemon pointer to dlt daemon structure
\r
202 * @param filename name of file to be used for loading
\r
203 * @param verbose if set to true verbose information is printed out.
\r
204 * @return negative value if there was an error
\r
206 int dlt_daemon_applications_load(DltDaemon *daemon,const char *filename, int verbose);
\r
208 * Save applications from internal context management to file
\r
209 * @param daemon pointer to dlt daemon structure
\r
210 * @param filename name of file to be used for saving
\r
211 * @param verbose if set to true verbose information is printed out.
\r
212 * @return negative value if there was an error
\r
214 int dlt_daemon_applications_save(DltDaemon *daemon,const char *filename, int verbose);
\r
216 * Clear all applications in internal application management
\r
217 * @param daemon pointer to dlt daemon structure
\r
218 * @param verbose if set to true verbose information is printed out.
\r
219 * @return negative value if there was an error
\r
221 int dlt_daemon_applications_clear(DltDaemon *daemon,int verbose);
\r
224 * Add (new) context to internal context management
\r
225 * @param daemon pointer to dlt daemon structure
\r
226 * @param apid pointer to application id
\r
227 * @param ctid pointer to context id
\r
228 * @param log_level log level of context
\r
229 * @param trace_status trace status of context
\r
230 * @param log_level_pos offset of context in context field on user application
\r
231 * @param user_handle connection handle for connection to user application
\r
232 * @param description description of context
\r
233 * @param verbose if set to true verbose information is printed out.
\r
234 * @return Pointer to added context, null pointer on error
\r
236 DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,char *apid,char *ctid,int8_t log_level,int8_t trace_status,int log_level_pos, int user_handle,char *description,int verbose);
\r
238 * Delete context from internal context management
\r
239 * @param daemon pointer to dlt daemon structure
\r
240 * @param context pointer to context to be deleted
\r
241 * @param verbose if set to true verbose information is printed out.
\r
242 * @return negative value if there was an error
\r
244 int dlt_daemon_context_del(DltDaemon *daemon, DltDaemonContext* context, int verbose);
\r
246 * Find context with specific application id and context id
\r
247 * @param daemon pointer to dlt daemon structure
\r
248 * @param apid pointer to application id
\r
249 * @param ctid pointer to context id
\r
250 * @param verbose if set to true verbose information is printed out.
\r
251 * @return Pointer to context, null pointer on error or not found
\r
253 DltDaemonContext* dlt_daemon_context_find(DltDaemon *daemon,char *apid,char *ctid,int verbose);
\r
255 * Clear all contexts in internal context management
\r
256 * @param daemon pointer to dlt daemon structure
\r
257 * @param verbose if set to true verbose information is printed out.
\r
258 * @return negative value if there was an error
\r
260 int dlt_daemon_contexts_clear(DltDaemon *daemon,int verbose);
\r
262 * Load contexts from file to internal context management
\r
263 * @param daemon pointer to dlt daemon structure
\r
264 * @param filename name of file to be used for loading
\r
265 * @param verbose if set to true verbose information is printed out.
\r
266 * @return negative value if there was an error
\r
268 int dlt_daemon_contexts_load(DltDaemon *daemon,const char *filename, int verbose);
\r
270 * Save contexts from internal context management to file
\r
271 * @param daemon pointer to dlt daemon structure
\r
272 * @param filename name of file to be used for saving
\r
273 * @param verbose if set to true verbose information is printed out.
\r
274 * @return negative value if there was an error
\r
276 int dlt_daemon_contexts_save(DltDaemon *daemon,const char *filename, int verbose);
\r
279 * Send user message DLT_USER_MESSAGE_LOG_LEVEL to user application
\r
280 * @param daemon pointer to dlt daemon structure
\r
281 * @param context pointer to context for response
\r
282 * @param verbose if set to true verbose information is printed out.
\r
283 * @return negative value if there was an error
\r
285 int dlt_daemon_user_send_log_level(DltDaemon *daemon,DltDaemonContext *context, int verbose);
\r
287 * Send user messages to all user applications using default context, or trace status
\r
288 * to update those values
\r
289 * @param daemon pointer to dlt daemon structure
\r
290 * @param verbose if set to true verbose information is printed out.
\r
292 void dlt_daemon_user_send_default_update(DltDaemon *daemon, int verbose);
\r
295 * Process received control message from dlt client
\r
296 * @param sock connection handle used for sending response
\r
297 * @param daemon pointer to dlt daemon structure
\r
298 * @param msg pointer to received control message
\r
299 * @param verbose if set to true verbose information is printed out.
\r
301 int dlt_daemon_control_process_control(int sock, DltDaemon *daemon, DltMessage *msg, int verbose);
\r
303 * Generate response to control message from dlt client
\r
304 * @param sock connection handle used for sending response
\r
305 * @param daemon pointer to dlt daemon structure
\r
306 * @param service_id service id of control message
\r
307 * @param status status of response (e.g. ok, not supported, error)
\r
308 * @param verbose if set to true verbose information is printed out.
\r
310 void dlt_daemon_control_service_response(int sock, DltDaemon *daemon, uint32_t service_id, int8_t status, int verbose);
\r
312 * Send out response message to dlt client
\r
313 * @param sock connection handle used for sending response
\r
314 * @param daemon pointer to dlt daemon structure
\r
315 * @param msg pointer to response message
\r
316 * @param appid pointer to application id to be used in response message
\r
317 * @param contid pointer to context id to be used in response message
\r
318 * @param verbose if set to true verbose information is printed out.
\r
320 void dlt_daemon_control_send_control_message(int sock, DltDaemon *daemon, DltMessage *msg, char* appid, char* contid, int verbose);
\r
323 * Process and generate response to received sw injection control message
\r
324 * @param sock connection handle used for sending response
\r
325 * @param daemon pointer to dlt daemon structure
\r
326 * @param msg pointer to received sw injection control message
\r
327 * @param verbose if set to true verbose information is printed out.
\r
329 void dlt_daemon_control_callsw_cinjection(int sock, DltDaemon *daemon, DltMessage *msg, int verbose);
\r
331 * Process and generate response to received set log level control message
\r
332 * @param sock connection handle used for sending response
\r
333 * @param daemon pointer to dlt daemon structure
\r
334 * @param msg pointer to received control message
\r
335 * @param verbose if set to true verbose information is printed out.
\r
337 void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltMessage *msg, int verbose);
\r
339 * Process and generate response to received set trace status control message
\r
340 * @param sock connection handle used for sending response
\r
341 * @param daemon pointer to dlt daemon structure
\r
342 * @param msg pointer to received control message
\r
343 * @param verbose if set to true verbose information is printed out.
\r
345 void dlt_daemon_control_set_trace_status(int sock, DltDaemon *daemon, DltMessage *msg, int verbose);
\r
347 * Process and generate response to received set default log level control message
\r
348 * @param sock connection handle used for sending response
\r
349 * @param daemon pointer to dlt daemon structure
\r
350 * @param msg pointer to received control message
\r
351 * @param verbose if set to true verbose information is printed out.
\r
353 void dlt_daemon_control_set_default_log_level(int sock, DltDaemon *daemon, DltMessage *msg, int verbose);
\r
355 * Process and generate response to received set default trace status control message
\r
356 * @param sock connection handle used for sending response
\r
357 * @param daemon pointer to dlt daemon structure
\r
358 * @param msg pointer to received control message
\r
359 * @param verbose if set to true verbose information is printed out.
\r
361 void dlt_daemon_control_set_default_trace_status(int sock, DltDaemon *daemon, DltMessage *msg, int verbose);
\r
363 * Process and generate response to set timing packets control message
\r
364 * @param sock connection handle used for sending response
\r
365 * @param daemon pointer to dlt daemon structure
\r
366 * @param msg pointer to received control message
\r
367 * @param verbose if set to true verbose information is printed out.
\r
369 void dlt_daemon_control_set_timing_packets(int sock, DltDaemon *daemon, DltMessage *msg, int verbose);
\r
371 * Process and generate response to received get software version control message
\r
372 * @param sock connection handle used for sending response
\r
373 * @param daemon pointer to dlt daemon structure
\r
374 * @param verbose if set to true verbose information is printed out.
\r
376 void dlt_daemon_control_get_software_version(int sock, DltDaemon *daemon, int verbose);
\r
378 * Process and generate response to received get default log level control message
\r
379 * @param sock connection handle used for sending response
\r
380 * @param daemon pointer to dlt daemon structure
\r
381 * @param verbose if set to true verbose information is printed out.
\r
383 void dlt_daemon_control_get_default_log_level(int sock, DltDaemon *daemon, int verbose);
\r
385 * Process and generate response to received get log info control message
\r
386 * @param sock connection handle used for sending response
\r
387 * @param daemon pointer to dlt daemon structure
\r
388 * @param msg pointer to received control message
\r
389 * @param verbose if set to true verbose information is printed out.
\r
391 void dlt_daemon_control_get_log_info(int sock, DltDaemon *daemon, DltMessage *msg, int verbose);
\r
393 * Process and generate response to message buffer overflow control message
\r
394 * @param sock connection handle used for sending response
\r
395 * @param daemon pointer to dlt daemon structure
\r
396 * @param verbose if set to true verbose information is printed out.
\r
398 void dlt_daemon_control_message_buffer_overflow(int sock, DltDaemon *daemon, int verbose);
\r
400 * Process reset to factory default control message
\r
401 * @param daemon pointer to dlt daemon structure
\r
402 * @param filename name of file containing the runtime defaults for applications
\r
403 * @param filename1 name of file containing the runtime defaults for contexts
\r
404 * @param verbose if set to true verbose information is printed out.
\r
406 void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *filename, const char *filename1, int verbose);
\r
408 * Send time control message
\r
409 * @param sock connection handle used for sending response
\r
410 * @param daemon pointer to dlt daemon structure
\r
411 * @param verbose if set to true verbose information is printed out.
\r
413 void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, int verbose);
\r
423 #endif /* DLT_DAEMON_COMMON_H */
\r