Skip to content
Snippets Groups Projects
Verified Commit 4aaa55bb authored by Konstantinos Kanavouras's avatar Konstantinos Kanavouras
Browse files

Use the new logging functions on the mockup as well

parent 0a3bc203
No related branches found
No related tags found
No related merge requests found
......@@ -2,5 +2,9 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/Lib/ecss-services" vcs="Git" />
<mapping directory="$PROJECT_DIR$/Lib/ecss-services/ci/page_style/doxygen_dark_theme" vcs="Git" />
<mapping directory="$PROJECT_DIR$/Lib/ecss-services/lib/Catch2" vcs="Git" />
<mapping directory="$PROJECT_DIR$/Lib/ecss-services/lib/etl" vcs="Git" />
</component>
</project>
\ No newline at end of file
Subproject commit 49f6188a6128ab6da80fb0589eddbafc1eebf635
Subproject commit 5e8c791d34a23f504946d8d38c565591e4308be0
......@@ -8,6 +8,7 @@
#include <cxxabi.h>
#include <ErrorHandler.hpp>
#include <Message.hpp>
#include <inc/Logger.hpp>
template void ErrorHandler::logError(const Message&, ErrorHandler::AcceptanceErrorType);
template void ErrorHandler::logError(const Message&, ErrorHandler::ExecutionStartErrorType);
......@@ -18,14 +19,11 @@ template void ErrorHandler::logError(ErrorHandler::InternalErrorType);
template <typename ErrorType>
void ErrorHandler::logError(const Message& message, ErrorType errorType) {
char string [90];
snprintf(string, 90, "ERROR %s on [%2d,%2d]\r\n", abi::__cxa_demangle(typeid(ErrorType).name(), nullptr, nullptr, nullptr), message.serviceType, message.messageType);
sendUARTString(string);
LOG_ERROR << abi::__cxa_demangle(typeid(ErrorType).name(), nullptr, nullptr, nullptr)
<< " on " << "[" << message.serviceType << "," << message.messageType << "]";
}
template <typename ErrorType>
void ErrorHandler::logError(ErrorType errorType) {
char string [90];
snprintf(string, 90, "ERROR %s\r\n", abi::__cxa_demangle(typeid(ErrorType).name(), nullptr, nullptr, nullptr));
sendUARTString(string);
LOG_ERROR << abi::__cxa_demangle(typeid(ErrorType).name(), nullptr, nullptr, nullptr);
}
#include <inc/Logger.hpp>
#include "main.h"
void Logger::log(Logger::LogLevel level, String<LOGGER_MAX_MESSAGE_SIZE> & message) {
char uartMessage[256];
char name[10];
if (level <= Logger::trace) {
strcpy(name, "trace");
} else if (level <= Logger::debug) {
strcpy(name, "debug");
} else if (level <= Logger::info) {
strcpy(name, "info");
} else if (level <= Logger::notice) {
strcpy(name, "notice");
} else if (level <= Logger::warning) {
strcpy(name, "warning");
} else if (level <= Logger::error) {
strcpy(name, "error");
} else {
strcpy(name, "emergency");
}
snprintf(uartMessage, 256, "%-7lu [%-7s] %s\r\n", HAL_GetTick(), name, message.c_str());
sendUARTString(uartMessage);
}
\ No newline at end of file
#include "main.h"
#include <iostream>
#include <iomanip>
#include <inc/Logger.hpp>
#include "Service.hpp"
void Service::storeMessage(Message& message) {
// appends the remaining bits to complete a byte
message.finalize();
// Generate a report and send it away via UART
char string[90];
snprintf(string, 90, "New %s [%2d,%2d]\r\n", (message.packetType == Message::TM) ? "TM" : "TC", message.serviceType, message.messageType);
sendUARTString(string);
// Generate a report and log it away
LOG_DEBUG << "New " << ((message.packetType == Message::TM) ? "TM" : "TC")
<< " [" << message.serviceType << "," << message.messageType << "]";
}
......@@ -105,12 +105,8 @@ int main(void)
#pragma clang diagnostic ignored "-Wmissing-noreturn"
while (1)
{
const char string[90];
snprintf(string, 90, "A? %d\r\n", HAL_GetTick());
main_cpp();
HAL_UART_Transmit(&huart2, string, strlen(string), 10000);
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_2);
HAL_Delay(100);
/* USER CODE END WHILE */
......
#include <cstdio>
#include <inc/ServicePool.hpp>
#include <inc/Message.hpp>
#include <inc/Logger.hpp>
extern "C" {
#include "main.h"
......@@ -40,8 +41,6 @@ extern "C" {
ErrorHandler::reportError(msg, ErrorHandler::UnknownAcceptanceError);
// Print the temperature
char temperature[50];
snprintf(temperature, 50, "Temperature is %.1f\r\n", getTemperature(), getTemperature());
sendUARTString(temperature);
LOG_INFO << "Temperature is " << getTemperature();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment