From 837ec68ecc1f105474d81461d83b365ab1f8129d Mon Sep 17 00:00:00 2001 From: Vo Trung Chi Date: Wed, 26 Dec 2018 15:23:09 +0700 Subject: console: provides args option to enable send/receive serial header Provides argument option to enable send and resync serial header via command line. Signed-off-by: Vo Trung Chi --- src/console/dlt-control-common.c | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) (limited to 'src/console/dlt-control-common.c') diff --git a/src/console/dlt-control-common.c b/src/console/dlt-control-common.c index f58d826..7e16bde 100644 --- a/src/console/dlt-control-common.c +++ b/src/console/dlt-control-common.c @@ -155,6 +155,16 @@ void set_timeout(int t) DLT_CTRL_TIMEOUT); } +void set_send_serial_header(const int value) +{ + g_client.send_serial_header = value; +} + +void set_resync_serial_header(const int value) +{ + g_client.resync_serial_header = value; +} + int dlt_parse_config_param(char *config_id, char **config_data) { FILE *pFile = NULL; @@ -223,32 +233,6 @@ int dlt_parse_config_param(char *config_id, char **config_data) return 0; } -/** @brief Send a message to the daemon through the socket. - * - * The socket as to be opened and active before sending. - * - * @param sock The socket to send the message through - * @param msg The message to be send in DLT format. - * - * @return 0 on success, -1 otherwise. - */ -static int dlt_control_send_message_to_socket(int sock, DltMessage *msg) -{ - if (send(sock, - (const char *)(msg->headerbuffer + sizeof(DltStorageHeader)), - msg->headersize - sizeof(DltStorageHeader), 0) == -1) { - pr_error("Sending message header failed: %s\n", strerror(errno)); - return -1; - } - - if (send(sock, (const char *)msg->databuffer, msg->datasize, 0) == -1) { - pr_error("Sending message failed: %s\n", strerror(errno)); - return -1; - } - - return 0; -} - /** @brief Prepare the extra headers of a DLT message * * Modifies the extra headers of the message so that it can be sent. @@ -574,8 +558,10 @@ int dlt_control_send_message(DltControlMsgBody *body, int timeout) /* Re-init the return value */ callback_return = -1; - if (dlt_control_send_message_to_socket(g_client.sock, msg) != 0) { + if (dlt_client_send_message_to_socket(&g_client, msg) != DLT_RETURN_OK) + { pr_error("Sending message to daemon failed\n"); + dlt_message_free(msg, get_verbosity()); free(msg); return -1; } -- cgit v1.2.1