automotive-dlt
dlt-passive-node-ctrl.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <pthread.h>
#include "dlt_protocol.h"
#include "dlt_client.h"
#include "dlt-control-common.h"
#include "dlt_daemon_connection_types.h"
Include dependency graph for dlt-passive-node-ctrl.c:

Go to the source code of this file.

Data Structures

struct  PassiveNodeOptions
 

Macros

#define MAX_RESPONSE_LENGTH   32
 
#define DLT_NODE_CONNECT   1
 
#define DLT_NODE_DISCONNECT   0
 
#define DLT_NODE_CONNECT_UNDEF   999
 
#define DLT_GATEWAY_CONNECTED   2
 
#define DLT_NODE_CONNECTED_STR   "Connected"
 
#define DLT_NODE_DISCONNECTED_STR   "Disconnected"
 
#define UNDEFINED   999
 

Functions

unsigned int get_command (void)
 
void set_command (unsigned int c)
 
unsigned int get_connection_state (void)
 
void set_connection_state (unsigned int s)
 
void set_node_id (char *id)
 
char * get_node_id ()
 
static void dlt_print_passive_node_status (DltServicePassiveNodeConnectionInfo *info)
 Print passive node status information. More...
 
static int dlt_passive_node_analyze_response (char *answer, void *payload, int len)
 Analyze received DLT Daemon response. More...
 
DltControlMsgBodydlt_passive_node_prepare_message_body ()
 Prepare message body to be send to DLT Daemon. More...
 
void dlt_passive_node_destroy_message_body (DltControlMsgBody *msg_body)
 Destroy message body. More...
 
static int dlt_passive_node_ctrl_single_request ()
 Send a single command to DLT daemon and wait for response. More...
 
static void usage ()
 
static int parse_args (int argc, char *argv[])
 Parse application arguments. More...
 
int main (int argc, char *argv[])
 Entry point. More...
 

Variables

static struct PassiveNodeOptions g_options
 

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

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

Definition in file dlt-passive-node-ctrl.c.

Macro Definition Documentation

#define DLT_GATEWAY_CONNECTED   2

Definition at line 67 of file dlt-passive-node-ctrl.c.

Referenced by dlt_print_passive_node_status().

#define DLT_NODE_CONNECT   1

Definition at line 63 of file dlt-passive-node-ctrl.c.

Referenced by parse_args(), and set_connection_state().

#define DLT_NODE_CONNECT_UNDEF   999

Definition at line 65 of file dlt-passive-node-ctrl.c.

Referenced by main().

#define DLT_NODE_CONNECTED_STR   "Connected"

Definition at line 68 of file dlt-passive-node-ctrl.c.

Referenced by dlt_print_passive_node_status().

#define DLT_NODE_DISCONNECT   0

Definition at line 64 of file dlt-passive-node-ctrl.c.

Referenced by parse_args(), and set_connection_state().

#define DLT_NODE_DISCONNECTED_STR   "Disconnected"

Definition at line 69 of file dlt-passive-node-ctrl.c.

Referenced by dlt_print_passive_node_status().

#define MAX_RESPONSE_LENGTH   32

Definition at line 61 of file dlt-passive-node-ctrl.c.

Referenced by dlt_passive_node_analyze_response().

#define UNDEFINED   999

Definition at line 71 of file dlt-passive-node-ctrl.c.

Referenced by main().

Function Documentation

static int dlt_passive_node_analyze_response ( char *  answer,
void *  payload,
int  len 
)
static

Analyze received DLT Daemon response.

This function checks the received message. In particular, it checks the answer string 'service(<ID>, {ok, error, perm_denied})'. In any case the g_callback_return variable will be set as well which is evaluated in the main function after the communication thread returned.

Parameters
messageReceived DLT Message
Returns
0 if daemon returns 'ok' message, -1 otherwise

Definition at line 177 of file dlt-passive-node-ctrl.c.

References dlt_print_passive_node_status(), DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS, get_command(), MAX_RESPONSE_LENGTH, NULL, pr_error, and pr_verbose.

