Add missing undefined symbols to be sure to use mine
Dependents: DS130x_I2CApp MCP41xxxApp FM24Vxx_I2CApp MCP320xApp ... more
Diff: Debug.h
- Revision:
- 4:d03fcf494eb6
- Parent:
- 3:be0c7a9bd686
- Child:
- 5:7ddb6bca6d01
diff -r be0c7a9bd686 -r d03fcf494eb6 Debug.h --- a/Debug.h Wed Nov 24 12:30:18 2010 +0000 +++ b/Debug.h Wed Dec 08 13:16:16 2010 +0000 @@ -27,7 +27,7 @@ /** The steps below describe how to use this library: * 1. Import this library to your project 'As file', because you will need to modify this file as described in step 2 * 2. Edit this library - * 3. Remove comment from line 58 (search for '//#define __DEBUG' in this file) to get the DEBUG macro defimed properly. By default, __DEBUG flahg is undef + * 3. Remove comment from line 64 (search for '//#define __DEBUG' in this file) to get the DEBUG macro defimed properly. By default, __DEBUG flahg is undef * 4. Rebuild this library and use the debug macro as decribe in sample code * * IMPORTANT: If you modify this libray, please keep this comment up to date for future users @@ -42,6 +42,12 @@ * int main() { * DEBUG_ENTER("main") // Log the entry of the C function 'main' * int counter = 0; + * std::string str("This is a sample for heaxdecimal dump using DebugLibrary"); + * DEBUG(">>> Example:"); + * HEXADUMP((unsigned char *)str.c_str(), str.length()); + * DEBUG("==="); + * HEXADUMP_OFFSET((unsigned char *)str.c_str(), str.length(), 19); + * DEBUG("<<<"); * while(1) { * DEBUG("In loop [%d]", counter++) // A sample message * myled = 1; @@ -64,19 +70,31 @@ #ifdef __DEBUG -/** This class implements debug functionalities based on USB console interface. V0.0.0.4 +/** This class implements debug functionalities based on USB console interface. V0.0.0.5 * * Note that this class is based on Helper pattern */ class DebugHelper { + static inline unsigned char ToHexDigit(unsigned char p_digit) { return ((p_digit < 10) ? (p_digit + 0x30) : (p_digit + 0x37)); }; + static inline char ToCharDigit(unsigned char p_digit) { return (((p_digit < 0x20) || (p_digit > 0x80)) ? '.' : (char)p_digit); }; public: - /** Log method + /** Standard log method + * @param p_format Format string compliant with C 'printf' format string */ - static void Debug(const char* format, ...); + static void Debug(const char* p_format, ...); + /** Log an hexadecimal buffer + * + * Note that parameters 'p_offset' and 'p_length' are not supported yet + * + * @param p_buffer The buffer to dump + * @param p_count Number of bytes to dump + * @param p_offset Offset to start the dump. Default: 0 + */ + static void HexaDump(unsigned char* p_buffer, int p_count, int p_offset = 0); /** Break point method based on getchar() C function */ - static void BreakPoint(const char* file, int line); + static void BreakPoint(const char* p_file, int p_line); }; // End of class DebugHelper /** Used to log function/method entry (>> ) @@ -94,6 +112,16 @@ * Note that \ for multiline macro is not supported yet */ #define DEBUG(...) do { DebugHelper::Debug(__VA_ARGS__); DebugHelper::Debug("\r\n"); } while(false); +/** Used to dump an hexadecimal buffer + * + * Note that \ for multiline macro is not supported yet + */ +#define HEXADUMP(p_buffer, p_count) DebugHelper::HexaDump(p_buffer, p_count); +/** Used to dump an hexadecimal buffer with an offset + * + * Note that \ for multiline macro is not supported yet + */ +#define HEXADUMP_OFFSET(p_buffer, p_count, p_offset) DebugHelper::HexaDump(p_buffer, p_count, p_offset); /** Used to log an error message (?? ) * * Note that \ for multiline macro is not supported yet @@ -124,6 +152,16 @@ /** Undefine DEBUG macro, used when __DEBUG is undefined */ #define DEBUG(...) +/** Undefine DEBUG macro, used when __DEBUG is undefined + * + * Note that \ for multiline macro is not supported yet + */ +#define HEXADUMP(p_buffer, p_count) +/** Undefine DEBUG macro, used when __DEBUG is undefined + * + * Note that \ for multiline macro is not supported yet + */ +#define HEXADUMP_OFFSET(p_buffer, p_count, p_offset) /** Undefine DEBUG_ERROR macro, used when __DEBUG is undefined */ #define DEBUG_ERROR(...)