Portado para MBED OS 6

Dependents:   Navitec-Firmware

Committer:
renanbmx123
Date:
Sun Apr 04 14:38:12 2021 +0000
Revision:
6:3fdb7f0f121a
Parent:
5:58c5158b5120
Refatorado;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
spastor 0:e83acb8d505c 1 /**
spastor 0:e83acb8d505c 2 * Copyright (c) 2015 Digi International Inc.,
spastor 0:e83acb8d505c 3 * All rights not expressly granted are reserved.
spastor 0:e83acb8d505c 4 *
spastor 0:e83acb8d505c 5 * This Source Code Form is subject to the terms of the Mozilla Public
spastor 0:e83acb8d505c 6 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
spastor 0:e83acb8d505c 7 * You can obtain one at http://mozilla.org/MPL/2.0/.
spastor 0:e83acb8d505c 8 *
spastor 0:e83acb8d505c 9 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
spastor 0:e83acb8d505c 10 * =======================================================================
spastor 0:e83acb8d505c 11 */
spastor 0:e83acb8d505c 12
spastor 0:e83acb8d505c 13 #include "DigiLoggerMbedSerial.h"
spastor 0:e83acb8d505c 14
spastor 0:e83acb8d505c 15 using namespace DigiLog;
spastor 0:e83acb8d505c 16
renanbmx123 6:3fdb7f0f121a 17 //Serial *DigiLoggerMbedSerial::_log_serial;
renanbmx123 6:3fdb7f0f121a 18 BufferedSerial *DigiLoggerMbedSerial::_log_serial;
spastor 0:e83acb8d505c 19 /* Class constructor when using a serial port as logging channel */
renanbmx123 6:3fdb7f0f121a 20 DigiLoggerMbedSerial::DigiLoggerMbedSerial(BufferedSerial * log_serial, LogLevel log_level)
spastor 0:e83acb8d505c 21 {
spastor 0:e83acb8d505c 22 _log_serial = log_serial;
spastor 0:e83acb8d505c 23
spastor 0:e83acb8d505c 24 _log_level = log_level;
spastor 0:e83acb8d505c 25
spastor 0:e83acb8d505c 26 DigiLogger::current_logger = this;
spastor 0:e83acb8d505c 27 }
spastor 0:e83acb8d505c 28
spastor 0:e83acb8d505c 29 /* Class destructor */
spastor 0:e83acb8d505c 30 DigiLoggerMbedSerial::~DigiLoggerMbedSerial()
spastor 0:e83acb8d505c 31 {
spastor 5:58c5158b5120 32 _log_serial = NULL;
spastor 5:58c5158b5120 33 DigiLogger::current_logger = NULL;
spastor 0:e83acb8d505c 34 }
spastor 0:e83acb8d505c 35
spastor 0:e83acb8d505c 36 void DigiLoggerMbedSerial::log_buffer(char const * const buffer)
spastor 0:e83acb8d505c 37 {
spastor 5:58c5158b5120 38 if (_log_serial == NULL) {
spastor 0:e83acb8d505c 39 return;
spastor 5:58c5158b5120 40 }
spastor 0:e83acb8d505c 41
renanbmx123 6:3fdb7f0f121a 42 //_log_serial->printf("%s", buffer);
renanbmx123 6:3fdb7f0f121a 43 //fflush(*_log_serial);
renanbmx123 6:3fdb7f0f121a 44 _log_serial->write(&buffer, sizeof(buffer));
renanbmx123 6:3fdb7f0f121a 45 _log_serial->sync();
spastor 0:e83acb8d505c 46 }
spastor 0:e83acb8d505c 47
spastor 0:e83acb8d505c 48
spastor 0:e83acb8d505c 49