Add missing undefined symbols to be sure to use mine
Dependents: DS130x_I2CApp MCP41xxxApp FM24Vxx_I2CApp MCP320xApp ... more
Revision 5:7ddb6bca6d01, committed 2010-12-08
- Comitter:
- Yann
- Date:
- Wed Dec 08 13:33:24 2010 +0000
- Parent:
- 4:d03fcf494eb6
- Child:
- 6:14a596126adf
- Commit message:
- V0.0.0.6
Changed in this revision
Debug.cpp | Show annotated file Show diff for this revision Revisions of this file |
Debug.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Debug.cpp Wed Dec 08 13:16:16 2010 +0000 +++ b/Debug.cpp Wed Dec 08 13:33:24 2010 +0000 @@ -3,6 +3,8 @@ #ifdef __DEBUG +#define __LINE_LENGTH__ 91 + void DebugHelper::Debug(const char* p_format, ...) { va_list argp; @@ -24,8 +26,8 @@ // 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 // 0 1 2 3 4 5 6 7 8 9 // Address offset padding - char line[91]; - memset(line, 0x20, 91); + char line[__LINE_LENGTH__]; + memset(line, 0x20, __LINE_LENGTH__); sprintf(line, "%04x |", (unsigned short)startAddress); line[6] = 0x20; // Remove NULL character added by sprintf int idx = 0; @@ -51,12 +53,12 @@ } // Display the line line[56] = ':'; - line[89] = 0x0d; - line[90] = 0x0a; + line[__LINE_LENGTH__ - 2] = 0x0d; + line[__LINE_LENGTH__ - 1] = 0x0a; printf(line); if (currentIdx < endOfDump) { // Prepare next line, one line = 16 digits startAddress += 16; - memset(line, 0x20, 91); + memset(line, 0x20, __LINE_LENGTH__); sprintf(line, "%04x |", (unsigned short)startAddress); line[6] = 0x20; // Remove NULL character added by sprintf idx = 0;
--- a/Debug.h Wed Dec 08 13:16:16 2010 +0000 +++ b/Debug.h Wed Dec 08 13:33:24 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 64 (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 66 (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 @@ -41,13 +41,15 @@ * * 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); + * HEXADUMP_OFFSET((unsigned char *)str.c_str(), str.length() - 19, 19); * DEBUG("<<<"); + * + * int counter = 0; * while(1) { * DEBUG("In loop [%d]", counter++) // A sample message * myled = 1; @@ -70,13 +72,23 @@ #ifdef __DEBUG -/** This class implements debug functionalities based on USB console interface. V0.0.0.5 +/** This class implements debug functionalities based on USB console interface. V0.0.0.6 * * Note that this class is based on Helper pattern */ class DebugHelper { + /** Convert the specified digit into hexadecimal number (0x30..0x39 (0..9), 0x47..x4c (A..F)) + * + * @param p_digit The digit to convert + * @return An hexadecimal digit (0..9-A..F) + */ static inline unsigned char ToHexDigit(unsigned char p_digit) { return ((p_digit < 10) ? (p_digit + 0x30) : (p_digit + 0x37)); }; + /** Convert the specified hexadecimal digit into a character if it is printable, or replace by a '.' otherwise + * + * @param p_digit The hexadecimal digit to convert + * @return A character is it's printable, '.' otherwise + */ static inline char ToCharDigit(unsigned char p_digit) { return (((p_digit < 0x20) || (p_digit > 0x80)) ? '.' : (char)p_digit); }; public: /** Standard log method