Browse Source

Add ellipsis when debug message too long

fastled
Xose Pérez 7 years ago
parent
commit
cc660a5737
1 changed files with 16 additions and 4 deletions
  1. +16
    -4
      code/espurna/debug.ino

+ 16
- 4
code/espurna/debug.ino View File

@ -20,16 +20,22 @@ void debugSend(const char * format, ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
ets_vsnprintf(buffer, DEBUG_MESSAGE_MAX_LENGTH, format, args);
int len = ets_vsnprintf(buffer, DEBUG_MESSAGE_MAX_LENGTH, format, args);
va_end(args); va_end(args);
#ifdef DEBUG_PORT #ifdef DEBUG_PORT
DEBUG_PORT.printf(buffer); DEBUG_PORT.printf(buffer);
if (len > DEBUG_MESSAGE_MAX_LENGTH) {
DEBUG_PORT.printf(" (...)\n");
}
#endif #endif
#ifdef DEBUG_UDP_IP #ifdef DEBUG_UDP_IP
udpDebug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT); udpDebug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT);
udpDebug.write(buffer); udpDebug.write(buffer);
if (len > DEBUG_MESSAGE_MAX_LENGTH) {
udpDebug.write(" (...)\n");
}
udpDebug.endPacket(); udpDebug.endPacket();
#endif #endif
@ -37,23 +43,29 @@ void debugSend(const char * format, ...) {
void debugSend_P(PGM_P format, ...) { void debugSend_P(PGM_P format, ...) {
char buffer[DEBUG_MESSAGE_MAX_LENGTH+1];
char f[DEBUG_MESSAGE_MAX_LENGTH+1]; char f[DEBUG_MESSAGE_MAX_LENGTH+1];
memcpy_P(f, format, DEBUG_MESSAGE_MAX_LENGTH); memcpy_P(f, format, DEBUG_MESSAGE_MAX_LENGTH);
char buffer[DEBUG_MESSAGE_MAX_LENGTH+1];
va_list args; va_list args;
va_start(args, format); va_start(args, format);
ets_vsnprintf(buffer, DEBUG_MESSAGE_MAX_LENGTH, f, args);
int len = ets_vsnprintf(buffer, DEBUG_MESSAGE_MAX_LENGTH, f, args);
va_end(args); va_end(args);
#ifdef DEBUG_PORT #ifdef DEBUG_PORT
DEBUG_PORT.printf(buffer); DEBUG_PORT.printf(buffer);
if (len > DEBUG_MESSAGE_MAX_LENGTH) {
DEBUG_PORT.printf(" (...)\n");
}
#endif #endif
#ifdef DEBUG_UDP_IP #ifdef DEBUG_UDP_IP
udpDebug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT); udpDebug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT);
udpDebug.write(buffer); udpDebug.write(buffer);
if (len > DEBUG_MESSAGE_MAX_LENGTH) {
udpDebug.write(" (...)\n");
}
udpDebug.endPacket(); udpDebug.endPacket();
#endif #endif


Loading…
Cancel
Save