NuMaker Pelion Device Management example
Fork of mbed-os-example-pelion by
pre-main/dispatch_host_command.cpp@5:ae686808e015, 2019-11-22 (annotated)
- Committer:
- ccli8
- Date:
- Fri Nov 22 14:40:12 2019 +0800
- Revision:
- 5:ae686808e015
Support memory statistics
Intercept other host command with:
1. 'h' for printing heap statistics
2. 's' for printing stack statistics
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ccli8 |
5:ae686808e015 | 1 | /* |
ccli8 |
5:ae686808e015 | 2 | * Copyright (c) 2019 Nuvoton Technology Corporation |
ccli8 |
5:ae686808e015 | 3 | * |
ccli8 |
5:ae686808e015 | 4 | * SPDX-License-Identifier: Apache-2.0 |
ccli8 |
5:ae686808e015 | 5 | * |
ccli8 |
5:ae686808e015 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
ccli8 |
5:ae686808e015 | 7 | * you may not use this file except in compliance with the License. |
ccli8 |
5:ae686808e015 | 8 | * You may obtain a copy of the License at |
ccli8 |
5:ae686808e015 | 9 | * |
ccli8 |
5:ae686808e015 | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
ccli8 |
5:ae686808e015 | 11 | * |
ccli8 |
5:ae686808e015 | 12 | * Unless required by applicable law or agreed to in writing, software |
ccli8 |
5:ae686808e015 | 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
ccli8 |
5:ae686808e015 | 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ccli8 |
5:ae686808e015 | 15 | * See the License for the specific language governing permissions and |
ccli8 |
5:ae686808e015 | 16 | * limitations under the License. |
ccli8 |
5:ae686808e015 | 17 | */ |
ccli8 |
5:ae686808e015 | 18 | |
ccli8 |
5:ae686808e015 | 19 | #include "mbed.h" |
ccli8 |
5:ae686808e015 | 20 | |
ccli8 |
5:ae686808e015 | 21 | /* Dispatch host command communicating via USB VCOM |
ccli8 |
5:ae686808e015 | 22 | * |
ccli8 |
5:ae686808e015 | 23 | * WARNING: For mass production, remove this file. |
ccli8 |
5:ae686808e015 | 24 | */ |
ccli8 |
5:ae686808e015 | 25 | |
ccli8 |
5:ae686808e015 | 26 | /* Check weak reference/definition at the link: |
ccli8 |
5:ae686808e015 | 27 | * http://www.keil.com/support/man/docs/ARMLINK/armlink_pge1362065917715.htm */ |
ccli8 |
5:ae686808e015 | 28 | |
ccli8 |
5:ae686808e015 | 29 | extern "C" { |
ccli8 |
5:ae686808e015 | 30 | MBED_USED void dispatch_host_command(int); |
ccli8 |
5:ae686808e015 | 31 | MBED_WEAK void print_heap_stats(void); |
ccli8 |
5:ae686808e015 | 32 | MBED_WEAK void print_stack_statistics(void); |
ccli8 |
5:ae686808e015 | 33 | } |
ccli8 |
5:ae686808e015 | 34 | |
ccli8 |
5:ae686808e015 | 35 | void dispatch_host_command(int c) |
ccli8 |
5:ae686808e015 | 36 | { |
ccli8 |
5:ae686808e015 | 37 | switch (c) { |
ccli8 |
5:ae686808e015 | 38 | case 'h': |
ccli8 |
5:ae686808e015 | 39 | print_heap_stats(); |
ccli8 |
5:ae686808e015 | 40 | break; |
ccli8 |
5:ae686808e015 | 41 | |
ccli8 |
5:ae686808e015 | 42 | case 's': |
ccli8 |
5:ae686808e015 | 43 | print_stack_statistics(); |
ccli8 |
5:ae686808e015 | 44 | break; |
ccli8 |
5:ae686808e015 | 45 | } |
ccli8 |
5:ae686808e015 | 46 | } |