Implementation of diagnostics and utility functions for memory, stack, and lwIP state. More...
#include "framework_config.h"
#include "DebugTrace.h"
#include "utility/utility.h"
#include "FreeRTOS.h"
#include "task.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <sstream>
#include "pico/stdlib.h"
#include <lwip/memp.h>
#include <lwip/stats.h>
#include <lwip/pbuf.h>
#include <lwip/sockets.h>
#include <lwip/ip_addr.h>
#include "RP2040.h"
Go to the source code of this file.
Functions | |
void | printTaskStackSizes () |
void | logSystemStats () |
void | printHeapInfo () |
void | printSystemMemoryInfo () |
std::string | toLower (std::string str) |
void | runTimeStats () |
void | printActivePCBs () |
void | printTCPState () |
void | printMemsize () |
int | is_in_interrupt (void) |
void | debug_print (const char *msg) |
void | debug_print (const std::string &msg) |
void | debug_print (const char *msg, size_t len) |
void | warning (const std::string &msg) |
void | warning (const std::string &msg, int32_t code) |
void | rebootSystem () |
Reboot the device immediately. | |
Provides runtime tools for embedded system visibility including FreeRTOS and lwIP stats, memory usage, and debug trace control.
Definition in file utility.cpp.
void debug_print | ( | const char * | msg | ) |
Print in a mode that can be used in an ISR context.
Print in a mode that can be used in an ISR context.
Definition at line 184 of file utility.cpp.
Referenced by EventManager::enqueue().
void debug_print | ( | const char * | msg, |
size_t | len | ||
) |
Definition at line 203 of file utility.cpp.
void debug_print | ( | const std::string & | msg | ) |
Definition at line 195 of file utility.cpp.
int is_in_interrupt | ( | void | ) |
Check whether currently in interrupt context.
Check whether currently in interrupt context.
Definition at line 172 of file utility.cpp.
Referenced by EventManager::enqueue(), and EventManager::postNotification().
void logSystemStats | ( | ) |
Print FreeRTOS heap and task stack status.
Print FreeRTOS heap and task stack status.
Definition at line 65 of file utility.cpp.
void printActivePCBs | ( | ) |
Print number of active lwIP TCP PCBs.
Print number of active lwIP TCP PCBs.
Definition at line 142 of file utility.cpp.
References TRACE.
void printHeapInfo | ( | ) |
Print heap size and minimum ever free heap.
Print heap size and minimum ever free heap.
Definition at line 78 of file utility.cpp.
References TRACE.
Referenced by printSystemMemoryInfo().
void printMemsize | ( | ) |
Print lwIP memory pool statistics.
Print lwIP memory pool statistics.
Definition at line 165 of file utility.cpp.
void printSystemMemoryInfo | ( | ) |
Print stack and heap usage together.
Print stack and heap usage together.
Definition at line 86 of file utility.cpp.
References printHeapInfo(), and printTaskStackSizes().
void printTaskStackSizes | ( | ) |
Print stack high watermark for all FreeRTOS tasks.
Print stack high watermark for all FreeRTOS tasks.
Definition at line 39 of file utility.cpp.
References TRACE.
Referenced by printSystemMemoryInfo().
void printTCPState | ( | ) |
Print full lwIP statistics if available.
Print full lwIP statistics if available.
Definition at line 152 of file utility.cpp.
References TRACE.
void rebootSystem | ( | ) |
This function performs a clean system reboot using the appropriate method for the platform (RP2040 or RP2350). Intended for controlled resets, such as after persistent failures or user-initiated reboots.
Definition at line 237 of file utility.cpp.
Referenced by FrameworkManager::poll().
void runTimeStats | ( | ) |
Display task priorities, stack usage, and heap stats.
Display task priorities, stack usage, and heap stats.
Definition at line 102 of file utility.cpp.
References TRACE.
std::string toLower | ( | std::string | str | ) |
Convert string to lowercase.
Convert string to lowercase.
Definition at line 93 of file utility.cpp.
Referenced by HttpRequest::getHeader(), and HttpParser::isChunkedEncoding().
void warning | ( | const std::string & | msg | ) |
Definition at line 215 of file utility.cpp.
Referenced by HttpServer::run(), and Tcp::send().
void warning | ( | const std::string & | msg, |
int32_t | code | ||
) |
Definition at line 223 of file utility.cpp.