From 3bb7eb24092ff771ccfd1119f8c1088f3f78f981 Mon Sep 17 00:00:00 2001 From: Martin Willers Date: Mon, 31 May 2021 07:45:48 +0200 Subject: Add missing string functions (#309) Signed-off-by: Martin Willers --- include/dlt/dlt_user.h.in | 64 ++++++++++++++++++++++++++++++++++++++++--- include/dlt/dlt_user_macros.h | 38 +++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/dlt/dlt_user.h.in b/include/dlt/dlt_user.h.in index e4a1f06..960b9f0 100644 --- a/include/dlt/dlt_user.h.in +++ b/include/dlt/dlt_user.h.in @@ -496,7 +496,7 @@ DltReturnValue dlt_user_log_write_sized_string(DltContextData *log, const char * /** * Write a constant null terminated ASCII string into a DLT log message. - * In non verbose mode DLT parameter will not be send at all. + * In non verbose mode DLT parameter will not be sent 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 @@ -507,11 +507,11 @@ DltReturnValue dlt_user_log_write_constant_string(DltContextData *log, const cha /** * 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. + * In non verbose mode DLT parameter will not be sent 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 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 */ @@ -538,6 +538,29 @@ DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *t */ DltReturnValue dlt_user_log_write_sized_utf8_string(DltContextData *log, const char *text, uint16_t length); +/** + * Write a constant null terminated UTF8 string into a DLT log message. + * In non verbose mode DLT parameter will not be sent 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. + * @return Value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_constant_utf8_string(DltContextData *log, const char *text); + +/** + * Write a constant, potentially non-null-terminated UTF8 string into a DLT log message. + * In non verbose mode DLT parameter will not be sent 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 + * @param length length in bytes of @a text (without any termination character) + * @return Value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_sized_constant_utf8_string(DltContextData *log, const char *text, uint16_t length); + /** * Write a null-terminated ASCII string with "name" attribute into a DLT log message. * dlt_user_log_write_start has to be called before adding any parameters to the log message. @@ -595,7 +618,7 @@ DltReturnValue dlt_user_log_write_constant_string_attr(DltContextData *log, cons * and no content to the message. * * @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 text pointer to the parameter written into log message * @param length length in bytes of @a text (without any termination character) * @param name the "name" attribute (or NULL) * @return value from DltReturnValue enum @@ -633,6 +656,39 @@ DltReturnValue dlt_user_log_write_utf8_string_attr(DltContextData *log, const ch */ DltReturnValue dlt_user_log_write_sized_utf8_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name); +/** + * Write a constant, null-terminated UTF8 string with "name" attribute into a DLT log message. + * In non-verbose mode, this parameter will not be sent at all. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name is NULL, this function will add an attribute field with length 0 + * and no content to the message. + * + * @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 name the "name" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_constant_utf8_string_attr(DltContextData *log, const char *text, const char *name); + +/** + * Write a constant, potentially non-null-terminated UTF8 string with "name" attribute into a DLT log message. + * In non-verbose mode, this parameter will not be sent at all. + * dlt_user_log_write_start has to be called before adding any parameters to the log message. + * Finish building a log message by calling dlt_user_log_write_finish. + * + * If @a name is NULL, this function will add an attribute field with length 0 + * and no content to the message. + * + * @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) + * @param name the "name" attribute (or NULL) + * @return value from DltReturnValue enum + */ +DltReturnValue dlt_user_log_write_sized_constant_utf8_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name); + /** * 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. diff --git a/include/dlt/dlt_user_macros.h b/include/dlt/dlt_user_macros.h index 24b7b7a..f7d8033 100644 --- a/include/dlt/dlt_user_macros.h +++ b/include/dlt/dlt_user_macros.h @@ -368,6 +368,24 @@ #define DLT_SIZED_UTF8(TEXT, LEN) \ (void)dlt_user_log_write_sized_utf8_string(&log_local, TEXT, LEN) +/** + * Add constant utf8-encoded string parameter to the log messsage. + * @param TEXT Constant UTF8-encoded string + */ +#define DLT_CUTF8(TEXT) \ + (void)dlt_user_log_write_constant_utf8_string(&log_local, TEXT) + +/** + * Add constant utf8-encoded string parameter with given length to the log messsage. + * The string in @a TEXT does not need to be null-terminated, but + * the copied string will be null-terminated at its destination + * in the message buffer. + * @param TEXT Constant UTF8-encoded string + * @param LEN length in bytes to take from @a TEXT + */ +#define DLT_SIZED_CUTF8(TEXT, LEN) \ + (void)dlt_user_log_write_sized_constant_utf8_string(&log_local, TEXT, LEN) + /** * Add string parameter with "name" attribute to the log messsage. * @param TEXT ASCII string @@ -428,6 +446,26 @@ #define DLT_SIZED_UTF8_ATTR(TEXT, LEN, NAME) \ (void)dlt_user_log_write_sized_utf8_string_attr(&log_local, TEXT, LEN, ATTR) +/** + * Add constant utf8-encoded string parameter with "name" attribute to the log messsage. + * @param TEXT Constant UTF8-encoded string + * @param NAME "name" attribute + */ +#define DLT_CUTF8_ATTR(TEXT, NAME) \ + (void)dlt_user_log_write_constant_utf8_string_attr(&log_local, TEXT, NAME) + +/** + * Add constant utf8-encoded string parameter with given length and "name" attribute to the log messsage. + * The string in @a TEXT does not need to be null-terminated, but + * the copied string will be null-terminated at its destination + * in the message buffer. + * @param TEXT Constant UTF8-encoded string + * @param LEN length in bytes to take from @a TEXT + * @param NAME "name" attribute + */ +#define DLT_SIZED_CUTF8_ATTR(TEXT, LEN, NAME) \ + (void)dlt_user_log_write_sized_constant_utf8_string_attr(&log_local, TEXT, LEN, NAME) + /** * Add boolean parameter to the log messsage. * @param BOOL_VAR Boolean value (mapped to uint8) -- cgit v1.2.1