diff options
Diffstat (limited to 'src/console')
-rw-r--r-- | src/console/dlt-control-common.c | 40 | ||||
-rw-r--r-- | src/console/dlt-control-common.h | 7 | ||||
-rw-r--r-- | src/console/dlt-control.c | 20 | ||||
-rw-r--r-- | src/console/dlt-passive-node-ctrl.c | 16 | ||||
-rw-r--r-- | src/console/dlt-receive.c | 22 | ||||
-rw-r--r-- | src/console/logstorage/dlt-logstorage-ctrl.c | 36 |
6 files changed, 99 insertions, 42 deletions
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; } diff --git a/src/console/dlt-control-common.h b/src/console/dlt-control-common.h index d743a81..73a8e21 100644 --- a/src/console/dlt-control-common.h +++ b/src/console/dlt-control-common.h @@ -61,8 +61,8 @@ typedef struct uint32_t size; /**< size of that data */ } DltControlMsgBody; -/* As verbosity, ecuid and timeout are needed during the communication, - * defining getter and setters here. +/* As verbosity, ecuid, timeout, send_serial_header, resync_serial_header are + * needed during the communication, defining getter and setters here. * Then there is no need to define them in the control's user application. */ int get_verbosity(void); @@ -74,6 +74,9 @@ void set_ecuid(char *); int get_timeout(void); void set_timeout(int); +void set_send_serial_header(const int value); +void set_resync_serial_header(const int value); + /* Parse dlt.conf file and return the value of requested configuration */ int dlt_parse_config_param(char *config_id, char **config_data); diff --git a/src/console/dlt-control.c b/src/console/dlt-control.c index 106e2a3..4474bac 100644 --- a/src/console/dlt-control.c +++ b/src/console/dlt-control.c @@ -104,6 +104,8 @@ typedef struct { int jvalue; int kvalue; int bvalue; + int sendSerialHeaderFlag; + int resyncSerialHeaderFlag; char ecuid[4]; DltFile file; DltFilter filter; @@ -125,6 +127,8 @@ void usage() printf("Options:\n"); printf(" -v Verbose mode\n"); printf(" -h Usage\n"); + printf(" -S Send message with serial header (Default: Without serial header)\n"); + printf(" -R Enable resync serial header\n"); printf(" -y Serial device mode\n"); printf(" -b baudrate Serial device baudrate (Default: 115200)\n"); printf(" -e ecuid Set ECU ID (Default: RECV)\n"); @@ -305,7 +309,7 @@ int main(int argc, char *argv[]) /* Default return value */ ret = 0; - while ((c = getopt (argc, argv, "vhye:b:a:c:s:m:x:t:l:r:d:f:i:ogjku")) != -1) + while ((c = getopt (argc, argv, "vhSRye:b:a:c:s:m:x:t:l:r:d:f:i:ogjku")) != -1) switch (c) { case 'v': { @@ -317,6 +321,16 @@ int main(int argc, char *argv[]) usage(); return -1; } + case 'S': + { + dltdata.sendSerialHeaderFlag = 1; + break; + } + case 'R': + { + dltdata.resyncSerialHeaderFlag = 1; + break; + } case 'y': { dltdata.yflag = DLT_CLIENT_MODE_SERIAL; @@ -514,6 +528,10 @@ int main(int argc, char *argv[]) dlt_client_setbaudrate(&g_dltclient, dltdata.bvalue); } + /* Update the send and resync serial header flags based on command line option */ + g_dltclient.send_serial_header = dltdata.sendSerialHeaderFlag; + g_dltclient.resync_serial_header = dltdata.resyncSerialHeaderFlag; + /* initialise structure to use DLT file */ dlt_file_init(&(dltdata.file), dltdata.vflag); diff --git a/src/console/dlt-passive-node-ctrl.c b/src/console/dlt-passive-node-ctrl.c index 6a02667..5e6b033 100644 --- a/src/console/dlt-passive-node-ctrl.c +++ b/src/console/dlt-passive-node-ctrl.c @@ -318,6 +318,8 @@ static void usage() printf(" -s Show passive node(s) connection status\n"); printf(" -t Specify connection timeout (Default: %ds)\n", DLT_CTRL_TIMEOUT); + printf(" -S Send message with serial header (Default: Without serial header)\n"); + printf(" -R Enable resync serial header\n"); printf(" -v Set verbose flag (Default:%d)\n", get_verbosity()); } @@ -338,7 +340,7 @@ static int parse_args(int argc, char *argv[]) /* Get command line arguments */ opterr = 0; - while ((c = getopt(argc, argv, "c:hn:stv")) != -1) + while ((c = getopt(argc, argv, "c:hn:st:SRv")) != -1) switch (c) { case 'c': state = (int)strtol(optarg, NULL, 10); @@ -365,6 +367,16 @@ static int parse_args(int argc, char *argv[]) case 't': set_timeout((int) strtol(optarg, NULL, 10)); break; + case 'S': + { + set_send_serial_header(1); + break; + } + case 'R': + { + set_resync_serial_header(1); + break; + } case 'v': set_verbosity(1); pr_verbose("Now in verbose mode.\n"); @@ -401,6 +413,8 @@ int main(int argc, char *argv[]) set_ecuid(NULL); set_timeout(DLT_CTRL_TIMEOUT); + set_send_serial_header(0); + set_resync_serial_header(0); /* Get command line arguments */ if (parse_args(argc, argv) != 0) diff --git a/src/console/dlt-receive.c b/src/console/dlt-receive.c index f41566a..c985447 100644 --- a/src/console/dlt-receive.c +++ b/src/console/dlt-receive.c @@ -125,6 +125,8 @@ typedef struct { char *jvalue; /* filename for json filter file */ char *evalue; int bvalue; + int sendSerialHeaderFlag; + int resyncSerialHeaderFlag; int64_t climit; char ecuid[4]; int ohandle; @@ -155,6 +157,8 @@ void usage() printf(" -s Print DLT messages; only headers\n"); printf(" -v Verbose mode\n"); printf(" -h Usage\n"); + printf(" -S Send message with serial header (Default: Without serial header)\n"); + printf(" -R Enable resync serial header\n"); printf(" -y Serial device mode\n"); printf(" -u UDP multicast mode\n"); printf(" -b baudrate Serial device baudrate (Default: 115200)\n"); @@ -327,6 +331,8 @@ int main(int argc, char *argv[]) dltdata.jvalue = 0; dltdata.evalue = 0; dltdata.bvalue = 0; + dltdata.sendSerialHeaderFlag = 0; + dltdata.resyncSerialHeaderFlag = 0; dltdata.climit = -1; /* default: -1 = unlimited */ dltdata.ohandle = -1; dltdata.totalbytes = 0; @@ -348,7 +354,7 @@ int main(int argc, char *argv[]) /* Fetch command line arguments */ opterr = 0; - while ((c = getopt (argc, argv, "vashyuxmf:j:o:e:b:c:p:")) != -1) + while ((c = getopt (argc, argv, "vashSRyuxmf:j:o:e:b:c:p:")) != -1) switch (c) { case 'v': { @@ -380,6 +386,16 @@ int main(int argc, char *argv[]) usage(); return -1; } + case 'S': + { + dltdata.sendSerialHeaderFlag = 1; + break; + } + case 'R': + { + dltdata.resyncSerialHeaderFlag = 1; + break; + } case 'y': { dltdata.yflag = 1; @@ -521,6 +537,10 @@ int main(int argc, char *argv[]) dlt_client_setbaudrate(&dltclient, dltdata.bvalue); } + /* Update the send and resync serial header flags based on command line option */ + dltclient.send_serial_header = dltdata.sendSerialHeaderFlag; + dltclient.resync_serial_header = dltdata.resyncSerialHeaderFlag; + /* initialise structure to use DLT file */ dlt_file_init(&(dltdata.file), dltdata.vflag); diff --git a/src/console/logstorage/dlt-logstorage-ctrl.c b/src/console/logstorage/dlt-logstorage-ctrl.c index cd0e040..2629df6 100644 --- a/src/console/logstorage/dlt-logstorage-ctrl.c +++ b/src/console/logstorage/dlt-logstorage-ctrl.c @@ -406,19 +406,23 @@ static void usage(void) printf(" Don't use -s together with -d and -c\n"); printf(" -t Specify connection timeout (Default: %ds)\n", DLT_CTRL_TIMEOUT); + printf(" -S --send-header Send message with serial header (Default: Without serial header)\n"); + printf(" -R --resync-header Enable resync serial header\n"); printf(" -v --verbose Set verbose flag (Default:%d)\n", get_verbosity()); } static struct option long_options[] = { - { "command", required_argument, 0, 'c' }, - { "daemonize", optional_argument, 0, 'd' }, - { "ecuid", required_argument, 0, 'e' }, - { "help", no_argument, 0, 'h' }, - { "path", required_argument, 0, 'p' }, - { "snapshot", optional_argument, 0, 's' }, - { "timeout", required_argument, 0, 't' }, - { "verbose", no_argument, 0, 'v' }, - { 0, 0, 0, 0 } + {"command", required_argument, 0, 'c'}, + {"daemonize", optional_argument, 0, 'd'}, + {"ecuid", required_argument, 0, 'e'}, + {"help", no_argument, 0, 'h'}, + {"path", required_argument, 0, 'p'}, + {"snapshot", optional_argument, 0, 's'}, + {"timeout", required_argument, 0, 't'}, + {"send-header", no_argument, 0, 'S'}, + {"resync-header", no_argument, 0, 'R'}, + {"verbose", no_argument, 0, 'v'}, + {0, 0, 0, 0} }; /** @brief Parses the application arguments @@ -437,7 +441,7 @@ static int parse_args(int argc, char *argv[]) while ((c = getopt_long(argc, argv, - ":s::t:he:p:d::c:v", + ":s::t:hSRe:p:d::c:v", long_options, &long_index)) != -1) switch (c) { @@ -454,6 +458,16 @@ static int parse_args(int argc, char *argv[]) case 't': set_timeout((int) strtol(optarg, NULL, 10)); break; + case 'S': + { + set_send_serial_header(1); + break; + } + case 'R': + { + set_resync_serial_header(1); + break; + } case 'h': usage(); return -1; @@ -535,6 +549,8 @@ int main(int argc, char *argv[]) set_ecuid(NULL); set_timeout(DLT_CTRL_TIMEOUT); + set_send_serial_header(0); + set_resync_serial_header(0); /* Get command line arguments */ if (parse_args(argc, argv) != 0) |