Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers debug.h Source File

debug.h

Go to the documentation of this file.
00001 /**
00002  * @file debug.h
00003  * @brief Debugging facilities
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License
00011  * as published by the Free Software Foundation; either version 2
00012  * of the License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software Foundation,
00021  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00022  *
00023  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00024  * @version 1.7.6
00025  **/
00026 
00027 #ifndef _DEBUG_H
00028 #define _DEBUG_H
00029 
00030 //Dependencies
00031 #include <stdio.h>
00032 #include "os_port.h"
00033 
00034 //Trace level definitions
00035 #define TRACE_LEVEL_OFF      0
00036 #define TRACE_LEVEL_FATAL    1
00037 #define TRACE_LEVEL_ERROR    2
00038 #define TRACE_LEVEL_WARNING  3
00039 #define TRACE_LEVEL_INFO     4
00040 #define TRACE_LEVEL_DEBUG    5
00041 
00042 //Default trace level
00043 #ifndef TRACE_LEVEL
00044    #define TRACE_LEVEL TRACE_LEVEL_DEBUG
00045 #endif
00046 
00047 //Trace output redirection
00048 #ifndef TRACE_PRINTF
00049    #define TRACE_PRINTF(...) osSuspendAllTasks(), fprintf(stderr, __VA_ARGS__), osResumeAllTasks()
00050 #endif
00051 
00052 #ifndef TRACE_ARRAY
00053    #define TRACE_ARRAY(p, a, n) osSuspendAllTasks(), debugDisplayArray(stderr, p, a, n), osResumeAllTasks()
00054 #endif
00055 
00056 #ifndef TRACE_MPI
00057    #define TRACE_MPI(p, a) osSuspendAllTasks(), mpiDump(stderr, p, a), osResumeAllTasks()
00058 #endif
00059 
00060 //Debugging macros
00061 #if (TRACE_LEVEL >= TRACE_LEVEL_FATAL)
00062    #define TRACE_FATAL(...) TRACE_PRINTF(__VA_ARGS__)
00063 #else
00064    #define TRACE_FATAL(...)
00065 #endif
00066 
00067 #if (TRACE_LEVEL >= TRACE_LEVEL_ERROR)
00068    #define TRACE_ERROR(...) TRACE_PRINTF(__VA_ARGS__)
00069 #else
00070    #define TRACE_ERROR(...)
00071 #endif
00072 
00073 #if (TRACE_LEVEL >= TRACE_LEVEL_WARNING)
00074    #define TRACE_WARNING(...) TRACE_PRINTF(__VA_ARGS__)
00075 #else
00076    #define TRACE_WARNING(...)
00077 #endif
00078 
00079 #if (TRACE_LEVEL >= TRACE_LEVEL_INFO)
00080    #define TRACE_INFO(...) TRACE_PRINTF(__VA_ARGS__)
00081    #define TRACE_INFO_ARRAY(p, a, n) TRACE_ARRAY(p, a, n)
00082    #define TRACE_INFO_NET_BUFFER(p, b, o, n)
00083    #define TRACE_INFO_MPI(p, a) TRACE_MPI(p, a)
00084 #else
00085    #define TRACE_INFO(...)
00086    #define TRACE_INFO_ARRAY(p, a, n)
00087    #define TRACE_INFO_NET_BUFFER(p, b, o, n)
00088    #define TRACE_INFO_MPI(p, a)
00089 #endif
00090 
00091 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
00092    #define TRACE_DEBUG(...) TRACE_PRINTF(__VA_ARGS__)
00093    #define TRACE_DEBUG_ARRAY(p, a, n) TRACE_ARRAY(p, a, n)
00094    #define TRACE_DEBUG_NET_BUFFER(p, b, o, n)
00095    #define TRACE_DEBUG_MPI(p, a) TRACE_MPI(p, a)
00096 #else
00097    #define TRACE_DEBUG(...)
00098    #define TRACE_DEBUG_ARRAY(p, a, n)
00099    #define TRACE_DEBUG_NET_BUFFER(p, b, o, n)
00100    #define TRACE_DEBUG_MPI(p, a)
00101 #endif
00102 
00103 //Debug related functions
00104 void debugInit(uint32_t baudrate);
00105 
00106 void debugDisplayArray(FILE *stream,
00107    const char_t *prepend, const void *data, size_t length);
00108 
00109 //Deprecated definitions
00110 #define TRACE_LEVEL_NO_TRACE TRACE_LEVEL_OFF
00111 
00112 #endif
00113