Improved Logfile, extended Logging

This commit is contained in:
jomjol
2020-12-26 09:18:16 +01:00
parent 584a73255a
commit db0ca1cb9b
18 changed files with 159 additions and 39 deletions

View File

@@ -29,26 +29,38 @@ void PowerResetCamera(){
esp_err_t handler_lightOn(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_lightOn - Start");
LogFile.WriteToFile("handler_lightOn");
printf("handler_lightOn uri:\n"); printf(req->uri); printf("\n");
Camera.LightOnOff(true);
const char* resp_str = (const char*) req->user_ctx;
httpd_resp_send(req, resp_str, strlen(resp_str));
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_lightOn - Done");
return ESP_OK;
};
esp_err_t handler_lightOff(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_lightOff - Start");
LogFile.WriteToFile("handler_lightOff");
printf("handler_lightOff uri:\n"); printf(req->uri); printf("\n");
Camera.LightOnOff(false);
const char* resp_str = (const char*) req->user_ctx;
httpd_resp_send(req, resp_str, strlen(resp_str));
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_lightOff - Done");
return ESP_OK;
};
esp_err_t handler_capture(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture - Start");
LogFile.WriteToFile("handler_capture");
int quality;
framesize_t res;
@@ -59,12 +71,17 @@ esp_err_t handler_capture(httpd_req_t *req)
esp_err_t ressult;
ressult = Camera.CaptureToHTTP(req);
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture - Done");
return ressult;
};
esp_err_t handler_capture_with_ligth(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture_with_ligth - Start");
LogFile.WriteToFile("handler_capture_with_ligth");
char _query[100];
char _delay[10];
@@ -99,6 +116,8 @@ esp_err_t handler_capture_with_ligth(httpd_req_t *req)
Camera.LightOnOff(false);
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture_with_ligth - Done");
return ressult;
};
@@ -106,6 +125,8 @@ esp_err_t handler_capture_with_ligth(httpd_req_t *req)
esp_err_t handler_capture_save_to_file(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture_save_to_file - Start");
LogFile.WriteToFile("handler_capture_save_to_file");
char _query[100];
char _delay[10];
@@ -151,6 +172,8 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req)
const char* resp_str = (const char*) fn.c_str();
httpd_resp_send(req, resp_str, strlen(resp_str));
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_capture_save_to_file - Done");
return ressult;
};

View File

@@ -13,4 +13,7 @@ void register_server_camera_uri(httpd_handle_t server);
void PowerResetCamera();
extern bool debug_detail_heap;
#endif

View File

@@ -303,6 +303,8 @@ void CheckOTAUpdate(void)
esp_err_t handler_ota_update(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_ota_update - Start");
LogFile.WriteToFile("handler_ota_update");
char _query[200];
char _filename[30];
@@ -379,6 +381,8 @@ esp_err_t handler_ota_update(httpd_req_t *req)
httpd_resp_send(req, resp_str, strlen(resp_str));
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_ota_update - Done");
return ESP_OK;
};
@@ -414,6 +418,8 @@ void doReboot(){
esp_err_t handler_reboot(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_reboot - Start");
LogFile.WriteToFile("handler_reboot");
ESP_LOGI(TAGPARTOTA, "!!! System will restart within 5 sec!!!");
const char* resp_str = "!!! System will restart within 5 sec!!!";
@@ -421,6 +427,7 @@ esp_err_t handler_reboot(httpd_req_t *req)
doReboot();
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_reboot - Done");
return ESP_OK;
}

View File

@@ -9,3 +9,5 @@ static const char *TAGPARTOTA = "server_ota";
void register_server_ota_sdcard_uri(httpd_handle_t server);
void CheckOTAUpdate();
void doReboot();
extern bool debug_detail_heap;

View File

@@ -13,8 +13,6 @@
static const char* TAG = "flow_controll";
bool flowcontrolldebugdetail = true;
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
std::string _classname = "";
@@ -202,17 +200,7 @@ bool ClassFlowControll::doFlow(string time)
/////////////////////////////////////////////////////
if (flowcontrolldebugdetail){
std::string aStartEspInfoStr = "ClassFlowAnalog::doFlow - Start: " + getESPHeapInfo();
LogFile.WriteToFile(aStartEspInfoStr);
}
if (flowcontrolldebugdetail){
std::string aStartEspInfoStr = "ClassFlowAnalog::doFlow - Now : " + getESPHeapInfo();
LogFile.WriteToFile(aStartEspInfoStr);
}
if (debug_detail_heap) LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow - Start");
/////////////////////////////////////////////////////////
for (int i = 0; i < FlowControll.size(); ++i)
@@ -220,7 +208,8 @@ bool ClassFlowControll::doFlow(string time)
zw_time = gettimestring("%Y%m%d-%H%M%S");
aktstatus = zw_time + ": " + FlowControll[i]->name();
string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
LogFile.WriteToFile(zw);
if (debug_detail_heap) LogFile.WriteHeapInfo(zw);
// LogFile.WriteToFile(zw);
if (!FlowControll[i]->doFlow(time)){
repeat++;
LogFile.WriteToFile("Fehler im vorheriger Schritt - wird zum " + to_string(repeat) + ". Mal wiederholt");
@@ -237,12 +226,7 @@ bool ClassFlowControll::doFlow(string time)
result = true;
}
if (flowcontrolldebugdetail){
std::string aStartEspInfoStr = "ClassFlowAnalog::doFlow - Now : " + getESPHeapInfo();
LogFile.WriteToFile(aStartEspInfoStr);
}
if (debug_detail_heap) LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow");
}
zw_time = gettimestring("%Y%m%d-%H%M%S");
aktstatus = zw_time + ": Flow is done";

