summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2014-06-17 16:23:49 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2014-09-09 14:50:50 +0200
commitf1442dd3619c6478862b52f6ee022b8799a55bfe (patch)
tree04d28ce1c10c10d003013a950a7047cc342e4c60
parent87936e5249b2c22eefac0acfc21696e209ee6d35 (diff)
downloadDLT-daemon-f1442dd3619c6478862b52f6ee022b8799a55bfe.tar.gz
New macros for Format of Hex and Binary.
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
-rw-r--r--examples/README.txt1
-rwxr-xr-xinclude/dlt/dlt_protocol.h2
-rw-r--r--include/dlt/dlt_user.h26
-rw-r--r--include/dlt/dlt_user_macros.h12
-rw-r--r--src/lib/dlt_user.c16
5 files changed, 57 insertions, 0 deletions
diff --git a/examples/README.txt b/examples/README.txt
index fe42331..6599b7c 100644
--- a/examples/README.txt
+++ b/examples/README.txt
@@ -3,3 +3,4 @@ This folder contains several examples of applications using the DLT library. The
Example1: Minimal DLT Example
Example2: Non Verbose Mode Examples with different AppIdds and normal Strings
Example3: Non Verbose Mode Examples with different AppIdds and constant strings
+Example4: Different RAW data
diff --git a/include/dlt/dlt_protocol.h b/include/dlt/dlt_protocol.h
index 09e4adc..1bb5850 100755
--- a/include/dlt/dlt_protocol.h
+++ b/include/dlt/dlt_protocol.h
@@ -163,6 +163,8 @@
#define DLT_SCOD_ASCII 0x00000000
#define DLT_SCOD_UTF8 0x00008000
+#define DLT_SCOD_HEX 0x00010000
+#define DLT_SCOD_BIN 0x00018000
/*
* Definitions of DLT services.
diff --git a/include/dlt/dlt_user.h b/include/dlt/dlt_user.h
index 44d1ca1..1ed7b25 100644
--- a/include/dlt/dlt_user.h
+++ b/include/dlt/dlt_user.h
@@ -102,6 +102,20 @@ typedef enum
} DltLogLevelType;
/**
+ * Definitions of DLT Format
+ */
+typedef enum
+{
+ DLT_FORMAT_DEFAULT = 0x00, /**< no sepecial format */
+ DLT_FORMAT_HEX8 = 0x01, /**< Hex 8 */
+ DLT_FORMAT_HEX16 = 0x02, /**< Hex 16 */
+ DLT_FORMAT_HEX32 = 0x03, /**< Hex 32 */
+ DLT_FORMAT_HEX64 = 0x04, /**< Hex 64 */
+ DLT_FORMAT_BIN8 = 0x05, /**< Binary 8 */
+ DLT_FORMAT_BIN16 = 0x06 /**< Binary 16 */
+} DltFormatType;
+
+/**
* Definitions of DLT trace status
*/
typedef enum
@@ -399,6 +413,18 @@ int dlt_user_log_write_utf8_string(DltContextData *log, const char *text);
int dlt_user_log_write_raw(DltContextData *log,void *data,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.
+ * @param log pointer to an object containing information about logging context data
+ * @param data pointer to the parameter written into log message.
+ * @param length length in bytes of the parameter written into log message.
+ * @param type the format information.
+ * @return negative value if there was an error
+ */
+int dlt_user_log_write_raw_formated(DltContextData *log,void *data,uint16_t length,DltFormatType type);
+
+/**
* Trace network message
* @param handle pointer to an object containing information about one special logging context
* @param nw_trace_type type of network trace (DLT_NW_TRACE_IPC, DLT_NW_TRACE_CAN, DLT_NW_TRACE_FLEXRAY, or DLT_NW_TRACE_MOST)
diff --git a/include/dlt/dlt_user_macros.h b/include/dlt/dlt_user_macros.h
index 8a186ae..a8ceaf4 100644
--- a/include/dlt/dlt_user_macros.h
+++ b/include/dlt/dlt_user_macros.h
@@ -294,6 +294,18 @@ extern DltContext CONTEXT;
*/
#define DLT_RAW(BUF,LEN) \
dlt_user_log_write_raw(&log,BUF,LEN)
+#define DLT_HEX8(BUF,LEN) \
+ dlt_user_log_write_raw_formated(&log,BUF,LEN,DLT_FORMAT_HEX8)
+#define DLT_HEX16(BUF,LEN) \
+ dlt_user_log_write_raw_formated(&log,BUF,LEN,DLT_FORMAT_HEX16)
+#define DLT_HEX32(BUF,LEN) \
+ dlt_user_log_write_raw_formated(&log,BUF,LEN,DLT_FORMAT_HEX32)
+#define DLT_HEX64(BUF,LEN) \
+ dlt_user_log_write_raw_formated(&log,BUF,LEN,DLT_FORMAT_HEX64)
+#define DLT_BIN8(BUF,LEN) \
+ dlt_user_log_write_raw_formated(&log,BUF,LEN,DLT_FORMAT_BIN8)
+#define DLT_BIN16(BUF,LEN) \
+ dlt_user_log_write_raw_formated(&log,BUF,LEN,DLT_FORMAT_BIN16)
/**
* Trace network message
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index bf63ed7..1ad4335 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -1302,6 +1302,11 @@ int dlt_user_log_write_finish(DltContextData *log)
int dlt_user_log_write_raw(DltContextData *log,void *data,uint16_t length)
{
+ return dlt_user_log_write_raw_formated(log,data,length,DLT_FORMAT_DEFAULT);
+}
+
+int dlt_user_log_write_raw_formated(DltContextData *log,void *data,uint16_t length,DltFormatType type)
+{
uint16_t arg_size;
uint32_t type_info;
@@ -1325,6 +1330,17 @@ int dlt_user_log_write_raw(DltContextData *log,void *data,uint16_t length)
/* Transmit type information */
type_info = DLT_TYPE_INFO_RAWD;
+ if(type>=DLT_FORMAT_HEX8 && type<=DLT_FORMAT_HEX64)
+ {
+ type_info |= DLT_SCOD_HEX;
+ type_info += type;
+ }
+ else if(type>=DLT_FORMAT_BIN8 && type<=DLT_FORMAT_BIN16)
+ {
+ type_info |= DLT_SCOD_BIN;
+ type_info += type - DLT_FORMAT_BIN8 + 1;
+ }
+
memcpy((log->buffer)+log->size,&(type_info),sizeof(uint32_t));
log->size += sizeof(uint32_t);