Pequena LIB para fazer um LOGGER
Dependents: monitoramento_ativos
Revision 1:f23ad1b9a35a, committed 2019-05-04
- Comitter:
- AndersonIctus (anderson.ictus@gmail.com)
- Date:
- Sat May 04 08:56:58 2019 -0300
- Parent:
- 0:1019a5a78757
- Commit message:
- Incluido um logger pela serial da placa (Usando USB)
Changed in this revision
Logger.cpp | Show annotated file Show diff for this revision Revisions of this file |
Logger.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1019a5a78757 -r f23ad1b9a35a Logger.cpp --- a/Logger.cpp Thu May 02 23:51:34 2019 +0000 +++ b/Logger.cpp Sat May 04 08:56:58 2019 -0300 @@ -1,5 +1,13 @@ +#include "mbed.h" #include "Logger.h" -void Logger::log(string text) { - // printf("%s\r\n", text); +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> + +Logger::Logger() : _pc(USBTX, USBRX) { } + +void Logger::log(char* text) { + _pc.printf("%s\r\n", text); +}
diff -r 1019a5a78757 -r f23ad1b9a35a Logger.h --- a/Logger.h Thu May 02 23:51:34 2019 +0000 +++ b/Logger.h Sat May 04 08:56:58 2019 -0300 @@ -1,13 +1,22 @@ #ifndef MBED_LOGGER_H #define MBED_LOGGER_H -#include <string> -using namespace std; +#include "mbed.h" + +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> + +#define DEVICE_SERIAL 1 -class Logger { - +class Logger { public: - static void log(string text); + char buffer[256]; + Logger(); + void log(char* text); + + private: + Serial _pc; // tx, rx } ; #endif