Webserver+3d print
common/debug.h@0:8918a71cdbe9, 2017-02-04 (annotated)
- Committer:
- Sergunb
- Date:
- Sat Feb 04 18:15:49 2017 +0000
- Revision:
- 0:8918a71cdbe9
nothing else
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sergunb | 0:8918a71cdbe9 | 1 | /** |
Sergunb | 0:8918a71cdbe9 | 2 | * @file debug.h |
Sergunb | 0:8918a71cdbe9 | 3 | * @brief Debugging facilities |
Sergunb | 0:8918a71cdbe9 | 4 | * |
Sergunb | 0:8918a71cdbe9 | 5 | * @section License |
Sergunb | 0:8918a71cdbe9 | 6 | * |
Sergunb | 0:8918a71cdbe9 | 7 | * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. |
Sergunb | 0:8918a71cdbe9 | 8 | * |
Sergunb | 0:8918a71cdbe9 | 9 | * This program is free software; you can redistribute it and/or |
Sergunb | 0:8918a71cdbe9 | 10 | * modify it under the terms of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 11 | * as published by the Free Software Foundation; either version 2 |
Sergunb | 0:8918a71cdbe9 | 12 | * of the License, or (at your option) any later version. |
Sergunb | 0:8918a71cdbe9 | 13 | * |
Sergunb | 0:8918a71cdbe9 | 14 | * This program is distributed in the hope that it will be useful, |
Sergunb | 0:8918a71cdbe9 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Sergunb | 0:8918a71cdbe9 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Sergunb | 0:8918a71cdbe9 | 17 | * GNU General Public License for more details. |
Sergunb | 0:8918a71cdbe9 | 18 | * |
Sergunb | 0:8918a71cdbe9 | 19 | * You should have received a copy of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 20 | * along with this program; if not, write to the Free Software Foundation, |
Sergunb | 0:8918a71cdbe9 | 21 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
Sergunb | 0:8918a71cdbe9 | 22 | * |
Sergunb | 0:8918a71cdbe9 | 23 | * @author Oryx Embedded SARL (www.oryx-embedded.com) |
Sergunb | 0:8918a71cdbe9 | 24 | * @version 1.7.6 |
Sergunb | 0:8918a71cdbe9 | 25 | **/ |
Sergunb | 0:8918a71cdbe9 | 26 | |
Sergunb | 0:8918a71cdbe9 | 27 | #ifndef _DEBUG_H |
Sergunb | 0:8918a71cdbe9 | 28 | #define _DEBUG_H |
Sergunb | 0:8918a71cdbe9 | 29 | |
Sergunb | 0:8918a71cdbe9 | 30 | //Dependencies |
Sergunb | 0:8918a71cdbe9 | 31 | #include <stdio.h> |
Sergunb | 0:8918a71cdbe9 | 32 | #include "os_port.h" |
Sergunb | 0:8918a71cdbe9 | 33 | |
Sergunb | 0:8918a71cdbe9 | 34 | //Trace level definitions |
Sergunb | 0:8918a71cdbe9 | 35 | #define TRACE_LEVEL_OFF 0 |
Sergunb | 0:8918a71cdbe9 | 36 | #define TRACE_LEVEL_FATAL 1 |
Sergunb | 0:8918a71cdbe9 | 37 | #define TRACE_LEVEL_ERROR 2 |
Sergunb | 0:8918a71cdbe9 | 38 | #define TRACE_LEVEL_WARNING 3 |
Sergunb | 0:8918a71cdbe9 | 39 | #define TRACE_LEVEL_INFO 4 |
Sergunb | 0:8918a71cdbe9 | 40 | #define TRACE_LEVEL_DEBUG 5 |
Sergunb | 0:8918a71cdbe9 | 41 | |
Sergunb | 0:8918a71cdbe9 | 42 | //Default trace level |
Sergunb | 0:8918a71cdbe9 | 43 | #ifndef TRACE_LEVEL |
Sergunb | 0:8918a71cdbe9 | 44 | #define TRACE_LEVEL TRACE_LEVEL_DEBUG |
Sergunb | 0:8918a71cdbe9 | 45 | #endif |
Sergunb | 0:8918a71cdbe9 | 46 | |
Sergunb | 0:8918a71cdbe9 | 47 | //Trace output redirection |
Sergunb | 0:8918a71cdbe9 | 48 | #ifndef TRACE_PRINTF |
Sergunb | 0:8918a71cdbe9 | 49 | #define TRACE_PRINTF(...) osSuspendAllTasks(), fprintf(stderr, __VA_ARGS__), osResumeAllTasks() |
Sergunb | 0:8918a71cdbe9 | 50 | #endif |
Sergunb | 0:8918a71cdbe9 | 51 | |
Sergunb | 0:8918a71cdbe9 | 52 | #ifndef TRACE_ARRAY |
Sergunb | 0:8918a71cdbe9 | 53 | #define TRACE_ARRAY(p, a, n) osSuspendAllTasks(), debugDisplayArray(stderr, p, a, n), osResumeAllTasks() |
Sergunb | 0:8918a71cdbe9 | 54 | #endif |
Sergunb | 0:8918a71cdbe9 | 55 | |
Sergunb | 0:8918a71cdbe9 | 56 | #ifndef TRACE_MPI |
Sergunb | 0:8918a71cdbe9 | 57 | #define TRACE_MPI(p, a) osSuspendAllTasks(), mpiDump(stderr, p, a), osResumeAllTasks() |
Sergunb | 0:8918a71cdbe9 | 58 | #endif |
Sergunb | 0:8918a71cdbe9 | 59 | |
Sergunb | 0:8918a71cdbe9 | 60 | //Debugging macros |
Sergunb | 0:8918a71cdbe9 | 61 | #if (TRACE_LEVEL >= TRACE_LEVEL_FATAL) |
Sergunb | 0:8918a71cdbe9 | 62 | #define TRACE_FATAL(...) TRACE_PRINTF(__VA_ARGS__) |
Sergunb | 0:8918a71cdbe9 | 63 | #else |
Sergunb | 0:8918a71cdbe9 | 64 | #define TRACE_FATAL(...) |
Sergunb | 0:8918a71cdbe9 | 65 | #endif |
Sergunb | 0:8918a71cdbe9 | 66 | |
Sergunb | 0:8918a71cdbe9 | 67 | #if (TRACE_LEVEL >= TRACE_LEVEL_ERROR) |
Sergunb | 0:8918a71cdbe9 | 68 | #define TRACE_ERROR(...) TRACE_PRINTF(__VA_ARGS__) |
Sergunb | 0:8918a71cdbe9 | 69 | #else |
Sergunb | 0:8918a71cdbe9 | 70 | #define TRACE_ERROR(...) |
Sergunb | 0:8918a71cdbe9 | 71 | #endif |
Sergunb | 0:8918a71cdbe9 | 72 | |
Sergunb | 0:8918a71cdbe9 | 73 | #if (TRACE_LEVEL >= TRACE_LEVEL_WARNING) |
Sergunb | 0:8918a71cdbe9 | 74 | #define TRACE_WARNING(...) TRACE_PRINTF(__VA_ARGS__) |
Sergunb | 0:8918a71cdbe9 | 75 | #else |
Sergunb | 0:8918a71cdbe9 | 76 | #define TRACE_WARNING(...) |
Sergunb | 0:8918a71cdbe9 | 77 | #endif |
Sergunb | 0:8918a71cdbe9 | 78 | |
Sergunb | 0:8918a71cdbe9 | 79 | #if (TRACE_LEVEL >= TRACE_LEVEL_INFO) |
Sergunb | 0:8918a71cdbe9 | 80 | #define TRACE_INFO(...) TRACE_PRINTF(__VA_ARGS__) |
Sergunb | 0:8918a71cdbe9 | 81 | #define TRACE_INFO_ARRAY(p, a, n) TRACE_ARRAY(p, a, n) |
Sergunb | 0:8918a71cdbe9 | 82 | #define TRACE_INFO_NET_BUFFER(p, b, o, n) |
Sergunb | 0:8918a71cdbe9 | 83 | #define TRACE_INFO_MPI(p, a) TRACE_MPI(p, a) |
Sergunb | 0:8918a71cdbe9 | 84 | #else |
Sergunb | 0:8918a71cdbe9 | 85 | #define TRACE_INFO(...) |
Sergunb | 0:8918a71cdbe9 | 86 | #define TRACE_INFO_ARRAY(p, a, n) |
Sergunb | 0:8918a71cdbe9 | 87 | #define TRACE_INFO_NET_BUFFER(p, b, o, n) |
Sergunb | 0:8918a71cdbe9 | 88 | #define TRACE_INFO_MPI(p, a) |
Sergunb | 0:8918a71cdbe9 | 89 | #endif |
Sergunb | 0:8918a71cdbe9 | 90 | |
Sergunb | 0:8918a71cdbe9 | 91 | #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG) |
Sergunb | 0:8918a71cdbe9 | 92 | #define TRACE_DEBUG(...) TRACE_PRINTF(__VA_ARGS__) |
Sergunb | 0:8918a71cdbe9 | 93 | #define TRACE_DEBUG_ARRAY(p, a, n) TRACE_ARRAY(p, a, n) |
Sergunb | 0:8918a71cdbe9 | 94 | #define TRACE_DEBUG_NET_BUFFER(p, b, o, n) |
Sergunb | 0:8918a71cdbe9 | 95 | #define TRACE_DEBUG_MPI(p, a) TRACE_MPI(p, a) |
Sergunb | 0:8918a71cdbe9 | 96 | #else |
Sergunb | 0:8918a71cdbe9 | 97 | #define TRACE_DEBUG(...) |
Sergunb | 0:8918a71cdbe9 | 98 | #define TRACE_DEBUG_ARRAY(p, a, n) |
Sergunb | 0:8918a71cdbe9 | 99 | #define TRACE_DEBUG_NET_BUFFER(p, b, o, n) |
Sergunb | 0:8918a71cdbe9 | 100 | #define TRACE_DEBUG_MPI(p, a) |
Sergunb | 0:8918a71cdbe9 | 101 | #endif |
Sergunb | 0:8918a71cdbe9 | 102 | |
Sergunb | 0:8918a71cdbe9 | 103 | //Debug related functions |
Sergunb | 0:8918a71cdbe9 | 104 | void debugInit(uint32_t baudrate); |
Sergunb | 0:8918a71cdbe9 | 105 | |
Sergunb | 0:8918a71cdbe9 | 106 | void debugDisplayArray(FILE *stream, |
Sergunb | 0:8918a71cdbe9 | 107 | const char_t *prepend, const void *data, size_t length); |
Sergunb | 0:8918a71cdbe9 | 108 | |
Sergunb | 0:8918a71cdbe9 | 109 | //Deprecated definitions |
Sergunb | 0:8918a71cdbe9 | 110 | #define TRACE_LEVEL_NO_TRACE TRACE_LEVEL_OFF |
Sergunb | 0:8918a71cdbe9 | 111 | |
Sergunb | 0:8918a71cdbe9 | 112 | #endif |
Sergunb | 0:8918a71cdbe9 | 113 |