Skip to content

Commit

Permalink
Adds app/diagnostics application from #1424
Browse files Browse the repository at this point in the history
  • Loading branch information
avtolstoy committed Nov 9, 2017
1 parent eb6a720 commit 6b5cf8a
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions user/tests/app/diagnostics/diagnostics.cpp
@@ -0,0 +1,38 @@
#include "application.h"

SYSTEM_THREAD(ENABLED);

namespace {

const Serial1LogHandler logHandler(115200, LOG_LEVEL_WARN, {
{ "app", LOG_LEVEL_ALL }
});

const SerialLogHandler logHandler1(LOG_LEVEL_WARN, {
{ "app", LOG_LEVEL_ALL }
});


unsigned logMillis = 0;
unsigned logCount = 0;

bool logDiagnosticData(void* appender, const uint8_t* data, size_t size) {
Log.write(LOG_LEVEL_INFO, (const char*)data, size);
return true;
}

} // namespace

void setup() {
logMillis = millis();
}

void loop() {
if (millis() - logMillis >= 5000) {
++logCount;
Log.printf(LOG_LEVEL_INFO, "%u: ", logCount);
system_format_diag_data(nullptr, 0, 0, logDiagnosticData, nullptr, nullptr);
Log.print(LOG_LEVEL_INFO, "\r\n");
logMillis = millis();
}
}

0 comments on commit 6b5cf8a

Please sign in to comment.