Referenced by dlt_passive_node_ctrl_single_request().

static int dlt_passive_node_ctrl_single_request ( )
static

Send a single command to DLT daemon and wait for response.

Returns
0 on success, -1 on error

Definition at line 299 of file dlt-passive-node-ctrl.c.

References dlt_control_deinit(), dlt_control_init(), dlt_control_send_message(), dlt_passive_node_analyze_response(), dlt_passive_node_destroy_message_body(), dlt_passive_node_prepare_message_body(), get_ecuid(), get_timeout(), get_verbosity(), NULL, and pr_error.

Referenced by main().

void dlt_passive_node_destroy_message_body ( DltControlMsgBody msg_body)

Destroy message body.

Definition at line 280 of file dlt-passive-node-ctrl.c.

References DltControlMsgBody::data, and NULL.

Referenced by dlt_passive_node_ctrl_single_request().

DltControlMsgBody* dlt_passive_node_prepare_message_body ( )
static void dlt_print_passive_node_status ( DltServicePassiveNodeConnectionInfo *  info)
static

Print passive node status information.

Parameters
infoDltServicePassiveNodeConnectionInfo

Definition at line 136 of file dlt-passive-node-ctrl.c.

References DLT_GATEWAY_CONNECTED, DLT_ID_SIZE, DLT_NODE_CONNECTED_STR, DLT_NODE_DISCONNECTED_STR, and NULL.

Referenced by dlt_passive_node_analyze_response().

unsigned int get_command ( void  )
unsigned int get_connection_state ( void  )
char* get_node_id ( )
int main ( int  argc,
char *  argv[] 
)

Entry point.

Execute the argument parser and call the main feature accordingly

Parameters
argcamount of arguments
argvargument table
Returns
0 on success, -1 otherwise

Definition at line 426 of file dlt-passive-node-ctrl.c.

References PassiveNodeOptions::connection_state, DLT_CTRL_TIMEOUT, DLT_NODE_CONNECT_UNDEF, dlt_passive_node_ctrl_single_request(), DLT_SERVICE_ID_PASSIVE_NODE_CONNECT, g_options, get_command(), PassiveNodeOptions::node_id, NULL, parse_args(), pr_error, pr_verbose, set_ecuid(), set_timeout(), UNDEFINED, and usage().

static int parse_args ( int  argc,
char *  argv[] 
)
static

Parse application arguments.

The arguments are parsed and saved in static structure for future use.

Parameters
argcamount of arguments
argvargument table
Returns
0 on success, -1 otherwise

Definition at line 356 of file dlt-passive-node-ctrl.c.

References DLT_NODE_CONNECT, DLT_NODE_DISCONNECT, DLT_SERVICE_ID_PASSIVE_NODE_CONNECT, DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS, NULL, pr_error, pr_verbose, set_command(), set_connection_state(), set_node_id(), set_timeout(), set_verbosity(), and usage().

Referenced by main().

void set_command ( unsigned int  c)

Definition at line 89 of file dlt-passive-node-ctrl.c.

References PassiveNodeOptions::command, and g_options.

Referenced by parse_args(), and set_connection_state().

void set_connection_state ( unsigned int  s)
void set_node_id ( char *  id)

Definition at line 113 of file dlt-passive-node-ctrl.c.

References DLT_ID_SIZE, g_options, PassiveNodeOptions::node_id, and pr_error.

Referenced by parse_args().

static void usage ( void  )
static

Definition at line 331 of file dlt-passive-node-ctrl.c.

References DLT_CTRL_TIMEOUT, and get_verbosity().

Referenced by main(), and parse_args().

Variable Documentation

struct PassiveNodeOptions g_options
static
Initial value:
= {
.command = UNDEFINED,
.connection_state = UNDEFINED,
.node_id = {'\0'},
}
#define UNDEFINED

Referenced by get_command(), get_connection_state(), get_node_id(), main(), set_command(), set_connection_state(), and set_node_id().