summaryrefslogtreecommitdiff
path: root/src/lib/dlt_user.c
diff options
context:
space:
mode:
authorLassi Marttala <Lassi.LM.Marttala@partner.bmw.de>2012-09-28 16:36:34 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2012-11-26 12:39:30 +0100
commitaa1033cbf49615f46cf2d46f22cbad547ab216ae (patch)
tree44c5828ffea540ccb797f1a2e558f8a8c2d4b6cf /src/lib/dlt_user.c
parentb6192f12feff73c6860b424d962e3add23facff4 (diff)
downloadDLT-daemon-aa1033cbf49615f46cf2d46f22cbad547ab216ae.tar.gz
[GDLT-120]: More precise data sizes. Add automatic tests.
[GDLT-120]: Fix warnings. Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Diffstat (limited to 'src/lib/dlt_user.c')
-rw-r--r--src/lib/dlt_user.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index da30734..0edea8c 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -1878,7 +1878,7 @@ int dlt_user_trace_network_segmented_start(uint16_t *id, DltContext *handle, Dlt
}
/* Write stream handle */
- if(dlt_user_log_write_uint(&log, *id) < 0)
+ if(dlt_user_log_write_uint16(&log, *id) < 0)
{
return -1;
}
@@ -1890,7 +1890,7 @@ int dlt_user_trace_network_segmented_start(uint16_t *id, DltContext *handle, Dlt
}
/* Write size of payload */
- if(dlt_user_log_write_uint(&log, payload_len) < 0)
+ if(dlt_user_log_write_uint16(&log, payload_len) < 0)
{
return -1;
}
@@ -1904,13 +1904,13 @@ int dlt_user_trace_network_segmented_start(uint16_t *id, DltContext *handle, Dlt
segment_count--;
}
- if(dlt_user_log_write_uint(&log, segment_count) < 0)
+ if(dlt_user_log_write_uint16(&log, segment_count) < 0)
{
return -1;
}
/* Write length of one segment */
- if(dlt_user_log_write_uint(&log, DLT_MAX_TRACE_SEGMENT_SIZE) < 0)
+ if(dlt_user_log_write_uint16(&log, DLT_MAX_TRACE_SEGMENT_SIZE) < 0)
{
return -1;
}
@@ -1968,13 +1968,13 @@ int dlt_user_trace_network_segmented_segment(uint16_t id, DltContext *handle, Dl
}
/* Write stream handle */
- if(dlt_user_log_write_uint(&log, id) < 0)
+ if(dlt_user_log_write_uint16(&log, id) < 0)
{
return -1;
}
/* Write segment sequence number */
- if(dlt_user_log_write_uint(&log, sequence) < 0)
+ if(dlt_user_log_write_uint16(&log, sequence) < 0)
{
return -1;
}
@@ -2246,8 +2246,6 @@ int dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTraceType nw_
/* If truncation is allowed, check if we must do it */
if(allow_truncate > 0 && (header_len+payload_len+sizeof(uint16_t))>DLT_USER_BUF_MAX_SIZE)
{
- int truncated_payload_len = DLT_USER_BUF_MAX_SIZE - header_len - 40; // 40 == overhead bytes
-
/* Identify as truncated */
if(dlt_user_log_write_string(&log, "NWTR") < 0)
{
@@ -2261,11 +2259,18 @@ int dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTraceType nw_
}
/* Write original size of payload */
- if(dlt_user_log_write_uint(&log, payload_len) < 0)
+ if(dlt_user_log_write_uint16(&log, payload_len) < 0)
{
return -1;
}
+ /**
+ * Calculate maximum avaialble space in sending buffer after headers.
+ */
+
+ int truncated_payload_len = DLT_USER_BUF_MAX_SIZE -
+ log.size - sizeof(uint16_t) - sizeof(uint32_t);
+
/* Write truncated payload */
if (dlt_user_log_write_raw(&log, payload, truncated_payload_len) < 0)
{