diff options
author | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2014-09-11 16:14:07 +0200 |
---|---|---|
committer | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2014-09-11 16:24:43 +0200 |
commit | c8d990b893838b3263ac020b095f1a520908e815 (patch) | |
tree | dbc8f21021a6c478b4f0e5ddcf79afcd8c700646 /src/daemon | |
parent | 406f947a0f8dca7ac1fbdc6b1df2bbe37af1b669 (diff) | |
download | DLT-daemon-c8d990b893838b3263ac020b095f1a520908e815.tar.gz |
Added new API to send marker message from application.
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/dlt-daemon.c | 37 | ||||
-rwxr-xr-x | src/daemon/dlt-daemon.h | 1 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_client.c | 51 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_client.h | 11 |
4 files changed, 98 insertions, 2 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index c8b4703..1a98ca9 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -1473,6 +1473,14 @@ int dlt_daemon_process_user_messages(DltDaemon *daemon, DltDaemonLocal *daemon_l } break; } + case DLT_USER_MESSAGE_MARKER: + { + if (dlt_daemon_process_user_message_marker(daemon, daemon_local, daemon_local->flags.vflag)==-1) + { + run_loop=0; + } + break; + } default: { dlt_log(LOG_ERR,"(Internal) Invalid user message type received!\n"); @@ -2345,6 +2353,35 @@ int dlt_daemon_process_user_message_log_mode(DltDaemon *daemon, DltDaemonLocal * return 0; } +int dlt_daemon_process_user_message_marker(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose) +{ + PRINT_FUNCTION_VERBOSE(verbose); + + if ((daemon==0) || (daemon_local==0)) + { + dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_process_user_message_marker()\n"); + return -1; + } + + if (daemon_local->receiver.bytesRcvd < (int32_t)(sizeof(DltUserHeader))) + { + /* Not enough bytes received */ + return -1; + } + + /* Create automatic unregister context response for unregistered context */ + dlt_daemon_control_message_marker(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,verbose); + + /* keep not read data in buffer */ + if (dlt_receiver_remove(&(daemon_local->receiver),sizeof(DltUserHeader)+sizeof(DltUserControlMsgLogMode))==-1) + { + dlt_log(LOG_ERR,"Can't remove bytes from receiver for user message log mode\n"); + return -1; + } + + return 0; +} + int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose) { int ret; diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h index dfe4de3..022387a 100755 --- a/src/daemon/dlt-daemon.h +++ b/src/daemon/dlt-daemon.h @@ -190,6 +190,7 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon, DltDaemonLocal *d #endif
int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
int dlt_daemon_process_user_message_log_mode(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
+int dlt_daemon_process_user_message_marker(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
void dlt_daemon_timingpacket_thread(void *ptr);
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c index 5f85b15..b0a11c9 100644 --- a/src/daemon/dlt_daemon_client.c +++ b/src/daemon/dlt_daemon_client.c @@ -1183,6 +1183,57 @@ int dlt_daemon_control_message_timezone(int sock, DltDaemon *daemon, DltDaemonLo return 0; } +int dlt_daemon_control_message_marker(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose) +{ + DltMessage msg; + DltServiceMarker *resp; + + PRINT_FUNCTION_VERBOSE(verbose); + + if (daemon==0) + { + return -1; + } + + /* initialise new message */ + if (dlt_message_init(&msg,0)==-1) + { + return -1; + } + + /* prepare payload of data */ + msg.datasize = sizeof(DltServiceMarker); + if (msg.databuffer && (msg.databuffersize < msg.datasize)) + { + free(msg.databuffer); + msg.databuffer=0; + } + if (msg.databuffer == 0){ + msg.databuffer = (uint8_t *) malloc(msg.datasize); + msg.databuffersize = msg.datasize; + } + if (msg.databuffer==0) + { + return -1; + } + + resp = (DltServiceMarker*) msg.databuffer; + resp->service_id = DLT_SERVICE_ID_MARKER; + resp->status = DLT_SERVICE_RESPONSE_OK; + + /* send message */ + if(dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose)) + { + dlt_message_free(&msg,0); + return -1; + } + + /* free message */ + dlt_message_free(&msg,0); + + return 0; +} + void dlt_daemon_control_callsw_cinjection(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose) { char apid[DLT_ID_SIZE],ctid[DLT_ID_SIZE]; diff --git a/src/daemon/dlt_daemon_client.h b/src/daemon/dlt_daemon_client.h index 34715c9..c9ceec4 100644 --- a/src/daemon/dlt_daemon_client.h +++ b/src/daemon/dlt_daemon_client.h @@ -154,15 +154,22 @@ int dlt_daemon_control_message_unregister_context(int sock, DltDaemon *daemon, D */ int dlt_daemon_control_message_connection_info(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, uint8_t state, char* comid, int verbose); /** - * Send control message connection info (add on to AUTOSAR standard) + * Send control message timezone (add on to AUTOSAR standard) * @param sock connection handle used for sending response * @param daemon pointer to dlt daemon structure * @param daemon_local pointer to dlt daemon local structure - * @param timezone timezone on target * @param verbose if set to true verbose information is printed out. */ int dlt_daemon_control_message_timezone(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose); /** + * Send control message marker (add on to AUTOSAR standard) + * @param sock connection handle used for sending response + * @param daemon pointer to dlt daemon structure + * @param daemon_local pointer to dlt daemon local structure + * @param verbose if set to true verbose information is printed out. + */ +int dlt_daemon_control_message_marker(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose); +/** * Process received control message from dlt client * @param sock connection handle used for sending response * @param daemon pointer to dlt daemon structure |