summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Willers <M.Willers@gmx.net>2020-04-21 17:23:30 +0200
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2020-05-18 08:21:27 +0900
commitd80779e5e4bb33010ef079189a56803b032a7f2b (patch)
tree69a47cec514e59e4c7dcbd293c3fa3d5171ce2c3
parent1e414546eaf2049136af33029b9e6df8356fce95 (diff)
downloadDLT-daemon-d80779e5e4bb33010ef079189a56803b032a7f2b.tar.gz
Add functions for writing strings with known sizes
Signed-off-by: Martin Willers <M.Willers@gmx.net>
-rw-r--r--include/dlt/dlt_user.h34
-rw-r--r--src/lib/dlt_user.c16
2 files changed, 50 insertions, 0 deletions
diff --git a/include/dlt/dlt_user.h b/include/dlt/dlt_user.h
index 766d349..0533346 100644
--- a/include/dlt/dlt_user.h
+++ b/include/dlt/dlt_user.h
@@ -382,6 +382,17 @@ DltReturnValue dlt_user_log_write_int64(DltContextData *log, int64_t data);
DltReturnValue dlt_user_log_write_string(DltContextData *log, const char *text);
/**
+ * Write a potentially non-null-terminated ASCII string into a DLT log message.
+ * dlt_user_log_write_start has to be called before adding any attributes to the log message.
+ * Finish sending log message by calling dlt_user_log_write_finish.
+ * @param log pointer to an object containing information about logging context data
+ * @param text pointer to the parameter written into log message
+ * @param length length in bytes of @a text (without any termination character)
+ * @return Value from DltReturnValue enum
+ */
+DltReturnValue dlt_user_log_write_sized_string(DltContextData *log, const char *text, uint16_t length);
+
+/**
* Write a constant null terminated ASCII string into a DLT log message.
* In non verbose mode DLT parameter will not be send at all.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
@@ -393,6 +404,18 @@ DltReturnValue dlt_user_log_write_string(DltContextData *log, const char *text);
DltReturnValue dlt_user_log_write_constant_string(DltContextData *log, const char *text);
/**
+ * Write a constant, potentially non-null-terminated ASCII string into a DLT log message.
+ * In non verbose mode DLT parameter will not be send at all.
+ * dlt_user_log_write_start has to be called before adding any attributes to the log message.
+ * Finish sending log message by calling dlt_user_log_write_finish.
+ * @param log pointer to an object containing information about logging context data
+ * @param text pointer to the parameter written into log message containing null termination.
+ * @param length length in bytes of @a text (without any termination character)
+ * @return Value from DltReturnValue enum
+ */
+DltReturnValue dlt_user_log_write_sized_constant_string(DltContextData *log, const char *text, uint16_t length);
+
+/**
* Write a null terminated UTF8 string into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
@@ -403,6 +426,17 @@ DltReturnValue dlt_user_log_write_constant_string(DltContextData *log, const cha
DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *text);
/**
+ * Write a potentially non-null-terminated UTF8 string into a DLT log message.
+ * dlt_user_log_write_start has to be called before adding any attributes to the log message.
+ * Finish sending log message by calling dlt_user_log_write_finish.
+ * @param log pointer to an object containing information about logging context data
+ * @param text pointer to the parameter written into log message
+ * @param length length in bytes of @a text (without any termination character)
+ * @return Value from DltReturnValue enum
+ */
+DltReturnValue dlt_user_log_write_sized_utf8_string(DltContextData *log, const char *text, uint16_t length);
+
+/**
* Write a binary memory block into a DLT log message.
* dlt_user_log_write_start has to be called before adding any attributes to the log message.
* Finish sending log message by calling dlt_user_log_write_finish.
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index 9c9734f..318e3ef 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -2333,17 +2333,33 @@ DltReturnValue dlt_user_log_write_string(DltContextData *log, const char *text)
return dlt_user_log_write_string_utils(log, text, ASCII_STRING);
}
+DltReturnValue dlt_user_log_write_sized_string(DltContextData *log, const char *text, uint16_t length)
+{
+ return dlt_user_log_write_sized_string_utils(log, text, length, ASCII_STRING);
+}
+
DltReturnValue dlt_user_log_write_constant_string(DltContextData *log, const char *text)
{
/* Send parameter only in verbose mode */
return dlt_user.verbose_mode ? dlt_user_log_write_string(log, text) : DLT_RETURN_OK;
}
+DltReturnValue dlt_user_log_write_sized_constant_string(DltContextData *log, const char *text, uint16_t length)
+{
+ /* Send parameter only in verbose mode */
+ return dlt_user.verbose_mode ? dlt_user_log_write_sized_string(log, text, length) : DLT_RETURN_OK;
+}
+
DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *text)
{
return dlt_user_log_write_string_utils(log, text, UTF8_STRING);
}
+DltReturnValue dlt_user_log_write_sized_utf8_string(DltContextData *log, const char *text, uint16_t length)
+{
+ return dlt_user_log_write_sized_string_utils(log, text, length, UTF8_STRING);
+}
+
DltReturnValue dlt_user_log_write_sized_string_utils(DltContextData *log, const char *text, uint16_t length, const enum StringType type)
{
uint16_t arg_size = 0;