Skip to content

Commit

Permalink
Rename CATS_DEBUG to CATS_DEV to avoid confusion with debug build (#373)
Browse files Browse the repository at this point in the history
Closes #361
  • Loading branch information
stojadin2701 authored Dec 3, 2023
1 parent 06753d0 commit f2ac84d
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion flight_computer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
else ()
message(STATUS "Minimal optimization, debug info included")
add_compile_options(-Og -g)
#add_definitions(-DCATS_DEBUG)
#add_definitions(-DCATS_DEV)
endif ()

include_directories(
Expand Down
4 changes: 2 additions & 2 deletions flight_computer/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ build_flags =
[env:release]
build_flags =
${env.build_flags}
#-D CATS_DEBUG
#-D CATS_DEV

[env:debug]
build_type=debug
debug_build_flags =
-O0
-ggdb3
-g3
-D CATS_DEBUG
-D CATS_DEV
2 changes: 1 addition & 1 deletion flight_computer/src/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ extern uint32_t SystemCoreClock;
#define configGENERATE_RUN_TIME_STATS 0
#define configUSE_STATS_FORMATTING_FUNCTIONS 0

#ifdef CATS_DEBUG
#ifdef CATS_DEV
#define configCHECK_FOR_STACK_OVERFLOW 2
#else
#define configCHECK_FOR_STACK_OVERFLOW 0
Expand Down
10 changes: 5 additions & 5 deletions flight_computer/src/cli/cli_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "cli/cli_commands.hpp"

#ifdef CATS_DEBUG
#ifdef CATS_DEV
#include "tasks/task_simulator.hpp"
#endif

Expand Down Expand Up @@ -64,7 +64,7 @@ static void cli_cmd_flash_write(const char *cmd_name, char *args);
static void cli_cmd_flash_stop(const char *cmd_name, char *args);
static void cli_cmd_flash_test(const char *cmd_name, char *args);

#ifdef CATS_DEBUG
#ifdef CATS_DEV
static void cli_cmd_start_simulation(const char *cmd_name, char *args);
#endif

Expand All @@ -91,7 +91,7 @@ const clicmd_t cmd_table[] = {
CLI_COMMAND_DEF("rm", "remove a file", "<file_name>", cli_cmd_rm),
CLI_COMMAND_DEF("save", "save configuration", nullptr, cli_cmd_save),
CLI_COMMAND_DEF("set", "change setting", "[<cmd_name>=<value>]", cli_cmd_set),
#ifdef CATS_DEBUG
#ifdef CATS_DEV
CLI_COMMAND_DEF("sim", "start a simulation flight", "<sim_tag>", cli_cmd_start_simulation),
#endif
CLI_COMMAND_DEF("stats", "print flight stats", "<flight_number>", cli_cmd_print_stats),
Expand Down Expand Up @@ -412,7 +412,7 @@ static void cli_cmd_status(const char *cmd_name [[maybe_unused]], char *args [[m
static_cast<double>(task::global_state_estimation->GetEstimationOutput().velocity),
static_cast<double>(task::global_state_estimation->GetEstimationOutput().acceleration));

#ifdef CATS_DEBUG
#ifdef CATS_DEV
if (strcmp(args, "--heap") == 0) {
HeapStats_t heap_stats = {};
vPortGetHeapStats(&heap_stats);
Expand Down Expand Up @@ -851,7 +851,7 @@ static void cli_cmd_flash_test(const char *cmd_name [[maybe_unused]], char *args
cli_print_line("Test complete!");
}

#ifdef CATS_DEBUG
#ifdef CATS_DEV
static void cli_cmd_start_simulation(const char *cmd_name [[maybe_unused]], char *args) { start_simulation(args); }
#endif

Expand Down
6 changes: 3 additions & 3 deletions flight_computer/src/config/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ extern volatile recorder_status_e global_recorder_status;
extern event_action_map_elem_t* event_action_map;

// clang-format off
// __PLATFORMIO_BUILD_DEBUG__ adds '-dbg', CATS_DEBUG adds '-dev'
// __PLATFORMIO_BUILD_DEBUG__ adds '-dbg', CATS_DEV adds '-dev'
#ifdef __PLATFORMIO_BUILD_DEBUG__
#ifdef CATS_DEBUG
#ifdef CATS_DEV
inline constexpr const char* code_version = FIRMWARE_VERSION "-dbg-dev";
#else
inline constexpr const char* code_version = FIRMWARE_VERSION "-dbg";
#endif
#else
#ifdef CATS_DEBUG
#ifdef CATS_DEV
inline constexpr const char* code_version = FIRMWARE_VERSION "-dev";
#else
inline constexpr const char* code_version = FIRMWARE_VERSION;
Expand Down
2 changes: 1 addition & 1 deletion flight_computer/src/util/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

constexpr uint16_t STACK_OVERFLOW_PRINT_BUF_SZ = 100;

#ifdef CATS_DEBUG
#ifdef CATS_DEV
/**
* This function is called when a stack overflow is detected by FreeRTOS. The CATS implementation of this function just
* prints the name of the task which generated the overflow via USB (if available) and blinks the red LED.
Expand Down
22 changes: 11 additions & 11 deletions flight_computer/src/util/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "comm/stream_group.hpp"
#include "util/log.h"

#ifdef CATS_DEBUG
#ifdef CATS_DEV
#include "cmsis_os.h"

#define CATS_RAINBOW_LOG
Expand All @@ -30,12 +30,12 @@ static char print_buffer[PRINT_BUFFER_LEN];
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)

void log_set_mode(log_mode_e mode) {
#ifdef CATS_DEBUG
#ifdef CATS_DEV
L.log_mode = mode;
#endif
}
log_mode_e log_get_mode() {
#ifdef CATS_DEBUG
#ifdef CATS_DEV
return L.log_mode;
#else
return LOG_MODE_NONE;
Expand All @@ -44,33 +44,33 @@ log_mode_e log_get_mode() {

// Only has impact on LOG_MODE_DEFAULT
void log_set_level(int level) {
#ifdef CATS_DEBUG
#ifdef CATS_DEV
L.level = level;
#endif
}

void log_enable() {
#ifdef CATS_DEBUG
#ifdef CATS_DEV
L.log_mode = LOG_MODE_DEFAULT;
#endif
}

void log_disable() {
#ifdef CATS_DEBUG
#ifdef CATS_DEV
L.log_mode = LOG_MODE_NONE;
#endif
}

bool log_is_enabled() {
#ifdef CATS_DEBUG
#ifdef CATS_DEV
return L.log_mode == LOG_MODE_DEFAULT;
#else
return false;
#endif
}

void log_log(int level, const char *file, int line, const char *format, ...) {
#ifdef CATS_DEBUG
#ifdef CATS_DEV
if ((L.log_mode == LOG_MODE_DEFAULT) && level >= L.level) {
/* fill buffer with metadata */
static char buf_ts[16];
Expand All @@ -96,7 +96,7 @@ void log_log(int level, const char *file, int line, const char *format, ...) {
}

void log_raw(const char *format, ...) {
#ifdef CATS_DEBUG
#ifdef CATS_DEV
va_list argptr;
va_start(argptr, format);
int len = vsnprintf(print_buffer, PRINT_BUFFER_LEN, format, argptr);
Expand All @@ -108,7 +108,7 @@ void log_raw(const char *format, ...) {
}

void log_sim(const char *format, ...) {
#ifdef CATS_DEBUG
#ifdef CATS_DEV
if (L.log_mode == LOG_MODE_SIM) {
va_list argptr;
va_start(argptr, format);
Expand All @@ -122,7 +122,7 @@ void log_sim(const char *format, ...) {
}

void log_rawr(const char *format, ...) {
#ifdef CATS_DEBUG
#ifdef CATS_DEV
va_list argptr;
va_start(argptr, format);
const int len = vsnprintf(print_buffer, PRINT_BUFFER_LEN, format, argptr);
Expand Down
2 changes: 1 addition & 1 deletion flight_computer/src/util/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void log_rawr(const char *format, ...) __attribute__((format(printf, 1, 2)));
}
#endif

#ifdef CATS_DEBUG
#ifdef CATS_DEV

#if defined(_WIN32)
#define PATH_SEPARATOR '\\'
Expand Down

0 comments on commit f2ac84d

Please sign in to comment.