Core Base Classes for the Light Endpoints
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more
Diff: ErrorHandler.cpp
- Revision:
- 74:b60149dd669e
- Parent:
- 73:3e6478c7649f
- Child:
- 82:24af66daaf17
diff -r 3e6478c7649f -r b60149dd669e ErrorHandler.cpp --- a/ErrorHandler.cpp Tue Mar 04 05:26:52 2014 +0000 +++ b/ErrorHandler.cpp Tue Mar 04 16:48:20 2014 +0000 @@ -30,8 +30,7 @@ PwmOut b(p25); // Memory statistics macro -#ifdef ENABLE_MEMORY_DEBUG - #define MEM_STATS(x) \ +#define MEM_STATS(x) \ int s##x=0;\ int *h##x = new int [1];\ this->m_pc->printf("\r\nMEMORY: stack: 0x%08x heap: 0x%08x avail: %d bytes\r\n", &s##x, h##x, &s##x-h##x);\ @@ -39,7 +38,6 @@ error("collision\n");\ delete [] h##x;\ __nop(); -#endif // close down connections extern void closedown(int code); @@ -95,6 +93,21 @@ if (this->m_mutex != NULL) this->m_mutex->unlock(); } + // log information + void ErrorHandler::log_memory(const char *format, ...) { + #ifdef MEMORY_LOGGING + if (this->m_mutex != NULL) this->m_mutex->lock(); + memset(this->m_message,0,MAX_LOG_MESSAGE+1); + va_list args; + va_start(args, format); + vsprintf(this->m_message, format, args); + va_end(args); + this->m_pc->printf(this->m_message); + MEM_STATS(0); + if (this->m_mutex != NULL) this->m_mutex->unlock(); + #endif + } + // pause void ErrorHandler::pause(const char *format, ...) { if (this->m_mutex != NULL) this->m_mutex->lock();