View File

@@ -56,3 +56,5 @@ public:
string name(){return "ClassFlowControll";};
};
extern bool debug_detail_heap;

View File

@@ -10,6 +10,48 @@ static const char *TAG = "log";
ClassLogFile LogFile("/sdcard/log/message", "log_%Y-%m-%d.txt");
void ClassLogFile::WriteHeapInfo(std::string _id)
{
std::string _zw;
_zw = "\t" + _id + "\t" + getESPHeapInfo();
WriteToFile(_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::WriteToDedicatedFile(std::string _fn, std::string info, bool _time)
{
FILE* pFile;

View File

@@ -12,6 +12,10 @@ private:
public:
ClassLogFile(std::string _logpath, std::string _logfile);
std::string getESPHeapInfo();
void WriteHeapInfo(std::string _id);
void SwitchOnOff(bool _doLogFile);
void SetRetention(unsigned short _retentionInDays);

View File

@@ -24,11 +24,22 @@ TaskHandle_t xHandleblink_task_doFlow = NULL;
TaskHandle_t xHandletask_autodoFlow = NULL;
bool flowisrunning = false;
long auto_intervall = 0;
bool auto_isrunning = false;
int countRounds = 0;
int getCountFlowRounds() {
return countRounds;
}
esp_err_t GetJPG(std::string _filename, httpd_req_t *req)
{
return tfliteflow.GetJPGStream(_filename, req);
@@ -101,6 +112,8 @@ void blink_task_doFlow(void *pvParameter)
esp_err_t handler_init(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_init - Start");
LogFile.WriteToFile("handler_init");
printf("handler_doinit uri:\n"); printf(req->uri); printf("\n");
@@ -114,11 +127,15 @@ esp_err_t handler_init(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_init - Done");
return ESP_OK;
};
esp_err_t handler_doflow(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_doflow - Start");
LogFile.WriteToFile("handler_doflow");
char* resp_str;
@@ -138,6 +155,8 @@ esp_err_t handler_doflow(httpd_req_t *req)
httpd_resp_send(req, resp_str, strlen(resp_str));
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_doflow - Done");
return ESP_OK;
};
@@ -146,6 +165,8 @@ esp_err_t handler_doflow(httpd_req_t *req)
esp_err_t handler_wasserzaehler(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_wasserzaehler - Start");
LogFile.WriteToFile("handler_wasserzaehler");
bool _rawValue = false;
bool _noerror = false;
@@ -227,12 +248,15 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_sendstr_chunk(req, NULL);
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_wasserzaehler - Done");
return ESP_OK;
};
esp_err_t handler_editflow(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_editflow - Start");
LogFile.WriteToFile("handler_editflow");
printf("handler_editflow uri: "); printf(req->uri); printf("\n");
@@ -334,6 +358,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
zw = "CutImage Done";
httpd_resp_sendstr_chunk(req, zw.c_str());
}
if (_task.compare("test_take") == 0)
@@ -388,6 +413,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_sendstr_chunk(req, NULL);
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_editflow - Done");
return ESP_OK;
};
@@ -395,6 +421,8 @@ esp_err_t handler_editflow(httpd_req_t *req)
esp_err_t handler_prevalue(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_prevalue - Start");
LogFile.WriteToFile("handler_prevalue");
const char* resp_str;
string zw;
@@ -424,6 +452,8 @@ esp_err_t handler_prevalue(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
if (debug_detail_heap) LogFile.WriteHeapInfo("handler_prevalue - Start");
return ESP_OK;
};
@@ -444,7 +474,8 @@ void task_autodoFlow(void *pvParameter)
while (auto_isrunning)
{
LogFile.WriteToFile("task_autodoFlow - next round");
std::string _zw = "task_autodoFlow - next round - Round #" + std::to_string(++countRounds);
LogFile.WriteToFile(_zw);
printf("Autoflow: start\n");
fr_start = esp_timer_get_time();

View File

@@ -18,3 +18,5 @@ bool isSetupModusActive();
esp_err_t GetJPG(std::string _filename, httpd_req_t *req);
esp_err_t GetRawJPG(httpd_req_t *req);
extern bool debug_detail_heap;

View File

@@ -111,7 +111,7 @@ static void initialize_sntp(void)
{
ESP_LOGI(TAG, "Initializing SNTP");
sntp_setoperatingmode(SNTP_OPMODE_POLL);
sntp_setservername(0, "xx_pool.ntp.org");
sntp_setservername(0, "pool.ntp.org");
// sntp_set_time_sync_notification_cb(time_sync_notification_cb);
sntp_init();
}

View File

@@ -28,6 +28,9 @@
static const char *TAGMAIN = "connect_wlan_main";
bool debug_detail_heap = true;
#define FLASH_GPIO GPIO_NUM_4
void Init_NVS_SDCard()
@@ -121,7 +124,9 @@ extern "C" void app_main(void)
vTaskDelay( xDelay );
// LogFile.WriteToFile("Startsequence 07");
setup_time();
LogFile.WriteToFile("============================== Main Started =======================================");
LogFile.WriteToFile("=============================================================================================");
LogFile.WriteToFile("=================================== Main Started ============================================");
LogFile.WriteToFile("=============================================================================================");
LogFile.SwitchOnOff(false);
std::string zw = gettimestring("%Y%m%d-%H%M%S");

View File

@@ -18,13 +18,14 @@
httpd_handle_t server = NULL;
std::string starttime = "";
/* An HTTP GET handler */
esp_err_t info_get_handler(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("info_get_handler - Start");
LogFile.WriteToFile("info_get_handler");
char _query[200];
char _valuechar[30];
@@ -125,21 +126,27 @@ esp_err_t info_get_handler(httpd_req_t *req)
return ESP_OK;
}
if (debug_detail_heap) LogFile.WriteHeapInfo("info_get_handler - Done");
return ESP_OK;
}
esp_err_t starttime_get_handler(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("starttime_get_handler - Start");
httpd_resp_send(req, starttime.c_str(), strlen(starttime.c_str()));
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
if (debug_detail_heap) LogFile.WriteHeapInfo("starttime_get_handler - Done");
return ESP_OK;
}
esp_err_t hello_main_handler(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("hello_main_handler - Start");
char filepath[50];
printf("uri: %s\n", req->uri);
int _pos;
@@ -189,6 +196,9 @@ esp_err_t hello_main_handler(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
if (debug_detail_heap) LogFile.WriteHeapInfo("hello_main_handler - Stop");
return ESP_OK;
}
@@ -218,6 +228,7 @@ esp_err_t img_tmp_handler(httpd_req_t *req)
esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("img_tmp_virtual_handler - Start");
char filepath[50];
printf("uri: %s\n", req->uri);
@@ -243,6 +254,8 @@ esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
return ESP_OK;
// File wird nicht intern bereit gestellt --> klassischer weg:
if (debug_detail_heap) LogFile.WriteHeapInfo("img_tmp_virtual_handler - Done");
return img_tmp_handler(req);
}
@@ -252,6 +265,8 @@ esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
esp_err_t sysinfo_handler(httpd_req_t *req)
{
if (debug_detail_heap) LogFile.WriteHeapInfo("sysinfo_handler - Start");
const char* resp_str;
std::string zw;
std::string cputemp = std::to_string(temperatureRead());
@@ -287,6 +302,8 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
/* Respond with an empty chunk to signal HTTP response completion */
httpd_resp_send_chunk(req, NULL, 0);
if (debug_detail_heap) LogFile.WriteHeapInfo("sysinfo_handler - Done");
return ESP_OK;
}

View File

@@ -22,9 +22,7 @@ httpd_handle_t start_webserver(void);
void register_server_main_uri(httpd_handle_t server, const char *base_path);
//void disconnect_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data);
//void connect_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data);
extern bool debug_detail_heap;
#endif

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="7e4f83c";
const char* GIT_REV="584a732";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling-reduce-sd-use";
const char* BUILD_TIME="2020-12-24 15:56";
const char* BUILD_TIME="2020-12-26 09:05";

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="7e4f83c";
const char* GIT_REV="584a732";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling-reduce-sd-use";
const char* BUILD_TIME="2020-12-24 15:56";
const char* BUILD_TIME="2020-12-26 09:05";

Binary file not shown.

Binary file not shown.