A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
add stack infos methods for system servicer
Geoac1ce807183e
diff --git a/src/Services/SystemService.cpp b/src/Services/SystemService.cppindex a4bdcd3b..1bba3a87 100644--- a/src/Services/SystemService.cpp+++ b/src/Services/SystemService.cpp@@ -114,9 +114,47 @@ std::string SystemService::getArduinoCore() const}// ------------------------------// Heap / PSRAM+// Stack / Heap / PSRAM// -----------------------------+size_t SystemService::getStackUsed() const {+ TaskHandle_t h = xTaskGetCurrentTaskHandle();+ size_t usedNow = 0;++ // Get snapshot of tasks+ TaskSnapshot_t snaps[16];+ UBaseType_t count = 0;+ UBaseType_t got = uxTaskGetSnapshotAll(snaps, 16, &count);+ if (got == 0) {+ return -1;+ }++ // Find the snapshot of the current task+ const TaskSnapshot_t* self = nullptr;+ for (UBaseType_t i = 0; i < got; ++i) {+ if (snaps[i].pxTCB == h) {+ self = &snaps[i];+ break;+ }+ }+ if (!self) {+ return -1;+ }++ uintptr_t top = reinterpret_cast<uintptr_t>(self->pxTopOfStack);+ uintptr_t end = reinterpret_cast<uintptr_t>(self->pxEndOfStack);+ if (top == 0 || end == 0 || end <= top) {+ return -1;+ }++ usedNow = end - top;+ return usedNow;+}++size_t SystemService::getStackTotal() const {+ return CONFIG_ARDUINO_LOOP_STACK_SIZE;+}+size_t SystemService::getHeapTotal() const{return ESP.getHeapSize();diff --git a/src/Services/SystemService.h b/src/Services/SystemService.hindex 9c143ecc..1e349034 100644--- a/src/Services/SystemService.h+++ b/src/Services/SystemService.h@@ -18,7 +18,9 @@ public:std::string getIdfVersion() const;std::string getArduinoCore() const;- // Heap / PSRAM+ // Stack / Heap / PSRAM+ size_t getStackUsed() const;+ size_t getStackTotal() const;size_t getHeapTotal() const;size_t getHeapFree() const;size_t getHeapMinFree() const;