Skip to content

Commit 49b940c

Browse files
Cruz Monrreal IICruz Monrreal II
authored andcommitted
Merge branch 'prepare_for_mbedos511' of ssh://github.com/artokin/mbed-os into rollup-b.1
2 parents 0e4f843 + d879422 commit 49b940c

File tree

300 files changed

+8803
-6802
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

300 files changed

+8803
-6802
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/*

features/frameworks/mbed-client-randlib/source/randLIB.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void randLIB_seed_random(void)
9898

9999
/* Spell out expressions so we get known ordering of 4 seed calls */
100100
uint64_t s = (uint64_t) arm_random_seed_get() << 32;
101-
state[0] ^= ( s | arm_random_seed_get());
101+
state[0] ^= (s | arm_random_seed_get());
102102

103103
s = (uint64_t) arm_random_seed_get() << 32;
104104
state[1] ^= s | arm_random_seed_get();
@@ -129,19 +129,19 @@ void randLIB_add_seed(uint64_t seed)
129129
uint8_t randLIB_get_8bit(void)
130130
{
131131
uint64_t r = randLIB_get_64bit();
132-
return (uint8_t) (r >> 56);
132+
return (uint8_t)(r >> 56);
133133
}
134134

135135
uint16_t randLIB_get_16bit(void)
136136
{
137137
uint64_t r = randLIB_get_64bit();
138-
return (uint16_t) (r >> 48);
138+
return (uint16_t)(r >> 48);
139139
}
140140

141141
uint32_t randLIB_get_32bit(void)
142142
{
143143
uint64_t r = randLIB_get_64bit();
144-
return (uint32_t) (r >> 32);
144+
return (uint32_t)(r >> 32);
145145
}
146146

147147

features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/makefile_defines.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ INCLUDE_DIRS =\
1111
../../../..\
1212
../../../../source\
1313
../../../../mbed-client-randlib\
14+
../../../../../../../libService/libService\
1415
/usr/include\
1516
$(CPPUTEST_HOME)/include\
1617

features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "CppUTest/TestPlugin.h"
77
#include "CppUTest/TestRegistry.h"
88
#include "CppUTestExt/MockSupportPlugin.h"
9-
int main(int ac, char** av)
9+
int main(int ac, char **av)
1010
{
1111
return CommandLineTestRunner::RunAllTests(ac, av);
1212
}

features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/randlibtest.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66

