summaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
authorSascha Philipp <sascha.philipp@continental-corporation.com>2014-10-06 08:15:36 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2015-03-25 17:12:12 +0100
commit5dd64263c2dc518aaf1d80f3521fa2cc452f6c8d (patch)
tree984eb55d90fb7ed7e9674f015c76fa402be89658 /src/daemon
parent27775afeeb2dc2ec86d41d22898fcdee57621afe (diff)
downloadDLT-daemon-5dd64263c2dc518aaf1d80f3521fa2cc452f6c8d.tar.gz
Fix content of offline trace
Change-Id: Id1fe0f438161fc81c5caee3c9c9627d9ddf5dbbf Signed-off-by: Sascha Philipp <sascha.philipp@continental-corporation.com>
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/dlt-daemon.c72
-rw-r--r--src/daemon/dlt_daemon_client.c13
-rw-r--r--src/daemon/dlt_daemon_client.h5
3 files changed, 42 insertions, 48 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index 8e4a82b..5e56302 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -1153,6 +1153,7 @@ void dlt_daemon_daemonize(int verbose)
This is a dlt-daemon only function. The libdlt has no equivalent function available. */
int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, char *str, int verbose)
{
+ DltMessage msg;
static uint8_t uiMsgCount = 0;
DltStandardHeaderExtra *pStandardExtra;
uint32_t uiType;
@@ -1166,62 +1167,53 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
PRINT_FUNCTION_VERBOSE(verbose);
// Set storageheader
- daemon_local->msg.storageheader = (DltStorageHeader *)(daemon_local->msg.headerbuffer);
- dlt_set_storageheader(daemon_local->msg.storageheader, daemon->ecuid);
+ msg.storageheader = (DltStorageHeader *)(msg.headerbuffer);
+ dlt_set_storageheader(msg.storageheader, daemon->ecuid);
// Set standardheader
- daemon_local->msg.standardheader = (DltStandardHeader *)(daemon_local->msg.headerbuffer + sizeof(DltStorageHeader));
- daemon_local->msg.standardheader->htyp = DLT_HTYP_UEH | DLT_HTYP_WEID | DLT_HTYP_WSID | DLT_HTYP_WTMS | DLT_HTYP_PROTOCOL_VERSION1;
- daemon_local->msg.standardheader->mcnt = uiMsgCount++;
+ msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
+ msg.standardheader->htyp = DLT_HTYP_UEH | DLT_HTYP_WEID | DLT_HTYP_WSID | DLT_HTYP_WTMS | DLT_HTYP_PROTOCOL_VERSION1;
+ msg.standardheader->mcnt = uiMsgCount++;
- uiExtraSize = DLT_STANDARD_HEADER_EXTRA_SIZE(daemon_local->msg.standardheader->htyp)+(DLT_IS_HTYP_UEH(daemon_local->msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
- daemon_local->msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + uiExtraSize;
+ uiExtraSize = DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp)+(DLT_IS_HTYP_UEH(msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
+ msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + uiExtraSize;
// Set extraheader
- pStandardExtra = (DltStandardHeaderExtra *)(daemon_local->msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader));
+ pStandardExtra = (DltStandardHeaderExtra *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader));
dlt_set_id(pStandardExtra->ecu, daemon->ecuid);
pStandardExtra->tmsp = DLT_HTOBE_32(dlt_uptime());
pStandardExtra->seid = DLT_HTOBE_32(getpid());
// Set extendedheader
- daemon_local->msg.extendedheader = (DltExtendedHeader *)(daemon_local->msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(daemon_local->msg.standardheader->htyp));
- daemon_local->msg.extendedheader->msin = DLT_MSIN_VERB | (DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT) | ((DLT_LOG_INFO << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN);
- daemon_local->msg.extendedheader->noar = 1;
- dlt_set_id(daemon_local->msg.extendedheader->apid, "DLTD");
- dlt_set_id(daemon_local->msg.extendedheader->ctid, "INTM");
+ msg.extendedheader = (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+ msg.extendedheader->msin = DLT_MSIN_VERB | (DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT) | ((DLT_LOG_INFO << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN);
+ msg.extendedheader->noar = 1;
+ dlt_set_id(msg.extendedheader->apid, "DLTD");
+ dlt_set_id(msg.extendedheader->ctid, "INTM");
// Set payload data...
uiType = DLT_TYPE_INFO_STRG;
uiSize = strlen(str) + 1;
- daemon_local->msg.datasize = sizeof(uint32_t) + sizeof(uint16_t) + uiSize;
+ msg.datasize = sizeof(uint32_t) + sizeof(uint16_t) + uiSize;
- // Ensure that the buffer size is large enough...
- if (daemon_local->msg.databuffer && (daemon_local->msg.databuffersize < daemon_local->msg.datasize))
- {
- free(daemon_local->msg.databuffer);
- daemon_local->msg.databuffer=0;
- }
- if (daemon_local->msg.databuffer == 0)
- {
- daemon_local->msg.databuffer = (uint8_t *) malloc(daemon_local->msg.datasize);
- daemon_local->msg.databuffersize = daemon_local->msg.datasize;
- }
- if (daemon_local->msg.databuffer==0)
+ msg.databuffer = (uint8_t *) malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
+ if (msg.databuffer==0)
{
dlt_log(LOG_WARNING,"Can't allocate buffer for get log info message\n");
return -1;
}
- daemon_local->msg.datasize = 0;
- memcpy((uint8_t *)(daemon_local->msg.databuffer + daemon_local->msg.datasize), (uint8_t *)(&uiType), sizeof(uint32_t));
- daemon_local->msg.datasize += sizeof(uint32_t);
- memcpy((uint8_t *)(daemon_local->msg.databuffer + daemon_local->msg.datasize), (uint8_t *)(&uiSize), sizeof(uint16_t));
- daemon_local->msg.datasize += sizeof(uint16_t);
- memcpy((uint8_t *)(daemon_local->msg.databuffer + daemon_local->msg.datasize), str, uiSize);
- daemon_local->msg.datasize += uiSize;
+ msg.datasize = 0;
+ memcpy((uint8_t *)(msg.databuffer + msg.datasize), (uint8_t *)(&uiType), sizeof(uint32_t));
+ msg.datasize += sizeof(uint32_t);
+ memcpy((uint8_t *)(msg.databuffer + msg.datasize), (uint8_t *)(&uiSize), sizeof(uint16_t));
+ msg.datasize += sizeof(uint16_t);
+ memcpy((uint8_t *)(msg.databuffer + msg.datasize), str, uiSize);
+ msg.datasize += uiSize;
// Calc lengths
- daemon_local->msg.standardheader->len = DLT_HTOBE_16(daemon_local->msg.headersize - sizeof(DltStorageHeader) + daemon_local->msg.datasize);
+ msg.standardheader->len = DLT_HTOBE_16(msg.headersize - sizeof(DltStorageHeader) + msg.datasize);
// Sending data...
{
@@ -1240,8 +1232,8 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
if((daemon->mode == DLT_USER_MODE_EXTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH))
{
- if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader),
- daemon_local->msg.databuffer,daemon_local->msg.datasize,verbose)))
+ if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,msg.headerbuffer,sizeof(DltStorageHeader),msg.headerbuffer+sizeof(DltStorageHeader),msg.headersize-sizeof(DltStorageHeader),
+ msg.databuffer,msg.datasize,verbose)))
{
if(ret == DLT_DAEMON_ERROR_BUFFER_FULL)
{
@@ -1251,6 +1243,8 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
}
}
+ free(msg.databuffer);
+
return 0;
}
@@ -2191,8 +2185,8 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemo
}
/* send message to client or write to log file */
- if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader),
- daemon_local->msg.databuffer,daemon_local->msg.datasize,verbose,0)))
+ if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,daemon_local->msg.headerbuffer,sizeof(DltStorageHeader),daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader),
+ daemon_local->msg.databuffer,daemon_local->msg.datasize,verbose)))
{
if(ret == DLT_DAEMON_ERROR_BUFFER_FULL)
{
@@ -2582,7 +2576,7 @@ int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daem
}
#endif
- if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_FORCE,daemon,daemon_local,data,length,0,0,verbose,0)))
+ if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_FORCE,daemon,daemon_local,0,0,data,length,0,0,verbose)))
{
return ret;
}
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c
index c5293de..fe75d90 100644
--- a/src/daemon/dlt_daemon_client.c
+++ b/src/daemon/dlt_daemon_client.c
@@ -58,7 +58,7 @@
/** Global text output buffer, mainly used for creation of error/warning strings */
static char str[DLT_DAEMON_TEXTBUFSIZE];
-int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_local,void* data1,int size1,void* data2,int size2,int verbose, int control)
+int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_local,void* storage_header,int storage_header_size,void* data1,int size1,void* data2,int size2,int verbose)
{
int ret;
int j;
@@ -101,8 +101,7 @@ int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_loc
if(((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH))
&& daemon_local->flags.offlineTraceDirectory[0])
{
- if(dlt_offline_trace_write(&(daemon_local->offlineTrace),daemon_local->msg.headerbuffer,daemon_local->msg.headersize,
- daemon_local->msg.databuffer,daemon_local->msg.datasize,0,0))
+ if(dlt_offline_trace_write(&(daemon_local->offlineTrace),storage_header,storage_header_size,data1,size1,data2,size2))
{
static int error_dlt_offline_trace_write_failed = 0;
if(!error_dlt_offline_trace_write_failed)
@@ -268,8 +267,8 @@ int dlt_daemon_client_send_control_message( int sock, DltDaemon *daemon, DltDaem
msg->standardheader->len = DLT_HTOBE_16(((uint16_t)len));
- if((ret=dlt_daemon_client_send(sock,daemon,daemon_local,msg->headerbuffer+sizeof(DltStorageHeader),msg->headersize-sizeof(DltStorageHeader),
- msg->databuffer,msg->datasize,verbose,1)))
+ if((ret=dlt_daemon_client_send(sock,daemon,daemon_local,msg->headerbuffer,sizeof(DltStorageHeader),msg->headerbuffer+sizeof(DltStorageHeader),msg->headersize-sizeof(DltStorageHeader),
+ msg->databuffer,msg->datasize,verbose)))
{
dlt_log(LOG_DEBUG,"dlt_daemon_control_send_control_message: DLT message send to all failed!.\n");
return ret;
@@ -1609,8 +1608,8 @@ void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, DltDaemonLocal
msg.standardheader->len = DLT_HTOBE_16(((uint16_t)len));
/* Send message */
- if((ret = dlt_daemon_client_send(sock,daemon,daemon_local,msg.headerbuffer+sizeof(DltStorageHeader),msg.headersize-sizeof(DltStorageHeader),
- msg.databuffer,msg.datasize,verbose,1)))
+ if((ret = dlt_daemon_client_send(sock,daemon,daemon_local,msg.headerbuffer,sizeof(DltStorageHeader),msg.headerbuffer+sizeof(DltStorageHeader),msg.headersize-sizeof(DltStorageHeader),
+ msg.databuffer,msg.datasize,verbose)))
{
}
diff --git a/src/daemon/dlt_daemon_client.h b/src/daemon/dlt_daemon_client.h
index c300d93..380f78c 100644
--- a/src/daemon/dlt_daemon_client.h
+++ b/src/daemon/dlt_daemon_client.h
@@ -67,15 +67,16 @@
* @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 storage_header pointer to data
+ * @param storage_header_size size of data
* @param data1 pointer to data
* @param size1 size of data
* @param data2 pointer to data
* @param size2 size of data
* @param verbose if set to true verbose information is printed out.
- * @param control if set to true message is not stored in offline trace
* @return unequal 0 if there is an error or buffer is full
*/
-int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_local,void* data1,int size1,void* data2,int size2,int verbose, int control);
+int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_local,void* storage_header,int storage_header_size,void* data1,int size1,void* data2,int size2,int verbose);
/**
* Send out response message to dlt client