diff options
author | Vo Trung Chi <Chi.VoTrung@vn.bosch.com> | 2018-12-26 15:23:09 +0700 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2021-10-05 11:19:26 +0900 |
commit | 0ee7fdff3d6bb2f2055e7083fa48728f4d274661 (patch) | |
tree | e191edd9e2736a6a2ebc642769a8b9c67ad60060 | |
parent | cc4d1e04fe4a8b57b137c347ad9fd66166b6250a (diff) | |
download | DLT-daemon-0ee7fdff3d6bb2f2055e7083fa48728f4d274661.tar.gz |
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 <Chi.VoTrung@vn.bosch.com>
-rw-r--r-- | doc/dlt-logstorage-ctrl.1.md | 8 | ||||
-rw-r--r-- | doc/dlt-passive-node-ctrl.1.md | 8 | ||||
-rw-r--r-- | doc/dlt-receive.1.md | 8 | ||||
-rw-r--r-- | doc/dlt_multinode.md | 2 | ||||
-rw-r--r-- | doc/dlt_offline_logstorage.md | 2 | ||||
-rw-r--r-- | include/dlt/dlt_client.h | 13 | ||||
-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 | ||||
-rw-r--r-- | src/lib/dlt_client.c | 67 | ||||
-rw-r--r-- | src/tests/dlt-test-client.c | 22 | ||||
-rw-r--r-- | src/tests/dlt-test-multi-process-client.c | 22 | ||||
-rw-r--r-- | src/tests/dlt-test-stress-client.c | 22 | ||||
-rw-r--r-- | tests/dlt_test_receiver.c | 22 |
17 files changed, 285 insertions, 52 deletions
diff --git a/doc/dlt-logstorage-ctrl.1.md b/doc/dlt-logstorage-ctrl.1.md index 1e80fb8..931e452 100644 --- a/doc/dlt-logstorage-ctrl.1.md +++ b/doc/dlt-logstorage-ctrl.1.md @@ -38,6 +38,14 @@ Send a trigger to DLT Daemon to connect/disconnect a certain offline logstorage : Specify connection timeout. Default is: 10s. +-S + +: Send message with serial header (Default: Without serial header) + +-R + +: Enable resync serial header + # EXAMPLES Activate the offline logstorage device mounted on /mnt/dltlog diff --git a/doc/dlt-passive-node-ctrl.1.md b/doc/dlt-passive-node-ctrl.1.md index a691c75..6525fad 100644 --- a/doc/dlt-passive-node-ctrl.1.md +++ b/doc/dlt-passive-node-ctrl.1.md @@ -34,6 +34,14 @@ Send a trigger to DLT daemon to (dis)connect a passive node or get current passi : Specify connection timeout (Default: 10s) +-S + +: Send message with serial header (Default: Without serial header) + +-R + +: Enable resync serial header + -v : Set verbose flag (Default:0) diff --git a/doc/dlt-receive.1.md b/doc/dlt-receive.1.md index b6184e4..38eed53 100644 --- a/doc/dlt-receive.1.md +++ b/doc/dlt-receive.1.md @@ -46,6 +46,14 @@ Receive DLT messages from DLT daemon and print or store the messages. : Verbose mode. +-S + +: Send message with serial header (Default: Without serial header) + +-R + +: Enable resync serial header + -y : Serial device mode. diff --git a/doc/dlt_multinode.md b/doc/dlt_multinode.md index bfb13aa..8d15985 100644 --- a/doc/dlt_multinode.md +++ b/doc/dlt_multinode.md @@ -79,5 +79,7 @@ Options: -n passive Node identifier (e.g. ECU2) -s Show passive node(s) connection status -t Specify connection timeout (Default: 10s) + -S Send message with serial header (Default: Without serial header) + -R Enable resync serial header -v Set verbose flag (Default:0) ``` diff --git a/doc/dlt_offline_logstorage.md b/doc/dlt_offline_logstorage.md index 5a38b99..3d29dab 100644 --- a/doc/dlt_offline_logstorage.md +++ b/doc/dlt_offline_logstorage.md @@ -198,6 +198,8 @@ Options: -p Mount point path -s Sync Logstorage cache -t Specify connection timeout (Default: 10s) + -S Send message with serial header (Default: Without serial header) + -R Enable resync serial header -v Set verbose flag (Default:0) ``` diff --git a/include/dlt/dlt_client.h b/include/dlt/dlt_client.h index 77f0cee..f1802cb 100644 --- a/include/dlt/dlt_client.h +++ b/include/dlt/dlt_client.h @@ -95,9 +95,11 @@ typedef struct int port; /**< Port for TCP connections (optional) */ char *serialDevice; /**< serialDevice Devicename of serial device */ char *socketPath; /**< socketPath Unix socket path */ - char ecuid[4]; /**< ECUiD */ + char ecuid[4]; /**< ECUiD */ speed_t baudrate; /**< baudrate Baudrate of serial interface, as speed_t */ DltClientMode mode; /**< mode DltClientMode */ + int send_serial_header; /**< (Boolean) Send DLT messages with serial header */ + int resync_serial_header; /**< (Boolean) Resync to serial header on all connection */ } DltClient; # ifdef __cplusplus @@ -145,6 +147,15 @@ DltReturnValue dlt_client_cleanup(DltClient *client, int verbose); * @return Value from DltReturnValue enum */ DltReturnValue dlt_client_main_loop(DltClient *client, void *data, int verbose); + +/** + * Send a message to the daemon through the socket. + * @param client pointer to dlt client structure. + * @param msg The message to be send in DLT format. + * @return Value from DltReturnValue enum. + */ +DltReturnValue dlt_client_send_message_to_socket(DltClient *client, DltMessage *msg); + /** * Send ancontrol message to the dlt daemon * @param client pointer to dlt client structure 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) diff --git a/src/lib/dlt_client.c b/src/lib/dlt_client.c index 25c311f..cddada7 100644 --- a/src/lib/dlt_client.c +++ b/src/lib/dlt_client.c @@ -474,8 +474,10 @@ DltReturnValue dlt_client_main_loop(DltClient *client, void *data, int verbose) } while (dlt_message_read(&msg, (unsigned char *)(client->receiver.buf), - (unsigned int) client->receiver.bytesRcvd, 0, - verbose) == DLT_MESSAGE_ERROR_OK) { + client->receiver.bytesRcvd, + client->resync_serial_header, + verbose) == DLT_MESSAGE_ERROR_OK) + { /* Call callback function */ if (message_callback_function) (*message_callback_function)(&msg, data); @@ -514,6 +516,48 @@ DltReturnValue dlt_client_main_loop(DltClient *client, void *data, int verbose) return DLT_RETURN_OK; } +DltReturnValue dlt_client_send_message_to_socket(DltClient *client, DltMessage *msg) +{ + int ret = 0; + + if ((client == NULL) || (client->sock < 0) + || (msg == NULL) || (msg->databuffer == NULL)) + { + dlt_log(LOG_ERR, "Invalid parameters\n"); + return DLT_RETURN_ERROR; + } + + if (client->send_serial_header) + { + ret = send(client->sock, (const char *)dltSerialHeader, + sizeof(dltSerialHeader), 0); + if (ret < 0) + { + dlt_vlog(LOG_ERR, "Sending serial header failed: %s\n", + strerror(errno)); + return DLT_RETURN_ERROR; + } + } + + ret = send(client->sock, + (const char *)(msg->headerbuffer + sizeof(DltStorageHeader)), + msg->headersize - sizeof(DltStorageHeader), 0); + if (ret < 0) + { + dlt_vlog(LOG_ERR, "Sending message header failed: %s\n", strerror(errno)); + return DLT_RETURN_ERROR; + } + + ret = send(client->sock, (const char *)msg->databuffer, msg->datasize, 0); + if ( ret < 0) + { + dlt_vlog(LOG_ERR, "Sending message failed: %s\n", strerror(errno)); + return DLT_RETURN_ERROR; + } + + return DLT_RETURN_OK; +} + DltReturnValue dlt_client_send_ctrl_msg(DltClient *client, char *apid, char *ctid, uint8_t *payload, uint32_t size) { DltMessage msg; @@ -616,6 +660,16 @@ DltReturnValue dlt_client_send_ctrl_msg(DltClient *client, char *apid, char *cti /* Send data (without storage header) */ if ((client->mode == DLT_CLIENT_MODE_TCP) || (client->mode == DLT_CLIENT_MODE_SERIAL)) { /* via FileDescriptor */ + if (client->send_serial_header) + { + ret = write(client->sock, dltSerialHeader, sizeof(dltSerialHeader)); + if (ret < 0) + { + dlt_log(LOG_ERR, "Sending message failed\n"); + dlt_message_free(&msg, 0); + return DLT_RETURN_ERROR; + } + } ret = (int) write(client->sock, msg.headerbuffer + sizeof(DltStorageHeader), msg.headersize - sizeof(DltStorageHeader)); @@ -643,9 +697,12 @@ DltReturnValue dlt_client_send_ctrl_msg(DltClient *client, char *apid, char *cti } else { /* via Socket */ - send(client->sock, (const char *)(msg.headerbuffer + sizeof(DltStorageHeader)), - msg.headersize - sizeof(DltStorageHeader), 0); - send(client->sock, (const char *)msg.databuffer, msg.datasize, 0); + if (dlt_client_send_message_to_socket(client, &msg) == DLT_RETURN_ERROR) + { + dlt_log(LOG_ERR, "Sending message to socket failed\n"); + dlt_message_free(&msg, 0); + return DLT_RETURN_ERROR; + } } /* free message */ diff --git a/src/tests/dlt-test-client.c b/src/tests/dlt-test-client.c index 5273aa2..d1fbe0a 100644 --- a/src/tests/dlt-test-client.c +++ b/src/tests/dlt-test-client.c @@ -101,6 +101,8 @@ typedef struct char *tvalue; char *evalue; int bvalue; + int sendSerialHeaderFlag; + int resyncSerialHeaderFlag; char ecuid[4]; int ohandle; @@ -139,6 +141,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(" -b baudrate Serial device baudrate (Default: 115200)\n"); printf(" -e ecuid Set ECU ID (Default: ECU1)\n"); @@ -167,6 +171,8 @@ int main(int argc, char *argv[]) dltdata.fvalue = 0; dltdata.evalue = 0; dltdata.bvalue = 0; + dltdata.sendSerialHeaderFlag = 0; + dltdata.resyncSerialHeaderFlag = 0; dltdata.ohandle = -1; dltdata.running_test = 0; @@ -185,7 +191,7 @@ int main(int argc, char *argv[]) /* Fetch command line arguments */ opterr = 0; - while ((c = getopt (argc, argv, "vashyxmf:o:e:b:z:")) != -1) + while ((c = getopt (argc, argv, "vashSRyxmf:o:e:b:z:")) != -1) switch (c) { case 'v': { @@ -217,6 +223,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; @@ -315,6 +331,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/tests/dlt-test-multi-process-client.c b/src/tests/dlt-test-multi-process-client.c index 56b6d48..8853d57 100644 --- a/src/tests/dlt-test-multi-process-client.c +++ b/src/tests/dlt-test-multi-process-client.c @@ -66,6 +66,8 @@ typedef struct { char *output; int output_handle; int messages_left; + int sendSerialHeaderFlag; + int resyncSerialHeaderFlag; DltClient *client_ref; } s_parameters; @@ -93,6 +95,8 @@ void usage(char *name) printf("%s", version); printf("Options:\n"); printf(" -m Total messages to receive. (Default: 10000)\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(" -v Verbose. Increases the verbosity level of dlt client library.\n"); @@ -110,6 +114,8 @@ void init_params(s_parameters *params) params->output = NULL; params->output_handle = -1; params->baudrate = 115200; + params->sendSerialHeaderFlag = 0; + params->resyncSerialHeaderFlag = 0; } /** @@ -121,11 +127,21 @@ int read_params(s_parameters *params, int argc, char *argv[]) int c; opterr = 0; - while ((c = getopt(argc, argv, "m:yb:vo:")) != -1) + while ((c = getopt(argc, argv, "m:yb:vo:SR")) != -1) switch (c) { case 'm': params->max_messages = atoi(optarg); break; + case 'S': + { + params->sendSerialHeaderFlag = 1; + break; + } + case 'R': + { + params->resyncSerialHeaderFlag = 1; + break; + } case 'y': params->serial = 1; break; @@ -204,6 +220,10 @@ int main(int argc, char *argv[]) dlt_client_init(&client, params.verbose); dlt_client_register_message_callback(receive); + /* Update the send and resync serial header flags based on command line option */ + client.send_serial_header = params.sendSerialHeaderFlag; + client.resync_serial_header = params.resyncSerialHeaderFlag; + err = init_dlt_connect(&client, ¶ms, argc, argv); if (err != 0) { diff --git a/src/tests/dlt-test-stress-client.c b/src/tests/dlt-test-stress-client.c index 1210386..5cbfeba 100644 --- a/src/tests/dlt-test-stress-client.c +++ b/src/tests/dlt-test-stress-client.c @@ -96,6 +96,8 @@ typedef struct char *evalue; int nvalue; int bvalue; + int sendSerialHeaderFlag; + int resyncSerialHeaderFlag; char ecuid[4]; int ohandle; @@ -141,6 +143,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(" -b baudrate Serial device baudrate (Default: 115200)\n"); printf(" -e ecuid Set ECU ID (Default: ECU1)\n"); @@ -173,6 +177,8 @@ int main(int argc, char *argv[]) dltdata.fvalue = 0; dltdata.evalue = 0; dltdata.bvalue = 0; + dltdata.sendSerialHeaderFlag = 0; + dltdata.resyncSerialHeaderFlag = 0; dltdata.nvalue = 10000; dltdata.ohandle = -1; @@ -199,7 +205,7 @@ int main(int argc, char *argv[]) /* Fetch command line arguments */ opterr = 0; - while ((c = getopt (argc, argv, "vashyxmf:o:e:b:n:")) != -1) + while ((c = getopt (argc, argv, "vashSRyxmf:o:e:b:n:")) != -1) switch (c) { case 'v': { @@ -231,6 +237,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; @@ -326,6 +342,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/tests/dlt_test_receiver.c b/tests/dlt_test_receiver.c index 9698d15..23e827c 100644 --- a/tests/dlt_test_receiver.c +++ b/tests/dlt_test_receiver.c @@ -95,6 +95,8 @@ typedef struct { int systemloggervalue; char ecuid[4]; int ohandle; + int sendSerialHeaderFlag; + int resyncSerialHeaderFlag; DltFile file; DltFilter filter; } DltReceiveData; @@ -118,6 +120,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(" -f Activate filetransfer test case\n"); printf(" -s Activate systemd journal test case\n"); @@ -143,6 +147,8 @@ int main(int argc, char *argv[]) dltdata.ovalue = 0; dltdata.evalue = 0; dltdata.bvalue = 0; + dltdata.sendSerialHeaderFlag = 0; + dltdata.resyncSerialHeaderFlag = 0; dltdata.ohandle = -1; dltdata.filetransfervalue = 0; dltdata.systemjournalvalue = 0; @@ -150,7 +156,7 @@ int main(int argc, char *argv[]) /* Fetch command line arguments */ opterr = 0; - while ((c = getopt (argc, argv, "vshyfla:o:e:b:")) != -1) + while ((c = getopt (argc, argv, "vshSRyfla:o:e:b:")) != -1) switch (c) { case 'v': { @@ -162,6 +168,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; @@ -262,6 +278,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); |