77
TEST_GROUP(randLIB)
88
{
9-
void setup()
10-
{
9+
void setup() {
1110
}
1211

13-
void teardown()
14-
{
12+
void teardown() {
1513
}
1614
};
1715

features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/randlib/test_randlib.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ bool test_randLIB_get_8bit()
1818
randLIB_reset();
1919
randLIB_seed_random();
2020
uint8_t test = randLIB_get_8bit();
21-
if( test == 0 ) {
21+
if (test == 0) {
2222
test = randLIB_get_8bit();
23-
if( test == 0 ) {
23+
if (test == 0) {
2424
return false;
2525
}
2626
}
@@ -32,9 +32,9 @@ bool test_randLIB_get_16bit()
3232
randLIB_reset();
3333
randLIB_seed_random();
3434
uint16_t test = randLIB_get_16bit();
35-
if( test == 0 ) {
35+
if (test == 0) {
3636
test = randLIB_get_16bit();
37-
if( test == 0 ) {
37+
if (test == 0) {
3838
return false;
3939
}
4040
}
@@ -46,9 +46,9 @@ bool test_randLIB_get_32bit()
4646
randLIB_reset();
4747
randLIB_seed_random();
4848
uint32_t test = randLIB_get_32bit();
49-
if( test == 0 ) {
49+
if (test == 0) {
5050
test = randLIB_get_32bit();
51-
if( test == 0 ) {
51+
if (test == 0) {
5252
return false;
5353
}
5454
}
@@ -145,7 +145,7 @@ bool test_randLIB_get_n_bytes_random()
145145

146146
uint8_t dat[5];
147147
void *ret = randLIB_get_n_bytes_random(dat, 5);
148-
if(ret != dat){
148+
if (ret != dat) {
149149
return false;
150150
}
151151

@@ -164,12 +164,12 @@ bool test_randLIB_get_random_in_range()
164164
randLIB_seed_random();
165165

166166
uint16_t ret = randLIB_get_random_in_range(2, 2);
167-
if( ret != 2 ){
167+
if (ret != 2) {
168168
return false;
169169
}
170170

171171
ret = randLIB_get_random_in_range(2, 3);
172-
if( ret != 2 && ret != 3){
172+
if (ret != 2 && ret != 3) {
173173
return false;
174174
}
175175

@@ -183,12 +183,12 @@ bool test_randLIB_randomise_base()
183183
randLIB_reset();
184184
randLIB_seed_random();
185185

186-
uint32_t ret = randLIB_randomise_base(0,0,0);
187-
if( ret ){
186+
uint32_t ret = randLIB_randomise_base(0, 0, 0);
187+
if (ret) {
188188
return false;
189189
}
190-
ret = randLIB_randomise_base(0xffff0000,0x8888,0x8888);
191-
if( ret != 0xffffffff ){
190+
ret = randLIB_randomise_base(0xffff0000, 0x8888, 0x8888);
191+
if (ret != 0xffffffff) {
192192
return false;
193193
}
194194
return true;

features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/stubs/open_stub.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ bool allow_open = true;
88
int __real_open(const char *path, int flags, ...);
99
int __wrap_open(const char *path, int flags, ...)
1010
{
11-
if (allow_open) {
12-
if (flags & O_CREAT) {
13-
va_list vl;
14-
va_start(vl,flags);
15-
mode_t mode = va_arg(vl, mode_t);
16-
va_end(vl);
17-
return __real_open(path, flags, mode);
18-
} else {
19-
return __real_open(path, flags);
20-
}
21-
} else {
22-
return -1;
23-
}
11+
if (allow_open) {
12+
if (flags & O_CREAT) {
13+
va_list vl;
14+
va_start(vl, flags);
15+
mode_t mode = va_arg(vl, mode_t);
16+
va_end(vl);
17+
return __real_open(path, flags, mode);
18+
} else {
19+
return __real_open(path, flags);
20+
}
21+
} else {
22+
return -1;
23+
}
2424
}

features/frameworks/mbed-client-randlib/test/mbed-client-randlib/unittest/stubs/random_stub.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/*
22
* Copyright (c) 2016, ARM Limited, All Rights Reserved
33
*/
4-
#include "random_stub.h"
4+
5+
#include "ns_types.h"
56

67
static uint32_t seed_value = 4;
78
static bool seed_inc = false;

features/frameworks/mbed-trace/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,43 @@ Set the output function, `printf` by default:
107107
mbed_trace_print_function_set(printf)
108108
```
109109
110+
### Tracing level
111+
112+
Run time tracing level is set using `mbed_trace_set_config()` function. Possible levels and examples how to set them is presented below.
113+
114+
```c
115+
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ALL);
116+
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_DEBUG); // (same as ALL)
117+
mbed_trace_config_set(TRACE_ACTIVE_LEVEL_INFO);
118+
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_WARN);
119+
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_ERROR);
120+
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_CMD);
121+
//mbed_trace_config_set(TRACE_ACTIVE_LEVEL_NONE);
122+
```
123+
124+
Build time optimization can be done with `MBED_TRACE_MAX_LEVEL` definition. Setting max level to `TRACE_LEVEL_DEBUG` includes all traces to the build. Setting max level to `TRACE_LEVEL_INFO` includes all but `tr_debug()` traces to the build. Other maximum tracing levels follow the same behavior and no messages above the selected level are included in the build.
125+
126+
```c
127+
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_DEBUG
128+
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO
129+
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_WARN
130+
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_ERROR
131+
#define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_CMD
132+
```
133+
134+
In Mbed OS, the build time maximum tracing level can be set through `mbed_app.json` as shown below.
135+
136+
```
137+
{
138+
"target_overrides":{
139+
"*":{
140+
"mbed-trace.enable": true,
141+
"mbed-trace.max-level": "TRACE_LEVEL_INFO"
142+
}
143+
}
144+
}
145+
```
146+
110147
### Helping functions
111148

112149
The purpose of the helping functions is to provide simple conversions, for example from an array to C string, so that you can print everything to single trace line. They must be called inside the actual trace calls, for example:

features/frameworks/mbed-trace/mbed-trace/mbed_trace.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ extern "C" {
180180
* Initialize trace functionality
181181
* @return 0 when all success, otherwise non zero
182182
*/
183-
int mbed_trace_init( void );
183+
int mbed_trace_init(void);
184184
/**
185185
* Free trace memory
186186
*/
187-
void mbed_trace_free( void );
187+
void mbed_trace_free(void);
188188
/**
189189
* Resize buffers (line / tmp ) sizes
190190
* @param lineLength new maximum length for trace line (0 = do no resize)
@@ -226,7 +226,7 @@ uint8_t mbed_trace_config_get(void);
226226
* char* trace_time(){ return "rtc-time-in-string"; }
227227
* mbed_trace_prefix_function_set( &trace_time );
228228
*/
229-
void mbed_trace_prefix_function_set( char* (*pref_f)(size_t) );
229+
void mbed_trace_prefix_function_set(char *(*pref_f)(size_t));
230230
/**
231231
* Set trace suffix function
232232
* suffix -function return string with null terminated
@@ -235,18 +235,18 @@ void mbed_trace_prefix_function_set( char* (*pref_f)(size_t) );
235235
* char* trace_suffix(){ return " END"; }
236236
* mbed_trace_suffix_function_set( &trace_suffix );
237237
*/
238-
void mbed_trace_suffix_function_set(char* (*suffix_f)(void) );
238+
void mbed_trace_suffix_function_set(char *(*suffix_f)(void));
239239
/**
240240
* Set trace print function
241241
* By default, trace module print using printf() function,
242242
* but with this you can write own print function,
243243
* for e.g. to other IO device.
244244
*/
245-
void mbed_trace_print_function_set( void (*print_f)(const char*) );
245+
void mbed_trace_print_function_set(void (*print_f)(const char *));
246246
/**
247247
* Set trace print function for tr_cmdline()
248248
*/
249-
void mbed_trace_cmdprint_function_set( void (*printf)(const char*) );
249+
void mbed_trace_cmdprint_function_set(void (*printf)(const char *));
250250
/**
251251
* Set trace mutex wait function
252252
* By default, trace calls are not thread safe.
@@ -270,10 +270,10 @@ void mbed_trace_mutex_release_function_set(void (*mutex_release_f)(void));
270270
* mbed_trace_exclude_filters_set("mygr");
271271
* mbed_tracef(TRACE_ACTIVE_LEVEL_DEBUG, "ougr", "This is not printed");
272272
*/
273-
void mbed_trace_exclude_filters_set(char* filters);
273+
void mbed_trace_exclude_filters_set(char *filters);
274274
/** get trace exclude filters
275275
*/
276-
const char* mbed_trace_exclude_filters_get(void);
276+
const char *mbed_trace_exclude_filters_get(void);
277277
/**
278278
* When trace group contains text in filter,
279279
* trace will be printed.
@@ -282,10 +282,10 @@ const char* mbed_trace_exclude_filters_get(void);
282282
* mbed_tracef(TRACE_ACTIVE_LEVEL_DEBUG, "mygr", "Hi There");
283283
* mbed_tracef(TRACE_ACTIVE_LEVEL_DEBUG, "grp2", "This is not printed");
284284
*/
285-
void mbed_trace_include_filters_set(char* filters);
285+
void mbed_trace_include_filters_set(char *filters);
286286
/** get trace include filters
287287
*/
288-
const char* mbed_trace_include_filters_get(void);
288+
const char *mbed_trace_include_filters_get(void);
289289
/**
290290
* General trace function
291291
* This should be used every time when user want to print out something important thing
@@ -298,9 +298,9 @@ const char* mbed_trace_include_filters_get(void);
298298
* @param ... variable arguments related to fmt
299299
*/
300300
#if defined(__GNUC__) || defined(__CC_ARM)
301-
void mbed_tracef(uint8_t dlevel, const char* grp, const char *fmt, ...) __attribute__ ((__format__(__printf__, 3, 4)));
301+
void mbed_tracef(uint8_t dlevel, const char *grp, const char *fmt, ...) __attribute__((__format__(__printf__, 3, 4)));
302302
#else
303-
void mbed_tracef(uint8_t dlevel, const char* grp, const char *fmt, ...);
303+
void mbed_tracef(uint8_t dlevel, const char *grp, const char *fmt, ...);
304304
#endif
305305
/**
306306
* General trace function
@@ -318,16 +318,16 @@ void mbed_tracef(uint8_t dlevel, const char* grp, const char *fmt, ...);
318318
* @param ap variable arguments list (like vprintf)
319319
*/
320320
#if defined(__GNUC__) || defined(__CC_ARM)
321-
void mbed_vtracef(uint8_t dlevel, const char* grp, const char *fmt, va_list ap) __attribute__ ((__format__(__printf__, 3, 0)));
321+
void mbed_vtracef(uint8_t dlevel, const char *grp, const char *fmt, va_list ap) __attribute__((__format__(__printf__, 3, 0)));
322322
#else
323-
void mbed_vtracef(uint8_t dlevel, const char* grp, const char *fmt, va_list ap);
323+
void mbed_vtracef(uint8_t dlevel, const char *grp, const char *fmt, va_list ap);
324324
#endif
325325

326326

327327
/**
328328
* Get last trace from buffer
329329
*/
330-
const char* mbed_trace_last(void);
330+
const char *mbed_trace_last(void);
331331
#if MBED_CONF_MBED_TRACE_FEA_IPV6 == 1
332332
/**
333333
* mbed_tracef helping function for convert ipv6
@@ -339,7 +339,7 @@ const char* mbed_trace_last(void);
339339
* @param add_ptr IPv6 Address pointer
340340
* @return temporary buffer where ipv6 is in string format
341341
*/
342-
char* mbed_trace_ipv6(const void *addr_ptr);
342+
char *mbed_trace_ipv6(const void *addr_ptr);
343343
/**
344344
* mbed_tracef helping function for print ipv6 prefix
345345
* usage e.g.
@@ -350,7 +350,7 @@ char* mbed_trace_ipv6(const void *addr_ptr);
350350
* @param prefix_len prefix length
351351
* @return temporary buffer where ipv6 is in string format
352352
*/
353-
char* mbed_trace_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len);
353+
char *mbed_trace_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len);
354354
#endif
355355
/**
356356
* mbed_tracef helping function for convert hex-array to string.
@@ -364,7 +364,7 @@ char* mbed_trace_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len);
364364
* if array as string not fit to temp buffer, this function write '*' as last character,
365365
* which indicate that buffer is too small for array.
366366
*/
367-
char* mbed_trace_array(const uint8_t* buf, uint16_t len);
367+
char *mbed_trace_array(const uint8_t *buf, uint16_t len);
368368

369369
#ifdef __cplusplus
370370
}

features/frameworks/mbed-trace/mbed_lib.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
"help": "Used to globally enable traces.",
66
"value": null
77
},
8+
"max-level": {
9+
"help": "This flag is used to optimize the code size. For example, setting trace optimization level to TRACE_LEVEL_INFO will define all tr_debug() macros empty, which reduces the binary size. The possible optimization levels are TRACE_LEVEL_DEBUG, TRACE_LEVEL_INFO, TRACE_LEVEL_WARN, TRACE_LEVEL_ERROR and TRACE_LEVEL_CMD. To set the output tracing level, please use mbed_trace_config_set(TRACE_ACTIVE_LEVEL_INFO). The possible tracing levels for mbed_trace_config_set() are TRACE_ACTIVE_LEVEL_ALL, TRACE_ACTIVE_LEVEL_DEBUG (same as ALL), TRACE_ACTIVE_LEVEL_INFO, TRACE_ACTIVE_LEVEL_WARN, TRACE_ACTIVE_LEVEL_ERROR, TRACE_ACTIVE_LEVEL_CMD and TRACE_LEVEL_NONE.",
10+
"value": null,
11+
"macro_name": "MBED_TRACE_MAX_LEVEL"
12+
13+
},
814
"fea-ipv6": {
915
"help": "Used to globally disable ipv6 tracing features.",
1016
"value": null

0 commit comments

Comments
 (0)