Skip to content

Commit 33b0820

Browse files
author
Arto Kinnunen
committed
Squashed 'features/FEATURE_COMMON_PAL/mbed-trace/' changes from af5f59c..b731d95
b731d95 Clarify mutex type requirement (#77) 7c31aef bumb version number (#72) 75982fc fix dummydefine for mbed_trace_init (#71) 539b80c Update version number. (#69) b0e09f9 output/ added to gitignore list (#66) a5cce88 Added include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) include to resolve compilation error for Linux. (#63) d087dbb Ensure tr_array doesn't print <null> when len == 0 (#65) git-subtree-dir: features/FEATURE_COMMON_PAL/mbed-trace git-subtree-split: b731d954d111d92199b2a0402dc9a3d52f5d4a17
1 parent c8a16cc commit 33b0820

File tree

7 files changed

+22
-3
lines changed

7 files changed

+22
-3
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ build/
3636
test_coverage/
3737
**/*.info
3838
**/*~
39+
output/*
40+
41+
# Yotta files
42+
.yotta.json

CMakeLists.txt

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ project(mbedTrace)
77

88

99
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/mbed-trace/)
10+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/)
1011
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../nanostack-libservice/mbed-client-libservice/)
1112
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../nanostack-libservice/)
1213

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The purpose of the library is to provide a light, simple and general tracing sol
5252
* With yotta: set `YOTTA_CFG_MBED_TRACE_FEA_IPV6 = 0`.
5353
* With mbed OS 5: set `MBED_CONF_MBED_TRACE_FEA_IPV6 = 0`.
5454
* If thread safety is needed, configure the wait and release callback functions before initialization to enable the protection. Usually, this needs to be done only once in the application's lifetime.
55+
* If [helping functions](#helping-functions) are used the mutex must be **recursive** (counting) so it can be acquired from a single thread repeatedly.
5556
* Call the trace initialization (`mbed_trace_init`) once before using any other APIs. It allocates the trace buffer and initializes the internal variables.
5657
* Define `TRACE_GROUP` in your source code (not in the header!) to use traces. It is a 1-4 characters long char-array (for example `#define TRACE_GROUP "APPL"`). This will be printed on every trace line.
5758

mbed-trace/mbed_trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ char* mbed_trace_array(const uint8_t* buf, uint16_t len);
408408
#elif !defined(MBED_TRACE_DUMMIES_DEFINED)
409409
// define dummies, hiding the real functions
410410
#define MBED_TRACE_DUMMIES_DEFINED
411-
#define mbed_trace_init(...) ((void) 0)
411+
#define mbed_trace_init(...) ((int) 0)
412412
#define mbed_trace_free(...) ((void) 0)
413413
#define mbed_trace_buffer_sizes(...) ((void) 0)
414414
#define mbed_trace_config_set(...) ((void) 0)

module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mbed-trace",
3-
"version": "1.2.1",
3+
"version": "1.3.0",
44
"description": "Trace library for mbed devices",
55
"keywords": [
66
"trace",

source/mbed_trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ char *mbed_trace_array(const uint8_t *buf, uint16_t len)
558558
int i, bLeft = tmp_data_left();
559559
char *str, *wptr;
560560
str = m_trace.tmp_data_ptr;
561-
if (str == NULL || bLeft == 0) {
561+
if (len == 0 || str == NULL || bLeft == 0) {
562562
return "";
563563
}
564564
if (buf == NULL) {

test/Test.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ TEST(trace, Array)
9191
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(longStr, 200) );
9292
}
9393

94+
TEST(trace, Null0Array)
95+
{
96+
static const unsigned char array[2] = { 0x23, 0x45 };
97+
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(array, 2));
98+
STRCMP_EQUAL("23:45", buf);
99+
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(array, 0));
100+
STRCMP_EQUAL("", buf);
101+
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(NULL, 0));
102+
STRCMP_EQUAL("", buf);
103+
mbed_tracef(TRACE_LEVEL_DEBUG, "mygr", "%s", mbed_trace_array(NULL, 2));
104+
STRCMP_EQUAL("<null>", buf);
105+
}
106+
94107
TEST(trace, LongString)
95108
{
96109
char longStr[1000] = {0x36};

0 commit comments

Comments
 (0)