
Nanostack Border Router is a generic mbed border router implementation that provides the 6LoWPAN ND or Thread border router initialization logic.
Revision 13:993808eb2e9c, committed 2017-05-31
- Comitter:
- mbed_official
- Date:
- Wed May 31 09:15:44 2017 +0100
- Parent:
- 12:04fcf9df91e2
- Child:
- 14:de99c96a9fae
- Commit message:
- Print memory stats after routing table (#38)
Print memory statistics in 20s intervals.
.
Commit copied from https://github.com/ARMmbed/nanostack-border-router
Changed in this revision
--- a/source/border_router_main.cpp Mon May 29 13:00:17 2017 +0100 +++ b/source/border_router_main.cpp Wed May 31 09:15:44 2017 +0100 @@ -29,6 +29,7 @@ #define APP_DEFINED_HEAP_SIZE MBED_CONF_APP_HEAP_SIZE static uint8_t app_stack_heap[APP_DEFINED_HEAP_SIZE]; static uint8_t mac[6] = {0}; +static mem_stat_t heap_info; static DigitalOut led1(MBED_CONF_APP_LED); @@ -103,7 +104,7 @@ int main(int argc, char **argv) { - ns_hal_init(app_stack_heap, APP_DEFINED_HEAP_SIZE, app_heap_error_handler, 0); + ns_hal_init(app_stack_heap, APP_DEFINED_HEAP_SIZE, app_heap_error_handler, &heap_info); mbed_trace_init(); // set up the tracing library mbed_trace_print_function_set(trace_printer); @@ -157,3 +158,4 @@ while (1); } +
--- a/source/borderrouter_helpers.c Mon May 29 13:00:17 2017 +0100 +++ b/source/borderrouter_helpers.c Wed May 31 09:15:44 2017 +0100 @@ -10,6 +10,7 @@ #include "ns_types.h" #include "common_functions.h" #include "ns_trace.h" +#include "nsdynmemLIB.h" #define TRACE_GROUP "app" static char tmp_print_buffer[128] = {0}; @@ -47,3 +48,20 @@ tr_info("Starting NanoStack Border Router..."); tr_info("Build date: %s %s", __DATE__, __TIME__); } + +void print_memory_stats(void) +{ + const mem_stat_t *heap_info = ns_dyn_mem_get_mem_stat(); + if (heap_info) { + tr_info( + "Heap size: %" PRIu16 ", " + "Reserved: %" PRIu16 ", " + "Reserved max: %" PRIu16 ", " + "Alloc fail: %" PRIu32 "" + ,heap_info->heap_sector_size + ,heap_info->heap_sector_allocated_bytes + ,heap_info->heap_sector_allocated_bytes_max + ,heap_info->heap_alloc_fail_cnt); + } +} +
--- a/source/borderrouter_helpers.h Mon May 29 13:00:17 2017 +0100 +++ b/source/borderrouter_helpers.h Wed May 31 09:15:44 2017 +0100 @@ -14,6 +14,7 @@ char *print_ipv6(const void *addr_ptr); char *print_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len); void print_appl_info(void); +void print_memory_stats(void); #ifdef __cplusplus }
--- a/source/borderrouter_tasklet.c Mon May 29 13:00:17 2017 +0100 +++ b/source/borderrouter_tasklet.c Wed May 31 09:15:44 2017 +0100 @@ -441,6 +441,7 @@ #if MBED_CONF_APP_DEBUG_TRACE == 1 arm_print_routing_table(); arm_print_neigh_cache(); + print_memory_stats(); #endif #endif eventOS_event_timer_request(9, ARM_LIB_SYSTEM_TIMER_EVENT, br_tasklet_id, 20000); @@ -464,7 +465,7 @@ /* Channel list: listen to a channel (default: all channels) */ uint32_t channel = cfg_int(global_config, "RF_CHANNEL", 0); - tr_info("RF channel: %d", channel); + tr_info("RF channel: %d", (int)channel); initialize_channel_list(channel); // configure as border router and set the operation mode
--- a/source/borderrouter_thread_tasklet.c Mon May 29 13:00:17 2017 +0100 +++ b/source/borderrouter_thread_tasklet.c Wed May 31 09:15:44 2017 +0100 @@ -511,6 +511,7 @@ #if MBED_CONF_APP_DEBUG_TRACE == 1 arm_print_routing_table(); arm_print_neigh_cache(); + print_memory_stats(); #endif #endif eventOS_event_timer_request(9, ARM_LIB_SYSTEM_TIMER_EVENT, br_tasklet_id, 20000);