Red Bird Racing VCU v2
 
Loading...
Searching...
No Matches
Debug.hpp
Go to the documentation of this file.
1/**
2 * @file Debug.hpp
3 * @author Planeson, Chiho, Red Bird Racing
4 * @brief Debugging macros and functions for serial and CAN output
5 * @version 2.0
6 * @date 2026-02-25
7 * @see Debug_serial, Debug_can
8 * @dir Debug @brief The Debug library contains debugging macros and functions for serial and CAN output, allowing for easy toggling of debug messages and separation of concerns between different types of debug information.
9 */
10
11#ifndef DEBUG_HPP
12#define DEBUG_HPP
13
14#include "Enums.hpp"
15
16// ignore -Wpedantic warnings for mcp2515.h
17#pragma GCC diagnostic push
18#pragma GCC diagnostic ignored "-Wpedantic"
19#include <mcp2515.h>
20#pragma GCC diagnostic pop
21
22// === Debug Flags ===
23#define DEBUG 0 // if 0, all debug messages are ignored
24#define DEBUG_SERIAL (1 && DEBUG) // if 0, all serial debug messages are ignored
25#define DEBUG_CAN (1 && DEBUG) // if 0, all CAN debug messages are ignored
26
27#if DEBUG_SERIAL
28#include <Debug_serial.hpp>
29#endif
30
31#if DEBUG_CAN
32#include <Debug_can.hpp>
33#endif
34
35#define DEBUG_GENERAL 1
36
37// ===== Debug Macros for Serial Output =====
38
39/**
40 * @brief Prints a general debug message to the serial console.
41 * @param x The message to print.
42 * @note Serial exclusive
43 */
44inline void DBG_GENERAL(const char *x)
45{
46#if DEBUG_GENERAL && DEBUG_SERIAL
48#endif
49}
50
51/**
52 * @brief Prints a line to the serial console for general debug.
53 * @param x The message to print.
54 * @note Serial exclusive
55 */
56inline void DBGLN_GENERAL(const char *x)
57{
58#if DEBUG_GENERAL && DEBUG_SERIAL
60#endif
61}
62
63
64
65/**
66 * @brief Sends arbitrary debug data via CAN with specified message ID and data bytes.
67 * @param id CAN message ID
68 * @param data0 Byte 0 of CAN data (default 0x00)
69 * @param data1 Byte 1 of CAN data (default 0x00)
70 * @param data2 Byte 2 of CAN data (default 0x00)
71 * @param data3 Byte 3 of CAN data (default 0x00)
72 * @param data4 Byte 4 of CAN data (default 0x00)
73 * @param data5 Byte 5 of CAN data (default 0x00)
74 * @param data6 Byte 6 of CAN data (default 0x00)
75 * @param data7 Byte 7 of CAN data (default 0x00)
76 * @note CAN exclusive
77 */
78inline void DBG_GENERAL_CAN(canid_t id, uint8_t data0 = 0x00, uint8_t data1 = 0x00,
79 uint8_t data2 = 0x00,
80 uint8_t data3 = 0x00,
81 uint8_t data4 = 0x00,
82 uint8_t data5 = 0x00,
83 uint8_t data6 = 0x00,
84 uint8_t data7 = 0x00)
85{
86#if DEBUG && DEBUG_CAN
87 Debug_CAN::send_message(id, data0, data1, data2, data3, data4, data5, data6, data7);
88#endif
89}
90
91#endif // DEBUG_HPP
void DBG_GENERAL_CAN(canid_t id, uint8_t data0=0x00, uint8_t data1=0x00, uint8_t data2=0x00, uint8_t data3=0x00, uint8_t data4=0x00, uint8_t data5=0x00, uint8_t data6=0x00, uint8_t data7=0x00)
Sends arbitrary debug data via CAN with specified message ID and data bytes.
Definition: Debug.hpp:78
void DBGLN_GENERAL(const char *x)
Prints a line to the serial console for general debug.
Definition: Debug.hpp:56
void DBG_GENERAL(const char *x)
Prints a general debug message to the serial console.
Definition: Debug.hpp:44
Declaration of the Debug_CAN namespace for CAN debugging functions.
Declaration of the Debug_Serial namespace for serial debugging functions.
Enumeration definitions for the VCU.
void send_message(canid_t id, uint8_t data0=0x00, uint8_t data1=0x00, uint8_t data2=0x00, uint8_t data3=0x00, uint8_t data4=0x00, uint8_t data5=0x00, uint8_t data6=0x00, uint8_t data7=0x00)
Sends arbitrary debug data via CAN with specified message ID and data bytes.
Definition: Debug_can.cpp:46
void println(const char *msg)
Prints a string AND a newline to the serial console.
void print(const char *msg)
Prints a string to the serial console.