mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 04:26:58 +03:00
Refactor getEspHeapInfo routine (#1816)
* Refactor getEspHeapInfo * ClassLogfile: Remove redundandent one
This commit is contained in:
@@ -39,52 +39,59 @@ unsigned int systemStatus = 0;
|
|||||||
sdmmc_cid_t SDCardCid;
|
sdmmc_cid_t SDCardCid;
|
||||||
sdmmc_csd_t SDCardCsd;
|
sdmmc_csd_t SDCardCsd;
|
||||||
|
|
||||||
|
|
||||||
|
// #define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
string getESPHeapInfo(){
|
string getESPHeapInfo(){
|
||||||
string espInfoResultStr = "";
|
string espInfoResultStr = "";
|
||||||
char aMsgBuf[80];
|
char aMsgBuf[80];
|
||||||
|
|
||||||
multi_heap_info_t aMultiHead_info ;
|
|
||||||
heap_caps_get_info (&aMultiHead_info,MALLOC_CAP_8BIT);
|
|
||||||
size_t aFreeHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
size_t aFreeHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
size_t aMinFreeHeadSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT);
|
|
||||||
size_t aMinFreeHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT);
|
|
||||||
size_t aHeapLargestFreeBlockSize = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT);
|
|
||||||
sprintf(aMsgBuf," Free Heap Size: %ld", (long) aFreeHeapSize);
|
|
||||||
size_t aFreeSPIHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_SPIRAM);
|
|
||||||
size_t aFreeInternalHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_INTERNAL);
|
|
||||||
size_t aMinFreeInternalHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_INTERNAL);
|
|
||||||
|
|
||||||
sprintf(aMsgBuf," Heap: %ld", (long) aFreeHeapSize);
|
size_t aFreeSPIHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
|
||||||
|
size_t aFreeInternalHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
|
||||||
|
|
||||||
|
size_t aHeapLargestFreeBlockSize = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
|
||||||
|
size_t aHeapIntLargestFreeBlockSize = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
|
||||||
|
|
||||||
|
size_t aMinFreeHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
|
||||||
|
size_t aMinFreeInternalHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
|
||||||
|
|
||||||
|
|
||||||
|
sprintf(aMsgBuf,"Heap Total: %ld", (long) aFreeHeapSize);
|
||||||
espInfoResultStr += string(aMsgBuf);
|
espInfoResultStr += string(aMsgBuf);
|
||||||
sprintf(aMsgBuf," Min Free: %ld", (long) aMinFreeHeapSize);
|
|
||||||
|
sprintf(aMsgBuf," | SPI Free: %ld", (long) aFreeSPIHeapSize);
|
||||||
espInfoResultStr += string(aMsgBuf);
|
espInfoResultStr += string(aMsgBuf);
|
||||||
sprintf(aMsgBuf," larg. Block: %ld", (long) aHeapLargestFreeBlockSize);
|
sprintf(aMsgBuf," | SPI Larg Block: %ld", (long) aHeapLargestFreeBlockSize);
|
||||||
espInfoResultStr += string(aMsgBuf);
|
espInfoResultStr += string(aMsgBuf);
|
||||||
sprintf(aMsgBuf," SPI Heap: %ld", (long) aFreeSPIHeapSize);
|
sprintf(aMsgBuf," | SPI Min Free: %ld", (long) aMinFreeHeapSize);
|
||||||
espInfoResultStr += string(aMsgBuf);
|
espInfoResultStr += string(aMsgBuf);
|
||||||
sprintf(aMsgBuf," Min Free Heap Size: %ld", (long) aMinFreeHeadSize);
|
|
||||||
sprintf(aMsgBuf," NOT_SPI Heap: %ld", (long) (aFreeHeapSize - aFreeSPIHeapSize));
|
sprintf(aMsgBuf," | Int Free: %ld", (long) (aFreeInternalHeapSize));
|
||||||
espInfoResultStr += string(aMsgBuf);
|
espInfoResultStr += string(aMsgBuf);
|
||||||
sprintf(aMsgBuf," largest Block Size: %ld", (long) aHeapLargestFreeBlockSize);
|
sprintf(aMsgBuf," | Int Larg Block: %ld", (long) aHeapIntLargestFreeBlockSize);
|
||||||
sprintf(aMsgBuf," Internal Heap: %ld", (long) (aFreeInternalHeapSize));
|
|
||||||
espInfoResultStr += string(aMsgBuf);
|
espInfoResultStr += string(aMsgBuf);
|
||||||
sprintf(aMsgBuf," Internal Min Heap free: %ld", (long) (aMinFreeInternalHeapSize));
|
sprintf(aMsgBuf," | Int Min Free: %ld", (long) (aMinFreeInternalHeapSize));
|
||||||
espInfoResultStr += string(aMsgBuf);
|
espInfoResultStr += string(aMsgBuf);
|
||||||
|
|
||||||
return espInfoResultStr;
|
return espInfoResultStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t getESPHeapSize(){
|
size_t getESPHeapSize()
|
||||||
size_t aFreeHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
{
|
||||||
return aFreeHeapSize;
|
return heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getInternalESPHeapSize() {
|
|
||||||
size_t aFreeInternalHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_INTERNAL);
|
size_t getInternalESPHeapSize()
|
||||||
return aFreeInternalHeapSize;
|
{
|
||||||
|
return heap_caps_get_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string getSDCardPartitionSize(){
|
string getSDCardPartitionSize(){
|
||||||
FATFS *fs;
|
FATFS *fs;
|
||||||
uint32_t fre_clust, tot_sect;
|
uint32_t fre_clust, tot_sect;
|
||||||
@@ -98,6 +105,7 @@ string getSDCardPartitionSize(){
|
|||||||
return std::to_string(tot_sect);
|
return std::to_string(tot_sect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string getSDCardFreePartitionSpace(){
|
string getSDCardFreePartitionSpace(){
|
||||||
FATFS *fs;
|
FATFS *fs;
|
||||||
uint32_t fre_clust, fre_sect;
|
uint32_t fre_clust, fre_sect;
|
||||||
@@ -111,6 +119,7 @@ string getSDCardFreePartitionSpace(){
|
|||||||
return std::to_string(fre_sect);
|
return std::to_string(fre_sect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string getSDCardPartitionAllocationSize(){
|
string getSDCardPartitionAllocationSize(){
|
||||||
FATFS *fs;
|
FATFS *fs;
|
||||||
uint32_t fre_clust, allocation_size;
|
uint32_t fre_clust, allocation_size;
|
||||||
@@ -130,6 +139,7 @@ void SaveSDCardInfo(sdmmc_card_t* card) {
|
|||||||
SDCardCsd = card->csd;
|
SDCardCsd = card->csd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string getSDCardManufacturer(){
|
string getSDCardManufacturer(){
|
||||||
string SDCardManufacturer = SDCardParseManufacturerIDs(SDCardCid.mfg_id);
|
string SDCardManufacturer = SDCardParseManufacturerIDs(SDCardCid.mfg_id);
|
||||||
//ESP_LOGD(TAG, "SD Card Manufacturer: %s", SDCardManufacturer.c_str());
|
//ESP_LOGD(TAG, "SD Card Manufacturer: %s", SDCardManufacturer.c_str());
|
||||||
@@ -137,6 +147,7 @@ string getSDCardManufacturer(){
|
|||||||
return (SDCardManufacturer + " (ID: " + std::to_string(SDCardCid.mfg_id) + ")");
|
return (SDCardManufacturer + " (ID: " + std::to_string(SDCardCid.mfg_id) + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string getSDCardName(){
|
string getSDCardName(){
|
||||||
char *SDCardName = SDCardCid.name;
|
char *SDCardName = SDCardCid.name;
|
||||||
//ESP_LOGD(TAG, "SD Card Name: %s", SDCardName);
|
//ESP_LOGD(TAG, "SD Card Name: %s", SDCardName);
|
||||||
@@ -144,6 +155,7 @@ string getSDCardName(){
|
|||||||
return std::string(SDCardName);
|
return std::string(SDCardName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string getSDCardCapacity(){
|
string getSDCardCapacity(){
|
||||||
int SDCardCapacity = SDCardCsd.capacity / (1024/SDCardCsd.sector_size) / 1024; // total sectors * sector size --> Byte to MB (1024*1024)
|
int SDCardCapacity = SDCardCsd.capacity / (1024/SDCardCsd.sector_size) / 1024; // total sectors * sector size --> Byte to MB (1024*1024)
|
||||||
//ESP_LOGD(TAG, "SD Card Capacity: %s", std::to_string(SDCardCapacity).c_str());
|
//ESP_LOGD(TAG, "SD Card Capacity: %s", std::to_string(SDCardCapacity).c_str());
|
||||||
@@ -151,6 +163,7 @@ string getSDCardCapacity(){
|
|||||||
return std::to_string(SDCardCapacity);
|
return std::to_string(SDCardCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string getSDCardSectorSize(){
|
string getSDCardSectorSize(){
|
||||||
int SDCardSectorSize = SDCardCsd.sector_size;
|
int SDCardSectorSize = SDCardCsd.sector_size;
|
||||||
//ESP_LOGD(TAG, "SD Card Sector Size: %s bytes", std::to_string(SDCardSectorSize).c_str());
|
//ESP_LOGD(TAG, "SD Card Sector Size: %s bytes", std::to_string(SDCardSectorSize).c_str());
|
||||||
@@ -210,6 +223,7 @@ void FindReplace(std::string& line, std::string& oldString, std::string& newStri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MakeDir(std::string _what)
|
bool MakeDir(std::string _what)
|
||||||
{
|
{
|
||||||
int mk_ret = mkdir(_what.c_str(), 0775);
|
int mk_ret = mkdir(_what.c_str(), 0775);
|
||||||
@@ -222,7 +236,6 @@ bool MakeDir(std::string _what)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ctype_space(const char c, string adddelimiter)
|
bool ctype_space(const char c, string adddelimiter)
|
||||||
{
|
{
|
||||||
if (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == 11)
|
if (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == 11)
|
||||||
@@ -235,6 +248,7 @@ bool ctype_space(const char c, string adddelimiter)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string trim(string istring, string adddelimiter)
|
string trim(string istring, string adddelimiter)
|
||||||
{
|
{
|
||||||
bool trimmed = false;
|
bool trimmed = false;
|
||||||
@@ -261,6 +275,7 @@ string trim(string istring, string adddelimiter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t findDelimiterPos(string input, string delimiter)
|
size_t findDelimiterPos(string input, string delimiter)
|
||||||
{
|
{
|
||||||
size_t pos = std::string::npos;
|
size_t pos = std::string::npos;
|
||||||
@@ -301,6 +316,7 @@ bool RenameFile(string from, string to)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FileExists(string filename)
|
bool FileExists(string filename)
|
||||||
{
|
{
|
||||||
FILE* fpSourceFile = fopen(filename.c_str(), "rb");
|
FILE* fpSourceFile = fopen(filename.c_str(), "rb");
|
||||||
@@ -367,6 +383,7 @@ bool CopyFile(string input, string output)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string getFileFullFileName(string filename)
|
string getFileFullFileName(string filename)
|
||||||
{
|
{
|
||||||
size_t lastpos = filename.find_last_of('/');
|
size_t lastpos = filename.find_last_of('/');
|
||||||
@@ -381,6 +398,7 @@ string getFileFullFileName(string filename)
|
|||||||
return zw;
|
return zw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string getDirectory(string filename)
|
string getDirectory(string filename)
|
||||||
{
|
{
|
||||||
size_t lastpos = filename.find('/');
|
size_t lastpos = filename.find('/');
|
||||||
@@ -397,6 +415,7 @@ string getDirectory(string filename)
|
|||||||
return zw;
|
return zw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string getFileType(string filename)
|
string getFileType(string filename)
|
||||||
{
|
{
|
||||||
size_t lastpos = filename.rfind(".", filename.length());
|
size_t lastpos = filename.rfind(".", filename.length());
|
||||||
@@ -415,6 +434,7 @@ string getFileType(string filename)
|
|||||||
return zw;
|
return zw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* recursive mkdir */
|
/* recursive mkdir */
|
||||||
int mkdir_r(const char *dir, const mode_t mode) {
|
int mkdir_r(const char *dir, const mode_t mode) {
|
||||||
char tmp[FILE_PATH_MAX];
|
char tmp[FILE_PATH_MAX];
|
||||||
@@ -472,6 +492,7 @@ int mkdir_r(const char *dir, const mode_t mode) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string toUpper(string in)
|
string toUpper(string in)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < in.length(); ++i)
|
for (int i = 0; i < in.length(); ++i)
|
||||||
@@ -480,6 +501,7 @@ string toUpper(string in)
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string toLower(string in)
|
string toLower(string in)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < in.length(); ++i)
|
for (int i = 0; i < in.length(); ++i)
|
||||||
@@ -488,6 +510,7 @@ string toLower(string in)
|
|||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// CPU Temp
|
// CPU Temp
|
||||||
extern "C" uint8_t temprature_sens_read();
|
extern "C" uint8_t temprature_sens_read();
|
||||||
float temperatureRead()
|
float temperatureRead()
|
||||||
@@ -495,12 +518,14 @@ float temperatureRead()
|
|||||||
return (temprature_sens_read() - 32) / 1.8;
|
return (temprature_sens_read() - 32) / 1.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
time_t addDays(time_t startTime, int days) {
|
time_t addDays(time_t startTime, int days) {
|
||||||
struct tm* tm = localtime(&startTime);
|
struct tm* tm = localtime(&startTime);
|
||||||
tm->tm_mday += days;
|
tm->tm_mday += days;
|
||||||
return mktime(tm);
|
return mktime(tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int removeFolder(const char* folderPath, const char* logTag) {
|
int removeFolder(const char* folderPath, const char* logTag) {
|
||||||
//ESP_LOGD(logTag, "Delete content in path %s", folderPath);
|
//ESP_LOGD(logTag, "Delete content in path %s", folderPath);
|
||||||
|
|
||||||
@@ -548,7 +573,6 @@ std::vector<string> HelperZerlegeZeile(std::string input, std::string _delimiter
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<string> ZerlegeZeile(std::string input, std::string delimiter)
|
std::vector<string> ZerlegeZeile(std::string input, std::string delimiter)
|
||||||
{
|
{
|
||||||
std::vector<string> Output;
|
std::vector<string> Output;
|
||||||
@@ -612,6 +636,7 @@ struct SDCard_Manufacturer_database {
|
|||||||
string manufacturer;
|
string manufacturer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Source: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/tree/lsmmc.c */
|
/* Source: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/tree/lsmmc.c */
|
||||||
/* SD Card Manufacturer Database */
|
/* SD Card Manufacturer Database */
|
||||||
struct SDCard_Manufacturer_database database[] = {
|
struct SDCard_Manufacturer_database database[] = {
|
||||||
@@ -722,6 +747,7 @@ struct SDCard_Manufacturer_database database[] = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Parse SD Card Manufacturer Database */
|
/* Parse SD Card Manufacturer Database */
|
||||||
string SDCardParseManufacturerIDs(int id)
|
string SDCardParseManufacturerIDs(int id)
|
||||||
{
|
{
|
||||||
@@ -784,6 +810,7 @@ void setSystemStatusFlag(SystemStatusFlag_t flag) {
|
|||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "New System Status: " + std::string(buf));
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "New System Status: " + std::string(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void clearSystemStatusFlag(SystemStatusFlag_t flag) {
|
void clearSystemStatusFlag(SystemStatusFlag_t flag) {
|
||||||
systemStatus = systemStatus | ~flag; // clear bit
|
systemStatus = systemStatus | ~flag; // clear bit
|
||||||
|
|
||||||
@@ -792,10 +819,12 @@ void clearSystemStatusFlag(SystemStatusFlag_t flag) {
|
|||||||
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "New System Status: " + std::string(buf));
|
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "New System Status: " + std::string(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int getSystemStatus(void) {
|
int getSystemStatus(void) {
|
||||||
return systemStatus;
|
return systemStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool isSetSystemStatusFlag(SystemStatusFlag_t flag) {
|
bool isSetSystemStatusFlag(SystemStatusFlag_t flag) {
|
||||||
//ESP_LOGE(TAG, "Flag (0x%08X) is set (0x%08X): %d", flag, systemStatus , ((systemStatus & flag) == flag));
|
//ESP_LOGE(TAG, "Flag (0x%08X) is set (0x%08X): %d", flag, systemStatus , ((systemStatus & flag) == flag));
|
||||||
|
|
||||||
@@ -835,6 +864,7 @@ string getResetReason(void) {
|
|||||||
return reasonText;
|
return reasonText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current uptime formated ad xxf xxh xxm [xxs]
|
* Returns the current uptime formated ad xxf xxh xxm [xxs]
|
||||||
*/
|
*/
|
||||||
@@ -859,6 +889,7 @@ std::string getFormatedUptime(bool compact) {
|
|||||||
return std::string(buf);
|
return std::string(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* get404(void) {
|
const char* get404(void) {
|
||||||
return
|
return
|
||||||
"<pre>\n\n\n\n"
|
"<pre>\n\n\n\n"
|
||||||
|
|||||||
@@ -21,50 +21,16 @@ static const char *TAG = "LOGFILE";
|
|||||||
|
|
||||||
ClassLogFile LogFile("/sdcard/log/message", "log_%Y-%m-%d.txt", "/sdcard/log/data", "data_%Y-%m-%d.csv");
|
ClassLogFile LogFile("/sdcard/log/message", "log_%Y-%m-%d.txt", "/sdcard/log/data", "data_%Y-%m-%d.csv");
|
||||||
|
|
||||||
|
|
||||||
void ClassLogFile::WriteHeapInfo(std::string _id)
|
void ClassLogFile::WriteHeapInfo(std::string _id)
|
||||||
{
|
{
|
||||||
std::string _zw = _id;
|
|
||||||
if (loglevel >= ESP_LOG_DEBUG) {
|
if (loglevel >= ESP_LOG_DEBUG) {
|
||||||
_zw = _zw + "\t" + getESPHeapInfo();
|
std::string _zw = _id + "\t" + getESPHeapInfo();
|
||||||
WriteToFile(ESP_LOG_DEBUG, "HEAP", _zw);
|
WriteToFile(ESP_LOG_DEBUG, "HEAP", _zw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string ClassLogFile::getESPHeapInfo(){
|
|
||||||
string espInfoResultStr = "";
|
|
||||||
char aMsgBuf[80];
|
|
||||||
|
|
||||||
multi_heap_info_t aMultiHead_info ;
|
|
||||||
heap_caps_get_info (&aMultiHead_info,MALLOC_CAP_8BIT);
|
|
||||||
size_t aFreeHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
|
||||||
size_t aMinFreeHeadSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT);
|
|
||||||
size_t aMinFreeHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT);
|
|
||||||
size_t aHeapLargestFreeBlockSize = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT);
|
|
||||||
sprintf(aMsgBuf,"Free Heap Size: \t%ld", (long) aFreeHeapSize);
|
|
||||||
size_t aFreeSPIHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_SPIRAM);
|
|
||||||
size_t aFreeInternalHeapSize = heap_caps_get_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_INTERNAL);
|
|
||||||
size_t aMinFreeInternalHeapSize = heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT| MALLOC_CAP_INTERNAL);
|
|
||||||
|
|
||||||
sprintf(aMsgBuf,"\tHeap:\t%ld", (long) aFreeHeapSize);
|
|
||||||
espInfoResultStr += string(aMsgBuf);
|
|
||||||
sprintf(aMsgBuf,"\tMin Free:\t%ld", (long) aMinFreeHeapSize);
|
|
||||||
espInfoResultStr += string(aMsgBuf);
|
|
||||||
sprintf(aMsgBuf,"\tlarg. Block: \t%ld", (long) aHeapLargestFreeBlockSize);
|
|
||||||
espInfoResultStr += string(aMsgBuf);
|
|
||||||
sprintf(aMsgBuf,"\tSPI Heap:\t%ld", (long) aFreeSPIHeapSize);
|
|
||||||
espInfoResultStr += string(aMsgBuf);
|
|
||||||
sprintf(aMsgBuf,"\tMin Free Heap Size:\t%ld", (long) aMinFreeHeadSize);
|
|
||||||
sprintf(aMsgBuf,"\tNOT_SPI Heap:\t%ld", (long) (aFreeHeapSize - aFreeSPIHeapSize));
|
|
||||||
espInfoResultStr += string(aMsgBuf);
|
|
||||||
sprintf(aMsgBuf,"\tlargest Block Size: \t%ld", (long) aHeapLargestFreeBlockSize);
|
|
||||||
sprintf(aMsgBuf,"\tInternal Heap:\t%ld", (long) (aFreeInternalHeapSize));
|
|
||||||
espInfoResultStr += string(aMsgBuf);
|
|
||||||
sprintf(aMsgBuf,"\tInternal Min Heap free:\t%ld", (long) (aMinFreeInternalHeapSize));
|
|
||||||
espInfoResultStr += string(aMsgBuf);
|
|
||||||
return espInfoResultStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClassLogFile::WriteToData(std::string _timestamp, std::string _name, std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ReturnRateValue, std::string _ReturnChangeAbsolute, std::string _ErrorMessageText, std::string _digital, std::string _analog)
|
void ClassLogFile::WriteToData(std::string _timestamp, std::string _name, std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ReturnRateValue, std::string _ReturnChangeAbsolute, std::string _ErrorMessageText, std::string _digital, std::string _analog)
|
||||||
{
|
{
|
||||||
ESP_LOGD(TAG, "Start WriteToData");
|
ESP_LOGD(TAG, "Start WriteToData");
|
||||||
@@ -145,26 +111,30 @@ void ClassLogFile::setLogLevel(esp_log_level_t _logLevel){
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ClassLogFile::SetLogFileRetention(unsigned short _LogFileRetentionInDays){
|
void ClassLogFile::SetLogFileRetention(unsigned short _LogFileRetentionInDays){
|
||||||
logFileRetentionInDays = _LogFileRetentionInDays;
|
logFileRetentionInDays = _LogFileRetentionInDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ClassLogFile::SetDataLogRetention(unsigned short _DataLogRetentionInDays){
|
void ClassLogFile::SetDataLogRetention(unsigned short _DataLogRetentionInDays){
|
||||||
dataLogRetentionInDays = _DataLogRetentionInDays;
|
dataLogRetentionInDays = _DataLogRetentionInDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ClassLogFile::SetDataLogToSD(bool _doDataLogToSD){
|
void ClassLogFile::SetDataLogToSD(bool _doDataLogToSD){
|
||||||
doDataLogToSD = _doDataLogToSD;
|
doDataLogToSD = _doDataLogToSD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ClassLogFile::GetDataLogToSD(){
|
bool ClassLogFile::GetDataLogToSD(){
|
||||||
return doDataLogToSD;
|
return doDataLogToSD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static FILE* logFileAppendHandle = NULL;
|
static FILE* logFileAppendHandle = NULL;
|
||||||
std::string fileNameDate;
|
std::string fileNameDate;
|
||||||
|
|
||||||
|
|
||||||
void ClassLogFile::WriteToFile(esp_log_level_t level, std::string tag, std::string message, bool _time)
|
void ClassLogFile::WriteToFile(esp_log_level_t level, std::string tag, std::string message, bool _time)
|
||||||
{
|
{
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
@@ -280,6 +250,7 @@ void ClassLogFile::WriteToFile(esp_log_level_t level, std::string tag, std::stri
|
|||||||
LogFile.WriteToFile(level, tag, message, true);
|
LogFile.WriteToFile(level, tag, message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string ClassLogFile::GetCurrentFileNameData()
|
std::string ClassLogFile::GetCurrentFileNameData()
|
||||||
{
|
{
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
@@ -311,6 +282,7 @@ std::string ClassLogFile::GetCurrentFileName()
|
|||||||
return logpath;
|
return logpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ClassLogFile::RemoveOldLogFile()
|
void ClassLogFile::RemoveOldLogFile()
|
||||||
{
|
{
|
||||||
if (logFileRetentionInDays == 0) {
|
if (logFileRetentionInDays == 0) {
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ private:
|
|||||||
public:
|
public:
|
||||||
ClassLogFile(std::string _logpath, std::string _logfile, std::string _logdatapath, std::string _datafile);
|
ClassLogFile(std::string _logpath, std::string _logfile, std::string _logdatapath, std::string _datafile);
|
||||||
|
|
||||||
std::string getESPHeapInfo();
|
|
||||||
|
|
||||||
void WriteHeapInfo(std::string _id);
|
void WriteHeapInfo(std::string _id);
|
||||||
|
|
||||||
void setLogLevel(esp_log_level_t _logLevel);
|
void setLogLevel(esp_log_level_t _logLevel);
|
||||||
|
|||||||
Reference in New Issue
Block a user