automotive-dlt
dlt-control-common.h File Reference
#include <stdio.h>
#include "dlt_common.h"
Include dependency graph for dlt-control-common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  DltControlMsgBody
 

Macros

#define DLT_CTRL_TIMEOUT   10
 
#define DLT_CTRL_ECUID_LEN   10
 
#define DLT_DAEMON_FLAG_MAX   256
 
#define pr_fmt(fmt)   fmt
 
#define PRINT_OUT   stderr
 
#define pr_error(fmt, ...)   ({ fprintf(PRINT_OUT, pr_fmt(fmt), ## __VA_ARGS__); fflush(PRINT_OUT); })
 
#define pr_verbose(fmt, ...)   ({ if (get_verbosity()) { fprintf(PRINT_OUT, pr_fmt(fmt), ## __VA_ARGS__); fflush(PRINT_OUT); } })
 
#define DLT_CTRL_DEFAULT_ECUID   "ECU1"
 

Functions

int get_verbosity (void)
 
void set_verbosity (int)
 
char * get_ecuid (void)
 
void set_ecuid (char *)
 
long get_timeout (void)
 
void set_timeout (long)
 
int dlt_parse_config_param (char *config_id, char **config_data)
 
int dlt_control_init (int(*response_analyser)(char *, void *, int), char *ecuid, int verbosity)
 Control communication initialization. More...
 
int dlt_control_send_message (DltControlMsgBody *, int)
 Send a message to the daemon and wait for the asynchronous answer. More...
 
int dlt_control_deinit (void)
 Control communication clean-up. More...
 

Detailed Description

app begin@ Copyright (C) 2015 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 console apps.

Author
Christoph Lipka clipk.nosp@m.a@jp.nosp@m..adit.nosp@m.-jv..nosp@m.com ADIT 2015
Frederic Berat fbera.nosp@m.t@de.nosp@m..adit.nosp@m.-jv..nosp@m.com ADIT 2015

For further information see http://www.genivi.org/. end@

Definition in file dlt-control-common.h.

Macro Definition Documentation

#define DLT_CTRL_DEFAULT_ECUID   "ECU1"

Definition at line 51 of file dlt-control-common.h.

Referenced by usage().

#define DLT_CTRL_ECUID_LEN   10

Definition at line 33 of file dlt-control-common.h.

Referenced by set_ecuid().

#define DLT_CTRL_TIMEOUT   10

Definition at line 31 of file dlt-control-common.h.

Referenced by main(), set_timeout(), and usage().

#define DLT_DAEMON_FLAG_MAX   256

Definition at line 34 of file dlt-control-common.h.

Referenced by dlt_parse_config_param(), and option_file_parser().

#define pr_fmt (   fmt)    fmt

Definition at line 37 of file dlt-control-common.h.

#define PRINT_OUT   stderr

Definition at line 41 of file dlt-control-common.h.

Function Documentation

int dlt_control_deinit ( void  )

Control communication clean-up.

Cancels the listener thread and clean=up the dlt client structure.

Returns
0 on success, -1 otherwise.

Definition at line 688 of file dlt-control-common.c.

References daemon_connect_thread, dlt_client_cleanup(), and get_verbosity().

Referenced by dlt_logstorage_ctrl_setup_event_loop(), dlt_logstorage_ctrl_single_request(), and dlt_passive_node_ctrl_single_request().

int dlt_control_init ( int(*)(char *, void *, int)  response_analyzer,
char *  ecuid,
int  verbosity 
)

Control communication initialization.

This will prepare the DLT connection and the thread dedicated to the response listening.

Parameters
response_analyzerUser defined function used to analyze the response
ecuidThe ECUID to provide to the daemon
verbosityThe verbosity level
Returns
0 on success, -1 otherwise.

Definition at line 648 of file dlt-control-common.c.

References daemon_connect_thread, dlt_client_cleanup(), dlt_control_callback(), dlt_control_init_connection(), dlt_control_listen_to_daemon(), get_verbosity(), NULL, pr_error, response_analyzer_cb, set_ecuid(), and set_verbosity().

Referenced by dlt_logstorage_ctrl_setup_event_loop(), dlt_logstorage_ctrl_single_request(), and dlt_passive_node_ctrl_single_request().

int dlt_control_send_message ( DltControlMsgBody body,
int  timeout 
)

Send a message to the daemon and wait for the asynchronous answer.

The answer is received and analyzed by a dedicated thread. Thus we need to wait for the signal from this thread and then read the return value to be provided to the user. In case of timeout, this function fails. The message provided by the user is formated in DLT format before sending.

Parameters
bodyThe message provided by the user
timeoutThe time to wait before considering that no answer will come
Returns
The user response analyzer return value, -1 in case of early error.

Definition at line 581 of file dlt-control-common.c.

References answer_cond, answer_lock, callback_return, dlt_control_prepare_message(), dlt_control_send_message_to_socket(), dlt_message_free(), get_verbosity(), NULL, pr_error, and DltClient::sock.

Referenced by dlt_logstorage_send_event(), and dlt_passive_node_ctrl_single_request().

int dlt_parse_config_param ( char *  config_id,
char **  config_data 
)
void set_ecuid ( char *  )
void set_timeout ( long  )

Definition at line 146 of file dlt-control-common.c.

References DLT_CTRL_TIMEOUT, local_timeout, and pr_error.

Referenced by main(), and parse_args().

void set_verbosity ( int  )

Definition at line 101 of file dlt-control-common.c.

References local_verbose.

Referenced by dlt_control_init(), and parse_args().