|
Mod Library
Sun Devil Rocketry's hardware agnostic utility library
|
: Interfaces for debugging SDR embedded firmware. More...
#include <stdbool.h>#include <stdio.h>#include "main.h"Go to the source code of this file.
Classes | |
| struct | _DEBUG_HANDLE |
Macros | |
| #define | DEBUG_INTF_BUF_SIZE 2048 |
| #define | DEBUG_MSG_PREAMBLE_MAX_LEN 22 |
| #define | DEBUG_MSG_MAX_LEN 128 |
| #define | DEBUG_MSG_USER_MAX_LEN (DEBUG_MSG_MAX_LEN - DEBUG_MSG_PREAMBLE_MAX_LEN) |
| #define | debug_assert(condition, error) |
| Call error_fail_fast in debug builds when the condition is false, and ignore otherwise. | |
| #define | debug_log_assert(condition, msg, level) |
| Log a message in debug builds when the condition is false, and ignore otherwise. | |
| #define | debug_log_msg(msg, level) |
| Log a message in debug builds, and ignore otherwise. | |
| #define | debug_ignore_emulator_warnings_start() |
| Ignore certain emulator-only cross-architecture compiler warnings. Must pair with the stop macro. | |
| #define | debug_ignore_emulator_warnings_stop() |
| Ignore certain emulator-only cross-architecture compiler warnings. Must come after the start macro. | |
Typedefs | |
| typedef void(*) | debug_write_callback(void *, size_t) |
| typedef void(*) | overflow_callback(const char *, size_t) |
| typedef struct _DEBUG_HANDLE | DEBUG_HANDLE |
| typedef enum _DEBUG_STATUS | DEBUG_STATUS |
| typedef enum _DEBUG_LEVEL | DEBUG_LEVEL |
Enumerations | |
| enum | _DEBUG_STATUS { DEBUG_OK = 0 , DEBUG_FAIL , DEBUG_OVERFLOW } |
| enum | _DEBUG_LEVEL { LOG_LVL_INFO , LOG_LVL_WARN , LOG_LVL_ERROR } |
Functions | |
| DEBUG_STATUS | debug_init (debug_write_callback write_function, overflow_callback overflow_function) |
| Initializes the debug module. | |
| void | debug_clear (void) |
| Reset the circular buffer. | |
| DEBUG_STATUS | debug_log (const char *message, size_t len, DEBUG_LEVEL log_level) |
| Add to the debug buffer. | |
| void | debug_callback_handler (void) |
| The function to call after a write completes. | |
: Interfaces for debugging SDR embedded firmware.
Copyright (c) 2026 Sun Devil Rocketry. All rights reserved.
This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is covered under the
BSD-3-Clause.
https://opensource.org/license/bsd-3-clause
==============================================================================
##### Debug module features #####
==============================================================================
[..]
(+) Write to a logging interface
******************************************************************************
| #define debug_assert | ( | condition, | |
| error ) |
Call error_fail_fast in debug builds when the condition is false, and ignore otherwise.
| condition | A predicate that evaluates to TRUE or FALSE. |
| error | The error code to log. |
| #define debug_ignore_emulator_warnings_start | ( | ) |
Ignore certain emulator-only cross-architecture compiler warnings. Must pair with the stop macro.
| msg | The message to log. |
| level | The severity of the message to log. |
| #define debug_ignore_emulator_warnings_stop | ( | ) |
Ignore certain emulator-only cross-architecture compiler warnings. Must come after the start macro.
| msg | The message to log. |
| level | The severity of the message to log. |
| #define debug_log_assert | ( | condition, | |
| msg, | |||
| level ) |
Log a message in debug builds when the condition is false, and ignore otherwise.
| condition | A predicate that evaluates to TRUE or FALSE. |
| msg | The message to log. |
| level | The severity of the message to log. |
| #define debug_log_msg | ( | msg, | |
| level ) |
Log a message in debug builds, and ignore otherwise.
| msg | The message to log. |
| level | The severity of the message to log. |
| DEBUG_STATUS debug_init | ( | debug_write_callback | write_function, |
| overflow_callback | overflow_function ) |
Initializes the debug module.
This function should be called before any other in the debug module, as it initializes pointers and buffers to their correct values.
| write_function | Callback to the function that writes over the debug interface. |
| overflow_function | Callback to the function that handles the buffer running out of space. |
Pass (void*)NULL as the overflow callback if you want to use the default overflow handler.
| DEBUG_STATUS debug_log | ( | const char * | message, |
| size_t | len, | ||
| DEBUG_LEVEL | log_level ) |
Add to the debug buffer.
| message | A C-string with the message you want to send. |
| len | The length of the message you want to send. |
| log_level | The severity of the debug message. |