replaced printf with ESP_LOGD

This commit is contained in:
George Ruinelli
2022-10-21 20:54:38 +02:00
parent c8d2d9d4fd
commit 46daa4cb79
2 changed files with 24 additions and 20 deletions

View File

@@ -14,6 +14,8 @@
#include "esp_wifi.h" #include "esp_wifi.h"
#include "server_tflite.h" #include "server_tflite.h"
#include "esp_log.h"
//#define DEBUG_DETAIL_ON //#define DEBUG_DETAIL_ON
@@ -38,11 +40,11 @@ esp_err_t info_get_handler(httpd_req_t *req)
if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK) if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK)
{ {
printf("Query: "); printf(_query); printf("\n"); ESP_LOGD(TAG_SERVERMAIN, "Query: %s", _query);
if (httpd_query_key_value(_query, "type", _valuechar, 30) == ESP_OK) if (httpd_query_key_value(_query, "type", _valuechar, 30) == ESP_OK)
{ {
printf("type is found"); printf(_valuechar); printf("\n"); ESP_LOGD(TAG_SERVERMAIN, "type is found: %s", _valuechar);
_task = std::string(_valuechar); _task = std::string(_valuechar);
} }
}; };
@@ -153,7 +155,7 @@ esp_err_t hello_main_handler(httpd_req_t *req)
#endif #endif
char filepath[50]; char filepath[50];
printf("uri: %s\n", req->uri); ESP_LOGD(TAG_SERVERMAIN, "uri: %s\n", req->uri);
int _pos; int _pos;
esp_err_t res; esp_err_t res;
@@ -162,7 +164,7 @@ esp_err_t hello_main_handler(httpd_req_t *req)
const char *filename = get_path_from_uri(filepath, base_path, const char *filename = get_path_from_uri(filepath, base_path,
req->uri - 1, sizeof(filepath)); req->uri - 1, sizeof(filepath));
printf("1 uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath); ESP_LOGD(TAG_SERVERMAIN, "1 uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
if ((strcmp(req->uri, "/") == 0)) if ((strcmp(req->uri, "/") == 0))
{ {
@@ -180,13 +182,13 @@ esp_err_t hello_main_handler(httpd_req_t *req)
} }
if (filetosend == "/sdcard/html/index.html" && isSetupModusActive()) { if (filetosend == "/sdcard/html/index.html" && isSetupModusActive()) {
printf("System is in setup mode --> index.html --> setup.html"); ESP_LOGD(TAG_SERVERMAIN, "System is in setup mode --> index.html --> setup.html");
filetosend = "/sdcard/html/setup.html"; filetosend = "/sdcard/html/setup.html";
} }
printf("Filename: %s\n", filename); ESP_LOGD(TAG_SERVERMAIN, "Filename: %s", filename);
printf("File requested: %s\n", filetosend.c_str()); ESP_LOGD(TAG_SERVERMAIN, "File requested: %s", filetosend.c_str());
if (!filename) { if (!filename) {
ESP_LOGE(TAG_SERVERMAIN, "Filename is too long"); ESP_LOGE(TAG_SERVERMAIN, "Filename is too long");
@@ -216,17 +218,17 @@ esp_err_t hello_main_handler(httpd_req_t *req)
esp_err_t img_tmp_handler(httpd_req_t *req) esp_err_t img_tmp_handler(httpd_req_t *req)
{ {
char filepath[50]; char filepath[50];
printf("uri: %s\n", req->uri); ESP_LOGD(TAG_SERVERMAIN, "uri: %s", req->uri);
char *base_path = (char*) req->user_ctx; char *base_path = (char*) req->user_ctx;
std::string filetosend(base_path); std::string filetosend(base_path);
const char *filename = get_path_from_uri(filepath, base_path, const char *filename = get_path_from_uri(filepath, base_path,
req->uri + sizeof("/img_tmp/") - 1, sizeof(filepath)); req->uri + sizeof("/img_tmp/") - 1, sizeof(filepath));
printf("1 uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath); ESP_LOGD(TAG_SERVERMAIN, "1 uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
filetosend = filetosend + "/img_tmp/" + std::string(filename); filetosend = filetosend + "/img_tmp/" + std::string(filename);
printf("File to upload: %s\n", filetosend.c_str()); ESP_LOGD(TAG_SERVERMAIN, "File to upload: %s", filetosend.c_str());
esp_err_t res = send_file(req, filetosend); esp_err_t res = send_file(req, filetosend);
if (res != ESP_OK) if (res != ESP_OK)
@@ -245,17 +247,17 @@ esp_err_t img_tmp_virtual_handler(httpd_req_t *req)
char filepath[50]; char filepath[50];
printf("uri: %s\n", req->uri); ESP_LOGD(TAG_SERVERMAIN, "uri: %s", req->uri);
char *base_path = (char*) req->user_ctx; char *base_path = (char*) req->user_ctx;
std::string filetosend(base_path); std::string filetosend(base_path);
const char *filename = get_path_from_uri(filepath, base_path, const char *filename = get_path_from_uri(filepath, base_path,
req->uri + sizeof("/img_tmp/") - 1, sizeof(filepath)); req->uri + sizeof("/img_tmp/") - 1, sizeof(filepath));
printf("1 uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath); ESP_LOGD(TAG_SERVERMAIN, "1 uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
filetosend = std::string(filename); filetosend = std::string(filename);
printf("File to upload: %s\n", filetosend.c_str()); ESP_LOGD(TAG_SERVERMAIN, "File to upload: %s", filetosend.c_str());
if (filetosend == "raw.jpg") if (filetosend == "raw.jpg")
{ {

View File

@@ -1,5 +1,7 @@
#include "test_flow_postrocess_helper.h" #include "test_flow_postrocess_helper.h"
#include "esp_log.h"
static const char *TAG_POSTPROC_HELPER = "test_flow_postproc_helper";
UnderTestPost* setUpClassFlowPostprocessing(t_CNNType digType, t_CNNType anaType) UnderTestPost* setUpClassFlowPostprocessing(t_CNNType digType, t_CNNType anaType)
{ {
@@ -36,7 +38,7 @@ std::string process_doFlow(std::vector<float> analog, std::vector<float> digits,
bool checkConsistency, bool extendedResolution, int decimal_shift) { bool checkConsistency, bool extendedResolution, int decimal_shift) {
// setup the classundertest // setup the classundertest
UnderTestPost* _undertestPost = init_do_flow(analog, digits, digType, checkConsistency, extendedResolution, decimal_shift); UnderTestPost* _undertestPost = init_do_flow(analog, digits, digType, checkConsistency, extendedResolution, decimal_shift);
printf("SetupClassFlowPostprocessing completed.\n"); ESP_LOGD(TAG_POSTPROC_HELPER, "SetupClassFlowPostprocessing completed.");
string time; string time;
// run test // run test
@@ -81,7 +83,7 @@ UnderTestPost* init_do_flow(std::vector<float> analog, std::vector<float> digits
gen_analog->ROI.push_back(anaROI); gen_analog->ROI.push_back(anaROI);
} }
} }
printf("Setting up of ROIs completed.\n"); ESP_LOGD(TAG_POSTPROC_HELPER, "Setting up of ROIs completed.");
_undertestPost->InitNUMBERS(); _undertestPost->InitNUMBERS();
@@ -95,7 +97,7 @@ UnderTestPost* init_do_flow(std::vector<float> analog, std::vector<float> digits
void setPreValue(UnderTestPost* _underTestPost, double _preValue) { void setPreValue(UnderTestPost* _underTestPost, double _preValue) {
if (_preValue>0) { if (_preValue>0) {
printf("preValue=%f", _preValue); ESP_LOGD(TAG_POSTPROC_HELPER, "preValue=%f", _preValue);
std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers(); std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
for (int _n = 0; _n < (*NUMBERS).size(); ++_n) { for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
(*NUMBERS)[_n]->PreValue = _preValue; (*NUMBERS)[_n]->PreValue = _preValue;
@@ -104,7 +106,7 @@ void setPreValue(UnderTestPost* _underTestPost, double _preValue) {
} }
void setAllowNegatives(UnderTestPost* _underTestPost, bool _allowNegatives) { void setAllowNegatives(UnderTestPost* _underTestPost, bool _allowNegatives) {
printf("checkConsistency=true\n"); ESP_LOGD(TAG_POSTPROC_HELPER, "checkConsistency=true");
std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers(); std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
for (int _n = 0; _n < (*NUMBERS).size(); ++_n) { for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
(*NUMBERS)[_n]->AllowNegativeRates = _allowNegatives; (*NUMBERS)[_n]->AllowNegativeRates = _allowNegatives;
@@ -114,7 +116,7 @@ void setAllowNegatives(UnderTestPost* _underTestPost, bool _allowNegatives) {
void setConsitencyCheck(UnderTestPost* _underTestPost, bool _checkConsistency) { void setConsitencyCheck(UnderTestPost* _underTestPost, bool _checkConsistency) {
if (_checkConsistency) { if (_checkConsistency) {
printf("checkConsistency=true\n"); ESP_LOGD(TAG_POSTPROC_HELPER, "checkConsistency=true");
std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers(); std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
for (int _n = 0; _n < (*NUMBERS).size(); ++_n) { for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
(*NUMBERS)[_n]->checkDigitIncreaseConsistency = true; (*NUMBERS)[_n]->checkDigitIncreaseConsistency = true;
@@ -136,7 +138,7 @@ void setDecimalShift(UnderTestPost* _underTestPost, int _decimal_shift) {
if (_decimal_shift!=0) { if (_decimal_shift!=0) {
std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers(); std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
for (int _n = 0; _n < (*NUMBERS).size(); ++_n) { for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
printf("Setting decimal shift on number: %d to %d\n", _n, _decimal_shift); ESP_LOGD(TAG_POSTPROC_HELPER, "Setting decimal shift on number: %d to %d", _n, _decimal_shift);
(*NUMBERS)[_n]->DecimalShift = _decimal_shift; (*NUMBERS)[_n]->DecimalShift = _decimal_shift;
(*NUMBERS)[_n]->DecimalShiftInitial = _decimal_shift; (*NUMBERS)[_n]->DecimalShiftInitial = _decimal_shift;
} }
@@ -147,7 +149,7 @@ void setAnalogdigitTransistionStart(UnderTestPost* _underTestPost, float _analog
if (_analogdigitTransistionStart!=0) { if (_analogdigitTransistionStart!=0) {
std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers(); std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
for (int _n = 0; _n < (*NUMBERS).size(); ++_n) { for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
printf("Setting decimal shift on number: %d to %f\n", _n, _analogdigitTransistionStart); ESP_LOGD(TAG_POSTPROC_HELPER, "Setting decimal shift on number: %d to %f", _n, _analogdigitTransistionStart);
(*NUMBERS)[_n]->AnalogDigitalTransitionStart = _analogdigitTransistionStart; (*NUMBERS)[_n]->AnalogDigitalTransitionStart = _analogdigitTransistionStart;
} }
} }