summaryrefslogtreecommitdiff
path: root/src/shared/dlt_common.c
diff options
context:
space:
mode:
authorJens Bocklage <jens_bocklage@mentor.com>2015-03-02 16:28:03 +0100
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2015-03-12 14:34:41 +0100
commitf90a5069f569aefa1c768ec7a336d982073f8ee2 (patch)
treec037ca7558ed60720298441f450b10278b4d1504 /src/shared/dlt_common.c
parent06b4012535e0b8bb5ad31001601e78fd9b53e8d3 (diff)
downloadDLT-daemon-f90a5069f569aefa1c768ec7a336d982073f8ee2.tar.gz
adding support for new macros to the daemon. new macros: DLT_HEX8(VAR) 8bits variable displayed in hexadecimal with "0x" prefix DLT_HEX16(VAR) 16bits displayed in hexadecimal with "0x" prefix DLT_HEX32(VAR) 32bits displayed in hexadecimal with "0x" prefix DLT_HEX64(VAR) 64bits displayed in hexadecimal with "0x" prefix DLT_BIN8(VAR) 8bits variable displayed in binary with "0b" prefix DLT_BIN16(VAR) 16bits variable displayed in binary with "0b" prefix
plus typo fix Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Diffstat (limited to 'src/shared/dlt_common.c')
-rwxr-xr-xsrc/shared/dlt_common.c74
1 files changed, 73 insertions, 1 deletions
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index dd4d74a..d0beb97 100755
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -3217,7 +3217,6 @@ int dlt_message_argument_print(DltMessage *msg,uint32_t type_info,uint8_t **ptr,
int64_t value64f_tmp_int64i=0,value64f_tmp_int64i_swaped=0;
uint32_t quantisation_tmp = 0;
-
if ( (type_info & DLT_TYPE_INFO_STRG) && (((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_ASCII) || ((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_UTF8)) )
{
@@ -3271,6 +3270,79 @@ int dlt_message_argument_print(DltMessage *msg,uint32_t type_info,uint8_t **ptr,
return -1;
snprintf(text+strlen(text),textlength-strlen(text),"%d",value8u);
}
+ else if ((type_info & DLT_TYPE_INFO_UINT) && (DLT_SCOD_BIN == (type_info & DLT_TYPE_INFO_SCOD)))
+ {
+ if (DLT_TYLE_8BIT == (type_info & DLT_TYPE_INFO_TYLE))
+ {
+ DLT_MSG_READ_VALUE(value8u,*ptr,*datalength,uint8_t); /* No endian conversion necessary */
+ if((*datalength)<0)
+ return -1;
+ char binary[10] = {'\0'}; // e.g.: "0b1100 0010"
+ int i;
+ for (i = (1 << 7); i > 0; i >>= 1)
+ {
+ if ((1<<3) == i)
+ strcat(binary, " ");
+ strcat(binary, (i == (value8u & i)) ? "1" : "0");
+ }
+
+ snprintf(text+strlen(text),textlength-strlen(text),"0b%s",binary);
+ }
+ if (DLT_TYLE_16BIT == (type_info & DLT_TYPE_INFO_TYLE))
+ {
+ DLT_MSG_READ_VALUE(value16u,*ptr,*datalength,uint16_t);
+ if((*datalength)<0)
+ return -1;
+ char binary[20] = {'\0'}; // e.g.: "0b1100 0010 0011 0110"
+ int i;
+ for (i = (1 << 15); i > 0; i >>= 1)
+ {
+ if (((1<<3) == i) || ((1<<7) == i) || ((1<<11) == i))
+ strcat(binary, " ");
+ strcat(binary, (i == (value16u & i)) ? "1" : "0");
+ }
+
+ snprintf(text+strlen(text),textlength-strlen(text),"0b%s",binary);
+ }
+ }
+ else if ((type_info & DLT_TYPE_INFO_UINT) && (DLT_SCOD_HEX == (type_info & DLT_TYPE_INFO_SCOD)))
+ {
+ if (DLT_TYLE_8BIT == (type_info & DLT_TYPE_INFO_TYLE))
+ {
+ DLT_MSG_READ_VALUE(value8u,*ptr,*datalength,uint8_t); /* No endian conversion necessary */
+ if((*datalength)<0)
+ return -1;
+ snprintf(text+strlen(text),textlength-strlen(text),"0x%02x",value8u);
+ }
+ if (DLT_TYLE_16BIT == (type_info & DLT_TYPE_INFO_TYLE))
+ {
+ DLT_MSG_READ_VALUE(value16u,*ptr,*datalength,uint16_t);
+ if((*datalength)<0)
+ return -1;
+ snprintf(text+strlen(text),textlength-strlen(text),"0x%04x",value16u);
+ }
+ if (DLT_TYLE_32BIT == (type_info & DLT_TYPE_INFO_TYLE))
+ {
+ DLT_MSG_READ_VALUE(value32u,*ptr,*datalength,uint32_t);
+ if((*datalength)<0)
+ return -1;
+ snprintf(text+strlen(text),textlength-strlen(text),"0x%08x",value32u);
+ }
+ if (DLT_TYLE_64BIT == (type_info & DLT_TYPE_INFO_TYLE))
+ {
+ *ptr += 4;
+ DLT_MSG_READ_VALUE(value32u,*ptr,*datalength,uint32_t);
+ if((*datalength)<0)
+ return -1;
+ snprintf(text+strlen(text),textlength-strlen(text),"0x%08x",value32u);
+ *ptr -= 8;
+ DLT_MSG_READ_VALUE(value32u,*ptr,*datalength,uint32_t);
+ if((*datalength)<0)
+ return -1;
+ snprintf(text+strlen(text),textlength-strlen(text),"%08x",value32u);
+ *ptr += 4;
+ }
+ }
else if ((type_info & DLT_TYPE_INFO_SINT) || (type_info & DLT_TYPE_INFO_UINT))
{
/* signed or unsigned argument received */