1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
Forwarded: yes
From d9c14fab892163d46f488ade407c2ea3a7879057 Mon Sep 17 00:00:00 2001
From: LUU QUANG MINH <Minh.LuuQuang@vn.bosch.com>
Date: Wed, 23 Aug 2023 23:21:03 +0700
Subject: [PATCH] common: apply big-edian case for ascii to uint16_t
When converting ascii to unint16_t, the byte order
needs to be kept for big-edian case
Co-Authored-By: Gianfranco Costamagna <1227338+LocutusOfBorg@users.noreply.github.com>
---
src/shared/dlt_common.c | 7 +++++++
tests/gtest_dlt_daemon_gateway.cpp | 3 +++
2 files changed, 10 insertions(+)
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index c9e8cafa..900fb17b 100644
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -4149,6 +4149,12 @@ int16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count)
if ((rp == NULL) || (rp_count == NULL))
return -1;
+#if (BYTE_ORDER == BIG_ENDIAN)
+ num_work[0] = *(rp + *rp_count + 0);
+ num_work[1] = *(rp + *rp_count + 1);
+ num_work[2] = *(rp + *rp_count + 2);
+ num_work[3] = *(rp + *rp_count + 3);
+#else
/* ------------------------------------------------------
* from: [89 13 ] -> to: ['+0x'1389\0] -> to num
* ------------------------------------------------------ */
@@ -4156,6 +4162,7 @@ int16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count)
num_work[1] = *(rp + *rp_count + 4);
num_work[2] = *(rp + *rp_count + 0);
num_work[3] = *(rp + *rp_count + 1);
+#endif
num_work[4] = 0;
*rp_count += 6;
diff --git a/tests/gtest_dlt_daemon_gateway.cpp b/tests/gtest_dlt_daemon_gateway.cpp
index b4336d88..0624d5f1 100644
--- a/tests/gtest_dlt_daemon_gateway.cpp
+++ b/tests/gtest_dlt_daemon_gateway.cpp
@@ -531,6 +531,9 @@ TEST(t_dlt_gateway_parse_get_log_info, normal)
msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
+#if (BYTE_ORDER == BIG_ENDIAN)
+ msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_MSBF);
+#endif
msg.standardheader->mcnt = 0;
dlt_set_id(msg.headerextra.ecu, ecuid);
|