mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-17 13:08:40 +03:00
Merge pull request #1201 from jomjol/replace-printf-with-esp_log
Replace printf with ESP_LOGD
This commit is contained in:
@@ -4,8 +4,9 @@
|
|||||||
|
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
#include "configFile.h"
|
#include "configFile.h"
|
||||||
|
#include <esp_log.h>
|
||||||
|
|
||||||
//static const char *TAGCONFIGFILE = "configFile";
|
static const char *TAG = "configFile";
|
||||||
|
|
||||||
ConfigFile::ConfigFile(std::string filePath)
|
ConfigFile::ConfigFile(std::string filePath)
|
||||||
{
|
{
|
||||||
@@ -48,7 +49,7 @@ bool ConfigFile::getNextLine(std::string *rt, bool &disabled, bool &eof)
|
|||||||
|
|
||||||
if (fgets(zw, 1024, pFile))
|
if (fgets(zw, 1024, pFile))
|
||||||
{
|
{
|
||||||
printf("%s", zw);
|
ESP_LOGD(TAG, "%s", zw);
|
||||||
if ((strlen(zw) == 0) && feof(pFile))
|
if ((strlen(zw) == 0) && feof(pFile))
|
||||||
{
|
{
|
||||||
*rt = "";
|
*rt = "";
|
||||||
@@ -67,7 +68,7 @@ bool ConfigFile::getNextLine(std::string *rt, bool &disabled, bool &eof)
|
|||||||
while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph
|
while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph
|
||||||
{
|
{
|
||||||
fgets(zw, 1024, pFile);
|
fgets(zw, 1024, pFile);
|
||||||
printf("%s", zw);
|
ESP_LOGD(TAG, "%s", zw);
|
||||||
if (feof(pFile))
|
if (feof(pFile))
|
||||||
{
|
{
|
||||||
*rt = "";
|
*rt = "";
|
||||||
|
|||||||
@@ -210,10 +210,10 @@ GpioHandler::~GpioHandler() {
|
|||||||
void GpioHandler::init()
|
void GpioHandler::init()
|
||||||
{
|
{
|
||||||
// TickType_t xDelay = 60000 / portTICK_PERIOD_MS;
|
// TickType_t xDelay = 60000 / portTICK_PERIOD_MS;
|
||||||
// printf("wait before start %ldms\r\n", (long) xDelay);
|
// ESP_LOGD(TAG_SERVERGPIO, "wait before start %ldms", (long) xDelay);
|
||||||
// vTaskDelay( xDelay );
|
// vTaskDelay( xDelay );
|
||||||
|
|
||||||
printf("*************** Start GPIOHandler_Init *****************\n");
|
ESP_LOGD(TAG_SERVERGPIO, "*************** Start GPIOHandler_Init *****************");
|
||||||
|
|
||||||
if (gpioMap == NULL) {
|
if (gpioMap == NULL) {
|
||||||
gpioMap = new std::map<gpio_num_t, GpioPin*>();
|
gpioMap = new std::map<gpio_num_t, GpioPin*>();
|
||||||
@@ -300,13 +300,13 @@ bool GpioHandler::readConfig()
|
|||||||
bool eof = false;
|
bool eof = false;
|
||||||
gpio_num_t gpioExtLED = (gpio_num_t) 0;
|
gpio_num_t gpioExtLED = (gpio_num_t) 0;
|
||||||
|
|
||||||
// printf("readConfig - Start 1\n");
|
// ESP_LOGD(TAG_SERVERGPIO, "readConfig - Start 1");
|
||||||
|
|
||||||
while ((!configFile.GetNextParagraph(line, disabledLine, eof) || (line.compare("[GPIO]") != 0)) && !eof) {}
|
while ((!configFile.GetNextParagraph(line, disabledLine, eof) || (line.compare("[GPIO]") != 0)) && !eof) {}
|
||||||
if (eof)
|
if (eof)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// printf("readConfig - Start 2 line: %s, disabbledLine: %d\n", line.c_str(), (int) disabledLine);
|
// ESP_LOGD(TAG_SERVERGPIO, "readConfig - Start 2 line: %s, disabbledLine: %d", line.c_str(), (int) disabledLine);
|
||||||
|
|
||||||
|
|
||||||
_isEnabled = !disabledLine;
|
_isEnabled = !disabledLine;
|
||||||
@@ -314,7 +314,7 @@ bool GpioHandler::readConfig()
|
|||||||
if (!_isEnabled)
|
if (!_isEnabled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// printf("readConfig - Start 3\n");
|
// ESP_LOGD(TAG_SERVERGPIO, "readConfig - Start 3");
|
||||||
|
|
||||||
// std::string mainTopicMQTT = "";
|
// std::string mainTopicMQTT = "";
|
||||||
std::string mainTopicMQTT = GetMQTTMainTopic();
|
std::string mainTopicMQTT = GetMQTTMainTopic();
|
||||||
@@ -359,7 +359,7 @@ bool GpioHandler::readConfig()
|
|||||||
|
|
||||||
if (pinMode == GPIO_PIN_MODE_EXTERNAL_FLASH_WS281X)
|
if (pinMode == GPIO_PIN_MODE_EXTERNAL_FLASH_WS281X)
|
||||||
{
|
{
|
||||||
printf("Set WS2812 to GPIO %d\n", gpioNr);
|
ESP_LOGD(TAG_SERVERGPIO, "Set WS2812 to GPIO %d", gpioNr);
|
||||||
gpioExtLED = gpioNr;
|
gpioExtLED = gpioNr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +403,7 @@ bool GpioHandler::readConfig()
|
|||||||
// LogFile.WriteToFile("Startsequence 06"); // Nremove
|
// LogFile.WriteToFile("Startsequence 06"); // Nremove
|
||||||
// vTaskDelay( xDelay );
|
// vTaskDelay( xDelay );
|
||||||
// xDelay = 5000 / portTICK_PERIOD_MS;
|
// xDelay = 5000 / portTICK_PERIOD_MS;
|
||||||
// printf("main: sleep for : %ldms\n", (long) xDelay);
|
// ESP_LOGD(TAG_SERVERGPIO, "main: sleep for: %ldms", (long) xDelay);
|
||||||
|
|
||||||
// SmartLed leds( LED_WS2812, 2, GPIO_NUM_12, 0, DoubleBuffer );
|
// SmartLed leds( LED_WS2812, 2, GPIO_NUM_12, 0, DoubleBuffer );
|
||||||
|
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ void CCamera::SetQualitySize(int qual, framesize_t resol)
|
|||||||
|
|
||||||
void CCamera::EnableAutoExposure(int flashdauer)
|
void CCamera::EnableAutoExposure(int flashdauer)
|
||||||
{
|
{
|
||||||
printf("EnableAutoExposure");
|
ESP_LOGD(TAGCAMERACLASS, "EnableAutoExposure");
|
||||||
LEDOnOff(true);
|
LEDOnOff(true);
|
||||||
if (flashdauer > 0)
|
if (flashdauer > 0)
|
||||||
LightOnOff(true);
|
LightOnOff(true);
|
||||||
@@ -423,19 +423,19 @@ esp_err_t CCamera::CaptureToFile(std::string nm, int delay)
|
|||||||
LEDOnOff(false);
|
LEDOnOff(false);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("w %d, h %d, size %d\n", fb->width, fb->height, fb->len);
|
ESP_LOGD(TAGCAMERACLASS, "w %d, h %d, size %d", fb->width, fb->height, fb->len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nm = FormatFileName(nm);
|
nm = FormatFileName(nm);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Save Camera to : %s\n", nm.c_str());
|
ESP_LOGD(TAGCAMERACLASS, "Save Camera to : %s", nm.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ftype = toUpper(getFileType(nm));
|
ftype = toUpper(getFileType(nm));
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Filetype: %s\n", ftype.c_str());
|
ESP_LOGD(TAGCAMERACLASS, "Filetype: %s", ftype.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t * buf = NULL;
|
uint8_t * buf = NULL;
|
||||||
@@ -551,20 +551,20 @@ void CCamera::LightOnOff(bool status)
|
|||||||
{
|
{
|
||||||
GpioHandler* gpioHandler = gpio_handler_get();
|
GpioHandler* gpioHandler = gpio_handler_get();
|
||||||
if ((gpioHandler != NULL) && (gpioHandler->isEnabled())) {
|
if ((gpioHandler != NULL) && (gpioHandler->isEnabled())) {
|
||||||
printf("Use gpioHandler flashLigh\n");
|
ESP_LOGD(TAGCAMERACLASS, "Use gpioHandler flashLigh");
|
||||||
gpioHandler->flashLightEnable(status);
|
gpioHandler->flashLightEnable(status);
|
||||||
} else {
|
} else {
|
||||||
#ifdef USE_PWM_LEDFLASH
|
#ifdef USE_PWM_LEDFLASH
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
printf("Internal Flash-LED turn on with PWM %d\n", led_intensity);
|
ESP_LOGD(TAGCAMERACLASS, "Internal Flash-LED turn on with PWM %d", led_intensity);
|
||||||
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, led_intensity));
|
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, led_intensity));
|
||||||
// Update duty to apply the new value
|
// Update duty to apply the new value
|
||||||
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
|
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Internal Flash-LED turn off PWM\n");
|
ESP_LOGD(TAGCAMERACLASS, "Internal Flash-LED turn off PWM");
|
||||||
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, 0));
|
ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, 0));
|
||||||
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
|
ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
|
||||||
}
|
}
|
||||||
@@ -608,11 +608,11 @@ void CCamera::GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol
|
|||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
printf("Query: "); printf(_query); printf("\n");
|
ESP_LOGD(TAGCAMERACLASS, "Query: %s", _query);
|
||||||
if (httpd_query_key_value(_query, "size", _size, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "size", _size, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Size: "); printf(_size); printf("\n");
|
ESP_LOGD(TAGCAMERACLASS, "Size: %s", _size);
|
||||||
#endif
|
#endif
|
||||||
if (strcmp(_size, "QVGA") == 0)
|
if (strcmp(_size, "QVGA") == 0)
|
||||||
resol = FRAMESIZE_QVGA; // 320x240
|
resol = FRAMESIZE_QVGA; // 320x240
|
||||||
@@ -630,7 +630,7 @@ void CCamera::GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol
|
|||||||
if (httpd_query_key_value(_query, "quality", _qual, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "quality", _qual, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Quality: "); printf(_qual); printf("\n");
|
ESP_LOGD(TAGCAMERACLASS, "Quality: %s", _qual);
|
||||||
#endif
|
#endif
|
||||||
qual = atoi(_qual);
|
qual = atoi(_qual);
|
||||||
|
|
||||||
@@ -663,7 +663,7 @@ framesize_t CCamera::TextToFramesize(const char * _size)
|
|||||||
CCamera::CCamera()
|
CCamera::CCamera()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("CreateClassCamera\n");
|
ESP_LOGD(TAGCAMERACLASS, "CreateClassCamera");
|
||||||
#endif
|
#endif
|
||||||
brightness = -5;
|
brightness = -5;
|
||||||
contrast = -5;
|
contrast = -5;
|
||||||
@@ -675,7 +675,7 @@ CCamera::CCamera()
|
|||||||
|
|
||||||
esp_err_t CCamera::InitCam()
|
esp_err_t CCamera::InitCam()
|
||||||
{
|
{
|
||||||
printf("Init Camera\n");
|
ESP_LOGD(TAGCAMERACLASS, "Init Camera");
|
||||||
ActualQuality = camera_config.jpeg_quality;
|
ActualQuality = camera_config.jpeg_quality;
|
||||||
ActualResolution = camera_config.frame_size;
|
ActualResolution = camera_config.frame_size;
|
||||||
//initialize the camera
|
//initialize the camera
|
||||||
@@ -694,6 +694,6 @@ void CCamera::SetLEDIntensity(float _intrel)
|
|||||||
_intrel = max(_intrel, (float) 0);
|
_intrel = max(_intrel, (float) 0);
|
||||||
_intrel = _intrel / 100;
|
_intrel = _intrel / 100;
|
||||||
led_intensity = (int) (_intrel * 8191);
|
led_intensity = (int) (_intrel * 8191);
|
||||||
printf("Set led_intensity to %d of 8191\n", led_intensity);
|
ESP_LOGD(TAGCAMERACLASS, "Set led_intensity to %d of 8191", led_intensity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
#include "ClassControllCamera.h"
|
#include "ClassControllCamera.h"
|
||||||
|
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
static const char *TAG = "server_cam";
|
||||||
|
|
||||||
#define SCRATCH_BUFSIZE2 8192
|
#define SCRATCH_BUFSIZE2 8192
|
||||||
char scratch2[SCRATCH_BUFSIZE2];
|
char scratch2[SCRATCH_BUFSIZE2];
|
||||||
@@ -37,7 +40,7 @@ esp_err_t handler_lightOn(httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_lightOn - Start");
|
LogFile.WriteHeapInfo("handler_lightOn - Start");
|
||||||
printf("handler_lightOn uri:\n"); printf(req->uri); printf("\n");
|
ESP_LOGD(TAG, "handler_lightOn uri: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Camera.LightOnOff(true);
|
Camera.LightOnOff(true);
|
||||||
@@ -55,7 +58,7 @@ esp_err_t handler_lightOff(httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_lightOff - Start");
|
LogFile.WriteHeapInfo("handler_lightOff - Start");
|
||||||
printf("handler_lightOff uri:\n"); printf(req->uri); printf("\n");
|
ESP_LOGD(TAG, "handler_lightOff uri: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
Camera.LightOnOff(false);
|
Camera.LightOnOff(false);
|
||||||
const char* resp_str = (const char*) req->user_ctx;
|
const char* resp_str = (const char*) req->user_ctx;
|
||||||
@@ -80,7 +83,7 @@ esp_err_t handler_capture(httpd_req_t *req)
|
|||||||
Camera.GetCameraParameter(req, quality, res);
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Size: %d", res); printf(" Quality: %d\n", quality);
|
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Camera.SetQualitySize(quality, res);
|
Camera.SetQualitySize(quality, res);
|
||||||
@@ -110,11 +113,11 @@ esp_err_t handler_capture_with_ligth(httpd_req_t *req)
|
|||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
printf("Query: "); printf(_query); printf("\n");
|
ESP_LOGD(TAG, "Query: %s", _query);
|
||||||
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Delay: "); printf(_delay); printf("\n");
|
ESP_LOGD(TAG, "Delay: %s", _delay);
|
||||||
#endif
|
#endif
|
||||||
delay = atoi(_delay);
|
delay = atoi(_delay);
|
||||||
|
|
||||||
@@ -126,7 +129,7 @@ esp_err_t handler_capture_with_ligth(httpd_req_t *req)
|
|||||||
Camera.GetCameraParameter(req, quality, res);
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Size: %d", res); printf(" Quality: %d\n", quality);
|
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Camera.SetQualitySize(quality, res);
|
Camera.SetQualitySize(quality, res);
|
||||||
@@ -166,12 +169,12 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req)
|
|||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
printf("Query: "); printf(_query); printf("\n");
|
ESP_LOGD(TAG, "Query: %s", _query);
|
||||||
if (httpd_query_key_value(_query, "filename", filename, 100) == ESP_OK)
|
if (httpd_query_key_value(_query, "filename", filename, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
fn.append(filename);
|
fn.append(filename);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Filename: "); printf(fn.c_str()); printf("\n");
|
ESP_LOGD(TAG, "Filename: %s", fn.c_str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -180,7 +183,7 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req)
|
|||||||
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "delay", _delay, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Delay: "); printf(_delay); printf("\n");
|
ESP_LOGD(TAG, "Delay: %s", _delay);
|
||||||
#endif
|
#endif
|
||||||
delay = atoi(_delay);
|
delay = atoi(_delay);
|
||||||
|
|
||||||
@@ -194,7 +197,7 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req)
|
|||||||
|
|
||||||
Camera.GetCameraParameter(req, quality, res);
|
Camera.GetCameraParameter(req, quality, res);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Size: %d", res); printf(" Quality: %d\n", quality);
|
ESP_LOGD(TAG, "Size: %d, Quality: %d", res, quality);
|
||||||
#endif
|
#endif
|
||||||
Camera.SetQualitySize(quality, res);
|
Camera.SetQualitySize(quality, res);
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ extern "C" {
|
|||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
#include "miniz.h"
|
#include "miniz.h"
|
||||||
|
|
||||||
|
static const char *TAG = "server_file";
|
||||||
|
|
||||||
/* Max length a file path can have on storage */
|
/* Max length a file path can have on storage */
|
||||||
// #define FILE_PATH_MAX (ESP_VFS_PATH_MAX + CONFIG_SPIFFS_OBJ_NAME_LEN)
|
// #define FILE_PATH_MAX (ESP_VFS_PATH_MAX + CONFIG_SPIFFS_OBJ_NAME_LEN)
|
||||||
#define FILE_PATH_MAX (255)
|
#define FILE_PATH_MAX (255)
|
||||||
@@ -88,7 +90,7 @@ esp_err_t get_tflite_file_handler(httpd_req_t *req)
|
|||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
|
||||||
const char verz_name[] = "/sdcard/config";
|
const char verz_name[] = "/sdcard/config";
|
||||||
printf("Suche TFLITE in /sdcard/config/\n");
|
ESP_LOGD(TAG, "Suche TFLITE in /sdcard/config/");
|
||||||
|
|
||||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
httpd_resp_set_type(req, "text/plain");
|
httpd_resp_set_type(req, "text/plain");
|
||||||
@@ -97,7 +99,7 @@ esp_err_t get_tflite_file_handler(httpd_req_t *req)
|
|||||||
while ((entry = readdir(dir)) != NULL)
|
while ((entry = readdir(dir)) != NULL)
|
||||||
{
|
{
|
||||||
_filename = std::string(entry->d_name);
|
_filename = std::string(entry->d_name);
|
||||||
printf("File: %s\t", _filename.c_str());
|
ESP_LOGD(TAG, "File: %s", _filename.c_str());
|
||||||
|
|
||||||
// ignore all files with starting dot (hidden files)
|
// ignore all files with starting dot (hidden files)
|
||||||
if (_filename.rfind(".", 0) == 0) {
|
if (_filename.rfind(".", 0) == 0) {
|
||||||
@@ -109,7 +111,7 @@ esp_err_t get_tflite_file_handler(httpd_req_t *req)
|
|||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
_fileext = _fileext.erase(0, pos + 1);
|
_fileext = _fileext.erase(0, pos + 1);
|
||||||
|
|
||||||
printf(" Extension: %s\n", _fileext.c_str());
|
ESP_LOGD(TAG, " Extension: %s", _fileext.c_str());
|
||||||
|
|
||||||
if ((_fileext == "tfl") || (_fileext == "tflite"))
|
if ((_fileext == "tfl") || (_fileext == "tflite"))
|
||||||
{
|
{
|
||||||
@@ -147,11 +149,11 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
|
|||||||
DIR *dir = opendir(dirpath_corrected);
|
DIR *dir = opendir(dirpath_corrected);
|
||||||
|
|
||||||
const size_t dirpath_len = strlen(dirpath);
|
const size_t dirpath_len = strlen(dirpath);
|
||||||
printf("Dirpath: <%s>, Pathlength: %d\n", dirpath, dirpath_len);
|
ESP_LOGD(TAG, "Dirpath: <%s>, Pathlength: %d", dirpath, dirpath_len);
|
||||||
|
|
||||||
/* Retrieve the base path of file storage to construct the full path */
|
/* Retrieve the base path of file storage to construct the full path */
|
||||||
strlcpy(entrypath, dirpath, sizeof(entrypath));
|
strlcpy(entrypath, dirpath, sizeof(entrypath));
|
||||||
printf("entrypath: <%s>\n", entrypath);
|
ESP_LOGD(TAG, "entrypath: <%s>", entrypath);
|
||||||
|
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
ESP_LOGE(TAG_FILESERVER, "Failed to stat dir : %s", dirpath);
|
ESP_LOGE(TAG_FILESERVER, "Failed to stat dir : %s", dirpath);
|
||||||
@@ -170,7 +172,7 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
|
|||||||
size_t chunksize;
|
size_t chunksize;
|
||||||
do {
|
do {
|
||||||
chunksize = fread(chunk, 1, SCRATCH_BUFSIZE, fd);
|
chunksize = fread(chunk, 1, SCRATCH_BUFSIZE, fd);
|
||||||
// printf("Chunksize %d\n", chunksize);
|
// ESP_LOGD(TAG, "Chunksize %d", chunksize);
|
||||||
if (chunksize > 0){
|
if (chunksize > 0){
|
||||||
if (httpd_resp_send_chunk(req, chunk, chunksize) != ESP_OK) {
|
if (httpd_resp_send_chunk(req, chunk, chunksize) != ESP_OK) {
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
@@ -211,7 +213,7 @@ static esp_err_t http_resp_dir_html(httpd_req_t *req, const char *dirpath, const
|
|||||||
entrytype = (entry->d_type == DT_DIR ? "directory" : "file");
|
entrytype = (entry->d_type == DT_DIR ? "directory" : "file");
|
||||||
|
|
||||||
strlcpy(entrypath + dirpath_len, entry->d_name, sizeof(entrypath) - dirpath_len);
|
strlcpy(entrypath + dirpath_len, entry->d_name, sizeof(entrypath) - dirpath_len);
|
||||||
printf("Entrypath: %s\n", entrypath);
|
ESP_LOGD(TAG, "Entrypath: %s", entrypath);
|
||||||
if (stat(entrypath, &entry_stat) == -1) {
|
if (stat(entrypath, &entry_stat) == -1) {
|
||||||
ESP_LOGE(TAG_FILESERVER, "Failed to stat %s : %s", entrytype, entry->d_name);
|
ESP_LOGE(TAG_FILESERVER, "Failed to stat %s : %s", entrytype, entry->d_name);
|
||||||
continue;
|
continue;
|
||||||
@@ -266,11 +268,11 @@ static esp_err_t logfileact_get_handler(httpd_req_t *req)
|
|||||||
char filepath[FILE_PATH_MAX];
|
char filepath[FILE_PATH_MAX];
|
||||||
FILE *fd = NULL;
|
FILE *fd = NULL;
|
||||||
//struct stat file_stat;
|
//struct stat file_stat;
|
||||||
printf("uri: %s\n", req->uri);
|
ESP_LOGD(TAG, "uri: %s", req->uri);
|
||||||
|
|
||||||
const char* filename = "log_current.txt";
|
const char* filename = "log_current.txt";
|
||||||
|
|
||||||
printf("uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath);
|
ESP_LOGD(TAG, "uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
|
||||||
|
|
||||||
std::string currentfilename = LogFile.GetCurrentFileName();
|
std::string currentfilename = LogFile.GetCurrentFileName();
|
||||||
|
|
||||||
@@ -331,12 +333,12 @@ static esp_err_t download_get_handler(httpd_req_t *req)
|
|||||||
char filepath[FILE_PATH_MAX];
|
char filepath[FILE_PATH_MAX];
|
||||||
FILE *fd = NULL;
|
FILE *fd = NULL;
|
||||||
struct stat file_stat;
|
struct stat file_stat;
|
||||||
printf("uri: %s\n", req->uri);
|
ESP_LOGD(TAG, "uri: %s", req->uri);
|
||||||
|
|
||||||
const char *filename = get_path_from_uri(filepath, ((struct file_server_data *)req->user_ctx)->base_path,
|
const char *filename = get_path_from_uri(filepath, ((struct file_server_data *)req->user_ctx)->base_path,
|
||||||
req->uri + sizeof("/fileserver") - 1, sizeof(filepath));
|
req->uri + sizeof("/fileserver") - 1, sizeof(filepath));
|
||||||
|
|
||||||
printf("uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath);
|
ESP_LOGD(TAG, "uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
|
||||||
|
|
||||||
// filename = get_path_from_uri(filepath, ((struct file_server_data *)req->user_ctx)->base_path,
|
// filename = get_path_from_uri(filepath, ((struct file_server_data *)req->user_ctx)->base_path,
|
||||||
// req->uri, sizeof(filepath));
|
// req->uri, sizeof(filepath));
|
||||||
@@ -366,7 +368,7 @@ static esp_err_t download_get_handler(httpd_req_t *req)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("uri: %s, filename: %s, filepath: %s\n", req->uri, filename, filepath);
|
ESP_LOGD(TAG, "uri: %s, filename: %s, filepath: %s", req->uri, filename, filepath);
|
||||||
return http_resp_dir_html(req, filepath, filename, readonly);
|
return http_resp_dir_html(req, filepath, filename, readonly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,12 +543,12 @@ static esp_err_t upload_post_handler(httpd_req_t *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int start_fn = strlen(((struct file_server_data *)req->user_ctx)->base_path);
|
int start_fn = strlen(((struct file_server_data *)req->user_ctx)->base_path);
|
||||||
printf("Directory: %s, start_fn: %d, found: %d\n", directory.c_str(), start_fn, found);
|
ESP_LOGD(TAG, "Directory: %s, start_fn: %d, found: %d", directory.c_str(), start_fn, found);
|
||||||
directory = directory.substr(start_fn, found - start_fn + 1);
|
directory = directory.substr(start_fn, found - start_fn + 1);
|
||||||
printf("Directory danach 1: %s\n", directory.c_str());
|
ESP_LOGD(TAG, "Directory danach 1: %s", directory.c_str());
|
||||||
|
|
||||||
directory = "/fileserver" + directory;
|
directory = "/fileserver" + directory;
|
||||||
printf("Directory danach 2: %s\n", directory.c_str());
|
ESP_LOGD(TAG, "Directory danach 2: %s", directory.c_str());
|
||||||
|
|
||||||
/* Redirect onto root to see the updated file list */
|
/* Redirect onto root to see the updated file list */
|
||||||
httpd_resp_set_status(req, "303 See Other");
|
httpd_resp_set_status(req, "303 See Other");
|
||||||
@@ -559,7 +561,7 @@ static esp_err_t upload_post_handler(httpd_req_t *req)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
if (strcmp(filepath, CONFIG_FILE) == 0) {
|
if (strcmp(filepath, CONFIG_FILE) == 0) {
|
||||||
printf("New config found. Reload handler.");
|
ESP_LOGD(TAG, "New config found. Reload handler.");
|
||||||
gpio_handler_deinit();
|
gpio_handler_deinit();
|
||||||
MQTTdestroy();
|
MQTTdestroy();
|
||||||
}
|
}
|
||||||
@@ -586,11 +588,11 @@ static esp_err_t delete_post_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, "Query: %s", _query);
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
||||||
{
|
{
|
||||||
printf("task is found: "); printf(_valuechar); printf("\n");
|
ESP_LOGD(TAG, "task is found: %s", _valuechar);
|
||||||
_task = std::string(_valuechar);
|
_task = std::string(_valuechar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -610,12 +612,12 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
|
|||||||
zw = zw.substr(0, zw.length()-1);
|
zw = zw.substr(0, zw.length()-1);
|
||||||
directory = "/fileserver" + zw + "/";
|
directory = "/fileserver" + zw + "/";
|
||||||
zw = "/sdcard" + zw;
|
zw = "/sdcard" + zw;
|
||||||
printf("Directory to delete: %s\n", zw.c_str());
|
ESP_LOGD(TAG, "Directory to delete: %s", zw.c_str());
|
||||||
|
|
||||||
delete_all_in_directory(zw);
|
delete_all_in_directory(zw);
|
||||||
// directory = std::string(filepath);
|
// directory = std::string(filepath);
|
||||||
// directory = "/fileserver" + directory;
|
// directory = "/fileserver" + directory;
|
||||||
printf("Location after delete directory content: %s\n", directory.c_str());
|
ESP_LOGD(TAG, "Location after delete directory content: %s", directory.c_str());
|
||||||
/* Redirect onto root to see the updated file list */
|
/* Redirect onto root to see the updated file list */
|
||||||
// httpd_resp_set_status(req, "303 See Other");
|
// httpd_resp_set_status(req, "303 See Other");
|
||||||
// httpd_resp_set_hdr(req, "Location", directory.c_str());
|
// httpd_resp_set_hdr(req, "Location", directory.c_str());
|
||||||
@@ -663,12 +665,12 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int start_fn = strlen(((struct file_server_data *)req->user_ctx)->base_path);
|
int start_fn = strlen(((struct file_server_data *)req->user_ctx)->base_path);
|
||||||
printf("Directory: %s, start_fn: %d, found: %d\n", directory.c_str(), start_fn, found);
|
ESP_LOGD(TAG, "Directory: %s, start_fn: %d, found: %d", directory.c_str(), start_fn, found);
|
||||||
directory = directory.substr(start_fn, found - start_fn + 1);
|
directory = directory.substr(start_fn, found - start_fn + 1);
|
||||||
printf("Directory danach 3: %s\n", directory.c_str());
|
ESP_LOGD(TAG, "Directory danach 3: %s", directory.c_str());
|
||||||
|
|
||||||
directory = "/fileserver" + directory;
|
directory = "/fileserver" + directory;
|
||||||
printf("Directory danach 4: %s\n", directory.c_str());
|
ESP_LOGD(TAG, "Directory danach 4: %s", directory.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -722,18 +724,18 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
|
|||||||
std::string directory = "";
|
std::string directory = "";
|
||||||
// static const char* s_Test_archive_filename = "testhtml.zip";
|
// static const char* s_Test_archive_filename = "testhtml.zip";
|
||||||
|
|
||||||
printf("miniz.c version: %s\n", MZ_VERSION);
|
ESP_LOGD(TAG, "miniz.c version: %s", MZ_VERSION);
|
||||||
printf("Zipfile: %s\n", _in_zip_file.c_str());
|
ESP_LOGD(TAG, "Zipfile: %s", _in_zip_file.c_str());
|
||||||
printf("Target Dir ZIP: %s\n", _target_zip.c_str());
|
ESP_LOGD(TAG, "Target Dir ZIP: %s", _target_zip.c_str());
|
||||||
printf("Target Dir BIN: %s\n", _target_bin.c_str());
|
ESP_LOGD(TAG, "Target Dir BIN: %s", _target_bin.c_str());
|
||||||
printf("Target Dir main: %s\n", _main.c_str());
|
ESP_LOGD(TAG, "Target Dir main: %s", _main.c_str());
|
||||||
|
|
||||||
// Now try to open the archive.
|
// Now try to open the archive.
|
||||||
memset(&zip_archive, 0, sizeof(zip_archive));
|
memset(&zip_archive, 0, sizeof(zip_archive));
|
||||||
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), 0);
|
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), 0);
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_init_file() failed!\n");
|
ESP_LOGD(TAG, "mz_zip_reader_init_file() failed!");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,7 +747,7 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
|
|||||||
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
|
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_init_file() failed!\n");
|
ESP_LOGD(TAG, "mz_zip_reader_init_file() failed!");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,14 +762,14 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
|
|||||||
p = mz_zip_reader_extract_file_to_heap(&zip_archive, archive_filename, &uncomp_size, 0);
|
p = mz_zip_reader_extract_file_to_heap(&zip_archive, archive_filename, &uncomp_size, 0);
|
||||||
if (!p)
|
if (!p)
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_extract_file_to_heap() failed on file %s\n", archive_filename);
|
ESP_LOGD(TAG, "mz_zip_reader_extract_file_to_heap() failed on file %s", archive_filename);
|
||||||
mz_zip_reader_end(&zip_archive);
|
mz_zip_reader_end(&zip_archive);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save to File.
|
// Save to File.
|
||||||
zw = std::string(archive_filename);
|
zw = std::string(archive_filename);
|
||||||
printf("Rohfilename: %s\n", zw.c_str());
|
ESP_LOGD(TAG, "Rohfilename: %s", zw.c_str());
|
||||||
|
|
||||||
if (getFileType(zw) == "BIN")
|
if (getFileType(zw) == "BIN")
|
||||||
{
|
{
|
||||||
@@ -791,7 +793,7 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
|
|||||||
|
|
||||||
string filename_zw = zw + SUFFIX_ZW;
|
string filename_zw = zw + SUFFIX_ZW;
|
||||||
|
|
||||||
printf("Filename to extract: %s, Zwischenfilename: %s", zw.c_str(), filename_zw.c_str());
|
ESP_LOGD(TAG, "Filename to extract: %s, Zwischenfilename: %s", zw.c_str(), filename_zw.c_str());
|
||||||
|
|
||||||
// extrahieren in zwischendatei
|
// extrahieren in zwischendatei
|
||||||
DeleteFile(filename_zw);
|
DeleteFile(filename_zw);
|
||||||
@@ -803,8 +805,8 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
|
|||||||
RenameFile(filename_zw, zw);
|
RenameFile(filename_zw, zw);
|
||||||
DeleteFile(filename_zw);
|
DeleteFile(filename_zw);
|
||||||
|
|
||||||
printf("Successfully extracted file \"%s\", size %u\n", archive_filename, (uint)uncomp_size);
|
ESP_LOGD(TAG, "Successfully extracted file \"%s\", size %u", archive_filename, (uint)uncomp_size);
|
||||||
// printf("File data: \"%s\"\n", (const char*)p);
|
// ESP_LOGD(TAG, "File data: \"%s\"", (const char*)p);
|
||||||
|
|
||||||
// We're done.
|
// We're done.
|
||||||
mz_free(p);
|
mz_free(p);
|
||||||
@@ -815,7 +817,7 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
|
|||||||
mz_zip_reader_end(&zip_archive);
|
mz_zip_reader_end(&zip_archive);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Success.\n");
|
ESP_LOGD(TAG, "Success.");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -829,16 +831,16 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
|
|||||||
std::string zw;
|
std::string zw;
|
||||||
// static const char* s_Test_archive_filename = "testhtml.zip";
|
// static const char* s_Test_archive_filename = "testhtml.zip";
|
||||||
|
|
||||||
printf("miniz.c version: %s\n", MZ_VERSION);
|
ESP_LOGD(TAG, "miniz.c version: %s", MZ_VERSION);
|
||||||
printf("Zipfile: %s\n", _in_zip_file.c_str());
|
ESP_LOGD(TAG, "Zipfile: %s", _in_zip_file.c_str());
|
||||||
printf("Target Dir: %s\n", _target_directory.c_str());
|
ESP_LOGD(TAG, "Target Dir: %s", _target_directory.c_str());
|
||||||
|
|
||||||
// Now try to open the archive.
|
// Now try to open the archive.
|
||||||
memset(&zip_archive, 0, sizeof(zip_archive));
|
memset(&zip_archive, 0, sizeof(zip_archive));
|
||||||
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), 0);
|
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), 0);
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_init_file() failed!\n");
|
ESP_LOGD(TAG, "mz_zip_reader_init_file() failed!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,7 +852,7 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
|
|||||||
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
|
status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
|
||||||
if (!status)
|
if (!status)
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_init_file() failed!\n");
|
ESP_LOGD(TAG, "mz_zip_reader_init_file() failed!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -864,7 +866,7 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
|
|||||||
p = mz_zip_reader_extract_file_to_heap(&zip_archive, archive_filename, &uncomp_size, 0);
|
p = mz_zip_reader_extract_file_to_heap(&zip_archive, archive_filename, &uncomp_size, 0);
|
||||||
if (!p)
|
if (!p)
|
||||||
{
|
{
|
||||||
printf("mz_zip_reader_extract_file_to_heap() failed!\n");
|
ESP_LOGD(TAG, "mz_zip_reader_extract_file_to_heap() failed!");
|
||||||
mz_zip_reader_end(&zip_archive);
|
mz_zip_reader_end(&zip_archive);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -872,13 +874,13 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
|
|||||||
// Save to File.
|
// Save to File.
|
||||||
zw = std::string(archive_filename);
|
zw = std::string(archive_filename);
|
||||||
zw = _target_directory + zw;
|
zw = _target_directory + zw;
|
||||||
printf("Filename to extract: %s", zw.c_str());
|
ESP_LOGD(TAG, "Filename to extract: %s", zw.c_str());
|
||||||
FILE* fpTargetFile = OpenFileAndWait(zw.c_str(), "wb");
|
FILE* fpTargetFile = OpenFileAndWait(zw.c_str(), "wb");
|
||||||
fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
|
fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
|
||||||
fclose(fpTargetFile);
|
fclose(fpTargetFile);
|
||||||
|
|
||||||
printf("Successfully extracted file \"%s\", size %u\n", archive_filename, (uint)uncomp_size);
|
ESP_LOGD(TAG, "Successfully extracted file \"%s\", size %u", archive_filename, (uint)uncomp_size);
|
||||||
// printf("File data: \"%s\"\n", (const char*)p);
|
// ESP_LOGD(TAG, "File data: \"%s\"", (const char*)p);
|
||||||
|
|
||||||
// We're done.
|
// We're done.
|
||||||
mz_free(p);
|
mz_free(p);
|
||||||
@@ -888,7 +890,7 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
|
|||||||
mz_zip_reader_end(&zip_archive);
|
mz_zip_reader_end(&zip_archive);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Success.\n");
|
ESP_LOGD(TAG, "Success.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -925,7 +927,7 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
|
|||||||
// strcpy(zw, serverprefix);
|
// strcpy(zw, serverprefix);
|
||||||
// zw[strlen(serverprefix)] = '*';
|
// zw[strlen(serverprefix)] = '*';
|
||||||
// zw[strlen(serverprefix)+1] = '\0';
|
// zw[strlen(serverprefix)+1] = '\0';
|
||||||
// printf("zw: %s\n", zw);
|
// ESP_LOGD(TAG, "zw: %s", zw);
|
||||||
httpd_uri_t file_download = {
|
httpd_uri_t file_download = {
|
||||||
.uri = "/fileserver*", // Match all URIs of type /path/to/file
|
.uri = "/fileserver*", // Match all URIs of type /path/to/file
|
||||||
.method = HTTP_GET,
|
.method = HTTP_GET,
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ static void infinite_loop(void)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
ESP_LOGI(TAGPARTOTA, "When a new firmware is available on the server, press the reset button to download it");
|
ESP_LOGI(TAGPARTOTA, "When a new firmware is available on the server, press the reset button to download it");
|
||||||
while(1) {
|
while(1) {
|
||||||
ESP_LOGI(TAGPARTOTA, "Waiting for a new firmware ... %d", ++i);
|
ESP_LOGI(TAGPARTOTA, "Waiting for a new firmware... %d", ++i);
|
||||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,8 +219,7 @@ static bool diagnostic(void)
|
|||||||
|
|
||||||
void CheckOTAUpdate(void)
|
void CheckOTAUpdate(void)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAGPARTOTA, "Start CheckOTAUpdateCheck ...");
|
ESP_LOGI(TAGPARTOTA, "Start CheckOTAUpdateCheck...");
|
||||||
printf("Start CheckOTAUpdateCheck ...\n");
|
|
||||||
|
|
||||||
uint8_t sha_256[HASH_LEN] = { 0 };
|
uint8_t sha_256[HASH_LEN] = { 0 };
|
||||||
esp_partition_t partition;
|
esp_partition_t partition;
|
||||||
@@ -249,31 +248,29 @@ void CheckOTAUpdate(void)
|
|||||||
switch (res_stat_partition)
|
switch (res_stat_partition)
|
||||||
{
|
{
|
||||||
case ESP_OK:
|
case ESP_OK:
|
||||||
printf("CheckOTAUpdate Partition: ESP_OK\n");
|
ESP_LOGD(TAGPARTOTA, "CheckOTAUpdate Partition: ESP_OK");
|
||||||
if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK) {
|
if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK) {
|
||||||
if (ota_state == ESP_OTA_IMG_PENDING_VERIFY) {
|
if (ota_state == ESP_OTA_IMG_PENDING_VERIFY) {
|
||||||
// run diagnostic function ...
|
// run diagnostic function ...
|
||||||
bool diagnostic_is_ok = diagnostic();
|
bool diagnostic_is_ok = diagnostic();
|
||||||
if (diagnostic_is_ok) {
|
if (diagnostic_is_ok) {
|
||||||
ESP_LOGI(TAGPARTOTA, "Diagnostics completed successfully! Continuing execution ...");
|
ESP_LOGI(TAGPARTOTA, "Diagnostics completed successfully! Continuing execution...");
|
||||||
printf("Diagnostics completed successfully! Continuing execution ...\n");
|
|
||||||
esp_ota_mark_app_valid_cancel_rollback();
|
esp_ota_mark_app_valid_cancel_rollback();
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGE(TAGPARTOTA, "Diagnostics failed! Start rollback to the previous version ...");
|
ESP_LOGE(TAGPARTOTA, "Diagnostics failed! Start rollback to the previous version...");
|
||||||
printf("Diagnostics failed! Start rollback to the previous version ...\n");
|
|
||||||
esp_ota_mark_app_invalid_rollback_and_reboot();
|
esp_ota_mark_app_invalid_rollback_and_reboot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_INVALID_ARG:
|
case ESP_ERR_INVALID_ARG:
|
||||||
printf("CheckOTAUpdate Partition: ESP_ERR_INVALID_ARG\n");
|
ESP_LOGD(TAGPARTOTA, "CheckOTAUpdate Partition: ESP_ERR_INVALID_ARG");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_NOT_SUPPORTED:
|
case ESP_ERR_NOT_SUPPORTED:
|
||||||
printf("CheckOTAUpdate Partition: ESP_ERR_NOT_SUPPORTED\n");
|
ESP_LOGD(TAGPARTOTA, "CheckOTAUpdate Partition: ESP_ERR_NOT_SUPPORTED");
|
||||||
break;
|
break;
|
||||||
case ESP_ERR_NOT_FOUND:
|
case ESP_ERR_NOT_FOUND:
|
||||||
printf("CheckOTAUpdate Partition: ESP_ERR_NOT_FOUND\n");
|
ESP_LOGD(TAGPARTOTA, "CheckOTAUpdate Partition: ESP_ERR_NOT_FOUND");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK) {
|
if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK) {
|
||||||
@@ -281,12 +278,10 @@ void CheckOTAUpdate(void)
|
|||||||
// run diagnostic function ...
|
// run diagnostic function ...
|
||||||
bool diagnostic_is_ok = diagnostic();
|
bool diagnostic_is_ok = diagnostic();
|
||||||
if (diagnostic_is_ok) {
|
if (diagnostic_is_ok) {
|
||||||
ESP_LOGI(TAGPARTOTA, "Diagnostics completed successfully! Continuing execution ...");
|
ESP_LOGI(TAGPARTOTA, "Diagnostics completed successfully! Continuing execution...");
|
||||||
printf("Diagnostics completed successfully! Continuing execution ...\n");
|
|
||||||
esp_ota_mark_app_valid_cancel_rollback();
|
esp_ota_mark_app_valid_cancel_rollback();
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGE(TAGPARTOTA, "Diagnostics failed! Start rollback to the previous version ...");
|
ESP_LOGE(TAGPARTOTA, "Diagnostics failed! Start rollback to the previous version...");
|
||||||
printf("Diagnostics failed! Start rollback to the previous version ...\n");
|
|
||||||
esp_ota_mark_app_invalid_rollback_and_reboot();
|
esp_ota_mark_app_invalid_rollback_and_reboot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,24 +306,24 @@ esp_err_t handler_ota_update(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(TAGPARTOTA, "Query: %s", _query);
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
||||||
{
|
{
|
||||||
printf("task is found: "); printf(_valuechar); printf("\n");
|
ESP_LOGD(TAGPARTOTA, "task is found: %s", _valuechar);
|
||||||
_task = std::string(_valuechar);
|
_task = std::string(_valuechar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "file", _filename, 100) == ESP_OK)
|
if (httpd_query_key_value(_query, "file", _filename, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
fn.append(_filename);
|
fn.append(_filename);
|
||||||
printf("File: "); printf(fn.c_str()); printf("\n");
|
ESP_LOGD(TAGPARTOTA, "File: %s", fn.c_str());
|
||||||
}
|
}
|
||||||
if (httpd_query_key_value(_query, "delete", _filename, 100) == ESP_OK)
|
if (httpd_query_key_value(_query, "delete", _filename, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
fn.append(_filename);
|
fn.append(_filename);
|
||||||
_file_del = true;
|
_file_del = true;
|
||||||
printf("Delete Default File: "); printf(fn.c_str()); printf("\n");
|
ESP_LOGD(TAGPARTOTA, "Delete Default File: %s", fn.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -394,7 +389,7 @@ esp_err_t handler_ota_update(httpd_req_t *req)
|
|||||||
std::string zw = "reboot\n";
|
std::string zw = "reboot\n";
|
||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
httpd_resp_sendstr_chunk(req, NULL);
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
printf("Send reboot\n");
|
ESP_LOGD(TAGPARTOTA, "Send reboot");
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,7 +413,7 @@ esp_err_t handler_ota_update(httpd_req_t *req)
|
|||||||
|
|
||||||
if (_task.compare("unziphtml") == 0)
|
if (_task.compare("unziphtml") == 0)
|
||||||
{
|
{
|
||||||
printf("Task unziphmtl\n");
|
ESP_LOGD(TAGPARTOTA, "Task unziphtml");
|
||||||
std::string in, out, zw;
|
std::string in, out, zw;
|
||||||
|
|
||||||
in = "/sdcard/firmware/html.zip";
|
in = "/sdcard/firmware/html.zip";
|
||||||
@@ -435,22 +430,22 @@ esp_err_t handler_ota_update(httpd_req_t *req)
|
|||||||
|
|
||||||
if (_file_del)
|
if (_file_del)
|
||||||
{
|
{
|
||||||
printf("Delete !! _file_del: %s\n", fn.c_str());
|
ESP_LOGD(TAGPARTOTA, "Delete !! _file_del: %s", fn.c_str());
|
||||||
struct stat file_stat;
|
struct stat file_stat;
|
||||||
int _result = stat(fn.c_str(), &file_stat);
|
int _result = stat(fn.c_str(), &file_stat);
|
||||||
printf("Ergebnis %d\n", _result);
|
ESP_LOGD(TAGPARTOTA, "Ergebnis %d\n", _result);
|
||||||
if (_result == 0) {
|
if (_result == 0) {
|
||||||
printf("Deleting file : %s\n", fn.c_str());
|
ESP_LOGD(TAGPARTOTA, "Deleting file : %s", fn.c_str());
|
||||||
/* Delete file */
|
/* Delete file */
|
||||||
unlink(fn.c_str());
|
unlink(fn.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("File does not exist: %s\n", fn.c_str());
|
ESP_LOGD(TAGPARTOTA, "File does not exist: %s", fn.c_str());
|
||||||
}
|
}
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
std::string zw = "file deleted\n";
|
std::string zw = "file deleted\n";
|
||||||
printf((zw + "\n").c_str());
|
ESP_LOGD(TAGPARTOTA, "%s", zw.c_str());
|
||||||
httpd_resp_send(req, zw.c_str(), strlen(zw.c_str()));
|
httpd_resp_send(req, zw.c_str(), strlen(zw.c_str()));
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
static const char *TAG = "class_flow";
|
||||||
|
|
||||||
|
|
||||||
void ClassFlow::SetInitialParameter(void)
|
void ClassFlow::SetInitialParameter(void)
|
||||||
@@ -105,7 +107,7 @@ std::string ClassFlow::GetParameterName(std::string _input)
|
|||||||
{
|
{
|
||||||
_param = _input;
|
_param = _input;
|
||||||
}
|
}
|
||||||
// printf("Parameter: %s, Pospunkt: %d\n", _param.c_str(), _pospunkt);
|
// ESP_LOGD(TAG, "Parameter: %s, Pospunkt: %d", _param.c_str(), _pospunkt);
|
||||||
return _param;
|
return _param;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,10 +123,10 @@ bool ClassFlow::getNextLine(FILE* pfile, string *rt)
|
|||||||
if (!fgets(zw, 1024, pfile))
|
if (!fgets(zw, 1024, pfile))
|
||||||
{
|
{
|
||||||
*rt = "";
|
*rt = "";
|
||||||
printf("END OF FILE\n");
|
ESP_LOGD(TAG, "END OF FILE");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
printf("%s", zw);
|
ESP_LOGD(TAG, "%s", zw);
|
||||||
*rt = zw;
|
*rt = zw;
|
||||||
*rt = trim(*rt);
|
*rt = trim(*rt);
|
||||||
while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph
|
while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph
|
||||||
@@ -132,7 +134,7 @@ bool ClassFlow::getNextLine(FILE* pfile, string *rt)
|
|||||||
*rt = "";
|
*rt = "";
|
||||||
if (!fgets(zw, 1024, pfile))
|
if (!fgets(zw, 1024, pfile))
|
||||||
return false;
|
return false;
|
||||||
printf("%s", zw);
|
ESP_LOGD(TAG, "%s", zw);
|
||||||
*rt = zw;
|
*rt = zw;
|
||||||
*rt = trim(*rt);
|
*rt = trim(*rt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,13 @@
|
|||||||
#include "ClassFlow.h"
|
#include "ClassFlow.h"
|
||||||
|
|
||||||
#include "CRotateImage.h"
|
#include "CRotateImage.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const char *TAG = "class_flow_alignment";
|
||||||
|
|
||||||
bool AlignmentExtendedDebugging = true;
|
bool AlignmentExtendedDebugging = true;
|
||||||
|
|
||||||
@@ -48,7 +50,7 @@ ClassFlowAlignment::ClassFlowAlignment(std::vector<ClassFlow*>* lfc)
|
|||||||
|
|
||||||
if (!ImageBasis) // die Funktion Bilder aufnehmen existiert nicht --> muss erst erzeugt werden NUR ZU TESTZWECKEN
|
if (!ImageBasis) // die Funktion Bilder aufnehmen existiert nicht --> muss erst erzeugt werden NUR ZU TESTZWECKEN
|
||||||
{
|
{
|
||||||
if (AlignmentExtendedDebugging) printf("CImageBasis had to be created\n");
|
if (AlignmentExtendedDebugging) ESP_LOGD(TAG, "CImageBasis had to be created");
|
||||||
ImageBasis = new CImageBasis(namerawimage);
|
ImageBasis = new CImageBasis(namerawimage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +176,7 @@ bool ClassFlowAlignment::doFlow(string time)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (initialmirror){
|
if (initialmirror){
|
||||||
printf("do mirror\n");
|
ESP_LOGD(TAG, "do mirror");
|
||||||
rt.Mirror();
|
rt.Mirror();
|
||||||
if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/mirror.jpg"));
|
if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/mirror.jpg"));
|
||||||
}
|
}
|
||||||
@@ -279,7 +281,7 @@ bool ClassFlowAlignment::LoadReferenceAlignmentValues(void)
|
|||||||
// LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues01");
|
// LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues01");
|
||||||
|
|
||||||
fgets(zw, 1024, pFile);
|
fgets(zw, 1024, pFile);
|
||||||
printf("%s", zw);
|
ESP_LOGD(TAG, "%s", zw);
|
||||||
|
|
||||||
// zwvalue = "LoadReferenceAlignmentValues Time: " + std::string(zw);
|
// zwvalue = "LoadReferenceAlignmentValues Time: " + std::string(zw);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "CTfLiteClass.h"
|
#include "CTfLiteClass.h"
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
static const char* TAG = "flow_analog";
|
static const char* TAG = "flow_analog";
|
||||||
|
|
||||||
@@ -311,7 +312,7 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
{
|
{
|
||||||
disabled = true;
|
disabled = true;
|
||||||
while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
|
while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
|
||||||
printf("[Analog/Digit] is disabled !!!\n");
|
ESP_LOGD(TAG, "[Analog/Digit] is disabled!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,7 +430,7 @@ general* ClassFlowCNNGeneral::GetGENERAL(string _name, bool _create = true)
|
|||||||
|
|
||||||
_ret->ROI.push_back(neuroi);
|
_ret->ROI.push_back(neuroi);
|
||||||
|
|
||||||
printf("GetGENERAL - GENERAL %s - roi %s - CCW: %d\n", _analog.c_str(), _roi.c_str(), neuroi->CCW);
|
ESP_LOGD(TAG, "GetGENERAL - GENERAL %s - roi %s - CCW: %d", _analog.c_str(), _roi.c_str(), neuroi->CCW);
|
||||||
|
|
||||||
return _ret;
|
return _ret;
|
||||||
}
|
}
|
||||||
@@ -488,7 +489,7 @@ bool ClassFlowCNNGeneral::doAlignAndCut(string time)
|
|||||||
for (int _ana = 0; _ana < GENERAL.size(); ++_ana)
|
for (int _ana = 0; _ana < GENERAL.size(); ++_ana)
|
||||||
for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i)
|
for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i)
|
||||||
{
|
{
|
||||||
printf("General %d - Align&Cut\n", i);
|
ESP_LOGD(TAG, "General %d - Align&Cut", i);
|
||||||
|
|
||||||
caic->CutAndSave(GENERAL[_ana]->ROI[i]->posx, GENERAL[_ana]->ROI[i]->posy, GENERAL[_ana]->ROI[i]->deltax, GENERAL[_ana]->ROI[i]->deltay, GENERAL[_ana]->ROI[i]->image_org);
|
caic->CutAndSave(GENERAL[_ana]->ROI[i]->posx, GENERAL[_ana]->ROI[i]->posy, GENERAL[_ana]->ROI[i]->deltax, GENERAL[_ana]->ROI[i]->deltay, GENERAL[_ana]->ROI[i]->image_org);
|
||||||
if (SaveAllFiles)
|
if (SaveAllFiles)
|
||||||
@@ -545,9 +546,9 @@ bool ClassFlowCNNGeneral::getNetworkParameter()
|
|||||||
CTfLiteClass *tflite = new CTfLiteClass;
|
CTfLiteClass *tflite = new CTfLiteClass;
|
||||||
string zwcnn = "/sdcard" + cnnmodelfile;
|
string zwcnn = "/sdcard" + cnnmodelfile;
|
||||||
zwcnn = FormatFileName(zwcnn);
|
zwcnn = FormatFileName(zwcnn);
|
||||||
printf(zwcnn.c_str());printf("\n");
|
ESP_LOGD(TAG, "%s", zwcnn.c_str());
|
||||||
if (!tflite->LoadModel(zwcnn)) {
|
if (!tflite->LoadModel(zwcnn)) {
|
||||||
printf("Can't read model file /sdcard%s\n", cnnmodelfile.c_str());
|
ESP_LOGD(TAG, "Can't read model file /sdcard%s", cnnmodelfile.c_str());
|
||||||
LogFile.WriteToFile("Cannot load model");
|
LogFile.WriteToFile("Cannot load model");
|
||||||
delete tflite;
|
delete tflite;
|
||||||
return false;
|
return false;
|
||||||
@@ -566,37 +567,37 @@ bool ClassFlowCNNGeneral::getNetworkParameter()
|
|||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
CNNType = Analogue;
|
CNNType = Analogue;
|
||||||
printf("TFlite-Type set to Analogue\n");
|
ESP_LOGD(TAG, "TFlite-Type set to Analogue");
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
CNNType = DoubleHyprid10;
|
CNNType = DoubleHyprid10;
|
||||||
printf("TFlite-Type set to DoubleHyprid10\n");
|
ESP_LOGD(TAG, "TFlite-Type set to DoubleHyprid10");
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
CNNType = Digital;
|
CNNType = Digital;
|
||||||
printf("TFlite-Type set to Digital\n");
|
ESP_LOGD(TAG, "TFlite-Type set to Digital");
|
||||||
break;
|
break;
|
||||||
/* case 20:
|
/* case 20:
|
||||||
CNNType = DigitalHyprid10;
|
CNNType = DigitalHyprid10;
|
||||||
printf("TFlite-Type set to DigitalHyprid10\n");
|
ESP_LOGD(TAG, "TFlite-Type set to DigitalHyprid10");
|
||||||
break;
|
break;
|
||||||
*/
|
*/
|
||||||
// case 22:
|
// case 22:
|
||||||
// CNNType = DigitalHyprid;
|
// CNNType = DigitalHyprid;
|
||||||
// printf("TFlite-Type set to DigitalHyprid\n");
|
// ESP_LOGD(TAG, "TFlite-Type set to DigitalHyprid");
|
||||||
// break;
|
// break;
|
||||||
case 100:
|
case 100:
|
||||||
if (modelxsize==32 && modelysize == 32) {
|
if (modelxsize==32 && modelysize == 32) {
|
||||||
CNNType = Analogue100;
|
CNNType = Analogue100;
|
||||||
printf("TFlite-Type set to Analogue100\n");
|
ESP_LOGD(TAG, "TFlite-Type set to Analogue100");
|
||||||
} else {
|
} else {
|
||||||
CNNType = Digital100;
|
CNNType = Digital100;
|
||||||
printf("TFlite-Type set to Digital\n");
|
ESP_LOGD(TAG, "TFlite-Type set to Digital");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogFile.WriteToFile("ERROR ERROR ERROR - tflite passt nicht zur Firmware - ERROR ERROR ERROR (outout_dimension=" + std::to_string(_anzoutputdimensions) + ")");
|
LogFile.WriteToFile("ERROR ERROR ERROR - tflite passt nicht zur Firmware - ERROR ERROR ERROR (outout_dimension=" + std::to_string(_anzoutputdimensions) + ")");
|
||||||
printf("ERROR ERROR ERROR - tflite passt nicht zur Firmware - ERROR ERROR ERROR\n");
|
ESP_LOGD(TAG, "ERROR ERROR ERROR - tflite passt nicht zur Firmware - ERROR ERROR ERROR");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -614,9 +615,9 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
CTfLiteClass *tflite = new CTfLiteClass;
|
CTfLiteClass *tflite = new CTfLiteClass;
|
||||||
string zwcnn = "/sdcard" + cnnmodelfile;
|
string zwcnn = "/sdcard" + cnnmodelfile;
|
||||||
zwcnn = FormatFileName(zwcnn);
|
zwcnn = FormatFileName(zwcnn);
|
||||||
printf(zwcnn.c_str());printf("\n");
|
ESP_LOGD(TAG, "%s", zwcnn.c_str());
|
||||||
if (!tflite->LoadModel(zwcnn)) {
|
if (!tflite->LoadModel(zwcnn)) {
|
||||||
printf("Can't read model file /sdcard%s\n", cnnmodelfile.c_str());
|
ESP_LOGD(TAG, "Can't read model file /sdcard%s", cnnmodelfile.c_str());
|
||||||
LogFile.WriteToFile("Cannot load model");
|
LogFile.WriteToFile("Cannot load model");
|
||||||
|
|
||||||
delete tflite;
|
delete tflite;
|
||||||
@@ -628,7 +629,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i)
|
for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i)
|
||||||
{
|
{
|
||||||
printf("General %d - TfLite\n", i);
|
ESP_LOGD(TAG, "General %d - TfLite", i);
|
||||||
|
|
||||||
switch (CNNType) {
|
switch (CNNType) {
|
||||||
case Analogue:
|
case Analogue:
|
||||||
@@ -649,7 +650,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
else
|
else
|
||||||
GENERAL[_ana]->ROI[i]->result_float = result * 10;
|
GENERAL[_ana]->ROI[i]->result_float = result * 10;
|
||||||
|
|
||||||
printf("Result General(Analog)%i - CCW: %d - %f\n", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float);
|
ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float);
|
||||||
if (isLogImage)
|
if (isLogImage)
|
||||||
LogImage(logPath, GENERAL[_ana]->ROI[i]->name, &GENERAL[_ana]->ROI[i]->result_float, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
|
LogImage(logPath, GENERAL[_ana]->ROI[i]->name, &GENERAL[_ana]->ROI[i]->result_float, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
|
||||||
} break;
|
} break;
|
||||||
@@ -658,7 +659,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
{
|
{
|
||||||
GENERAL[_ana]->ROI[i]->result_klasse = 0;
|
GENERAL[_ana]->ROI[i]->result_klasse = 0;
|
||||||
GENERAL[_ana]->ROI[i]->result_klasse = tflite->GetClassFromImageBasis(GENERAL[_ana]->ROI[i]->image);
|
GENERAL[_ana]->ROI[i]->result_klasse = tflite->GetClassFromImageBasis(GENERAL[_ana]->ROI[i]->image);
|
||||||
printf("Result General(Digit)%i: %d\n", i, GENERAL[_ana]->ROI[i]->result_klasse);
|
ESP_LOGD(TAG, "Result General(Digit)%i: %d", i, GENERAL[_ana]->ROI[i]->result_klasse);
|
||||||
|
|
||||||
if (isLogImage)
|
if (isLogImage)
|
||||||
{
|
{
|
||||||
@@ -695,7 +696,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
else
|
else
|
||||||
GENERAL[_ana]->ROI[i]->result_float = fmod((double) _num + (((double)_nachkomma)-5)/10 + (double) 10, 10);
|
GENERAL[_ana]->ROI[i]->result_float = fmod((double) _num + (((double)_nachkomma)-5)/10 + (double) 10, 10);
|
||||||
|
|
||||||
printf("Result General(DigitalHyprid)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
|
ESP_LOGD(TAG, "Result General(DigitalHyprid)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
|
||||||
_zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float);
|
_zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float);
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile(_zwres);
|
if (debugdetailgeneral) LogFile.WriteToFile(_zwres);
|
||||||
|
|
||||||
@@ -732,7 +733,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
|
|
||||||
GENERAL[_ana]->ROI[i]->result_float = fmod((double) _num + (((double)_nachkomma)-5)/10 + (double) 10, 10);
|
GENERAL[_ana]->ROI[i]->result_float = fmod((double) _num + (((double)_nachkomma)-5)/10 + (double) 10, 10);
|
||||||
|
|
||||||
printf("Result General(DigitalHyprid)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
|
ESP_LOGD(TAG, "Result General(DigitalHyprid)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
|
||||||
_zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float);
|
_zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float);
|
||||||
if (debugdetailgeneral) LogFile.WriteToFile(_zwres);
|
if (debugdetailgeneral) LogFile.WriteToFile(_zwres);
|
||||||
|
|
||||||
@@ -792,7 +793,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
string zw = "_num (p, m): " + to_string(_num) + " " + to_string(_numplus) + " " + to_string(_numminus);
|
string zw = "_num (p, m): " + to_string(_num) + " " + to_string(_numplus) + " " + to_string(_numminus);
|
||||||
zw = zw + " _val (p, m): " + to_string(_val) + " " + to_string(_valplus) + " " + to_string(_valminus);
|
zw = zw + " _val (p, m): " + to_string(_val) + " " + to_string(_valplus) + " " + to_string(_valminus);
|
||||||
zw = zw + " result: " + to_string(result) + " _fit: " + to_string(_fit);
|
zw = zw + " result: " + to_string(result) + " _fit: " + to_string(_fit);
|
||||||
printf("details cnn: %s\n", zw.c_str());
|
ESP_LOGD(TAG, "details cnn: %s", zw.c_str());
|
||||||
LogFile.WriteToFile(zw);
|
LogFile.WriteToFile(zw);
|
||||||
|
|
||||||
|
|
||||||
@@ -804,7 +805,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
result = -1;
|
result = -1;
|
||||||
_result_save_file+= 100; // Für den Fall, dass fit nicht ausreichend, soll trotzdem das Ergebnis mit "-10x.y" abgespeichert werden.
|
_result_save_file+= 100; // Für den Fall, dass fit nicht ausreichend, soll trotzdem das Ergebnis mit "-10x.y" abgespeichert werden.
|
||||||
string zw = "Value Rejected due to Threshold (Fit: " + to_string(_fit) + "Threshold: " + to_string(CNNGoodThreshold);
|
string zw = "Value Rejected due to Threshold (Fit: " + to_string(_fit) + "Threshold: " + to_string(CNNGoodThreshold);
|
||||||
printf("Value Rejected due to Threshold (Fit: %f, Threshold: %f\n", _fit, CNNGoodThreshold);
|
ESP_LOGD(TAG, "Value Rejected due to Threshold (Fit: %f, Threshold: %f", _fit, CNNGoodThreshold);
|
||||||
LogFile.WriteToFile(zw);
|
LogFile.WriteToFile(zw);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -814,7 +815,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
|
|
||||||
|
|
||||||
GENERAL[_ana]->ROI[i]->result_float = result;
|
GENERAL[_ana]->ROI[i]->result_float = result;
|
||||||
printf("Result General(Analog)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float);
|
ESP_LOGD(TAG, "Result General(Analog)%i: %f", i, GENERAL[_ana]->ROI[i]->result_float);
|
||||||
|
|
||||||
if (isLogImage)
|
if (isLogImage)
|
||||||
{
|
{
|
||||||
@@ -852,7 +853,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
|
|||||||
|
|
||||||
GENERAL[_ana]->ROI[i]->isReject = false;
|
GENERAL[_ana]->ROI[i]->isReject = false;
|
||||||
|
|
||||||
printf("Result General(Analog)%i - CCW: %d - %f\n", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float);
|
ESP_LOGD(TAG, "Result General(Analog)%i - CCW: %d - %f", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float);
|
||||||
|
|
||||||
if (isLogImage)
|
if (isLogImage)
|
||||||
{
|
{
|
||||||
@@ -898,7 +899,7 @@ std::vector<HTMLInfo*> ClassFlowCNNGeneral::GetHTMLInfo()
|
|||||||
for (int _ana = 0; _ana < GENERAL.size(); ++_ana)
|
for (int _ana = 0; _ana < GENERAL.size(); ++_ana)
|
||||||
for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i)
|
for (int i = 0; i < GENERAL[_ana]->ROI.size(); ++i)
|
||||||
{
|
{
|
||||||
printf("Image: %d\n", (int) GENERAL[_ana]->ROI[i]->image);
|
ESP_LOGD(TAG, "Image: %d", (int) GENERAL[_ana]->ROI[i]->image);
|
||||||
if (GENERAL[_ana]->ROI[i]->image)
|
if (GENERAL[_ana]->ROI[i]->image)
|
||||||
{
|
{
|
||||||
if (GENERAL[_ana]->name == "default")
|
if (GENERAL[_ana]->name == "default")
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ static const char* TAG = "flow_controll";
|
|||||||
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
|
||||||
std::string _classname = "";
|
std::string _classname = "";
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
// printf("_stepname: %s\n", _stepname.c_str());
|
// ESP_LOGD(TAG, "_stepname: %s", _stepname.c_str());
|
||||||
if ((_stepname.compare("[MakeImage]") == 0) || (_stepname.compare(";[MakeImage]") == 0)){
|
if ((_stepname.compare("[MakeImage]") == 0) || (_stepname.compare(";[MakeImage]") == 0)){
|
||||||
_classname = "ClassFlowMakeImage";
|
_classname = "ClassFlowMakeImage";
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ std::vector<HTMLInfo*> ClassFlowControll::GetAllDigital()
|
|||||||
{
|
{
|
||||||
if (flowdigit)
|
if (flowdigit)
|
||||||
{
|
{
|
||||||
printf("ClassFlowControll::GetAllDigital - flowdigit != NULL\n");
|
ESP_LOGD(TAG, "ClassFlowControll::GetAllDigital - flowdigit != NULL");
|
||||||
return flowdigit->GetHTMLInfo();
|
return flowdigit->GetHTMLInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ void ClassFlowControll::InitFlow(std::string config)
|
|||||||
if (pFile != NULL)
|
if (pFile != NULL)
|
||||||
{
|
{
|
||||||
fgets(zw, 1024, pFile);
|
fgets(zw, 1024, pFile);
|
||||||
printf("%s", zw);
|
ESP_LOGD(TAG, "%s", zw);
|
||||||
line = std::string(zw);
|
line = std::string(zw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ void ClassFlowControll::InitFlow(std::string config)
|
|||||||
cfc = CreateClassFlow(line);
|
cfc = CreateClassFlow(line);
|
||||||
if (cfc)
|
if (cfc)
|
||||||
{
|
{
|
||||||
printf("Start ReadParameter (%s)\n", line.c_str());
|
ESP_LOGD(TAG, "Start ReadParameter (%s)", line.c_str());
|
||||||
cfc->ReadParameter(pFile, line);
|
cfc->ReadParameter(pFile, line);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -247,7 +247,7 @@ void ClassFlowControll::InitFlow(std::string config)
|
|||||||
line = "";
|
line = "";
|
||||||
if (fgets(zw, 1024, pFile) && !feof(pFile))
|
if (fgets(zw, 1024, pFile) && !feof(pFile))
|
||||||
{
|
{
|
||||||
printf("Read: %s", zw);
|
ESP_LOGD(TAG, "Read: %s", zw);
|
||||||
line = std::string(zw);
|
line = std::string(zw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -362,7 +362,7 @@ string ClassFlowControll::getReadoutAll(int _type)
|
|||||||
if (i < (*numbers).size()-1)
|
if (i < (*numbers).size()-1)
|
||||||
out = out + "\r\n";
|
out = out + "\r\n";
|
||||||
}
|
}
|
||||||
// printf("OUT: %s", out.c_str());
|
// ESP_LOGD(TAG, "OUT: %s", out.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@@ -408,7 +408,7 @@ std::string ClassFlowControll::UpdatePrevalue(std::string _newvalue, std::string
|
|||||||
char* p;
|
char* p;
|
||||||
|
|
||||||
_newvalue = trim(_newvalue);
|
_newvalue = trim(_newvalue);
|
||||||
// printf("Input UpdatePreValue: %s\n", _newvalue.c_str());
|
// ESP_LOGD(TAG, "Input UpdatePreValue: %s", _newvalue.c_str());
|
||||||
|
|
||||||
if (_newvalue.compare("0.0") == 0)
|
if (_newvalue.compare("0.0") == 0)
|
||||||
{
|
{
|
||||||
@@ -493,7 +493,7 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
{
|
{
|
||||||
// reboot notwendig damit die neue wlan.ini auch benutzt wird !!!
|
// reboot notwendig damit die neue wlan.ini auch benutzt wird !!!
|
||||||
fclose(pfile);
|
fclose(pfile);
|
||||||
printf("do reboot\n");
|
ESP_LOGD(TAG, "do reboot");
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile("Reboot to activate new HOSTNAME.");
|
LogFile.WriteToFile("Reboot to activate new HOSTNAME.");
|
||||||
esp_restart();
|
esp_restart();
|
||||||
@@ -558,7 +558,7 @@ esp_err_t ClassFlowControll::SendRawJPG(httpd_req_t *req)
|
|||||||
|
|
||||||
esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
||||||
{
|
{
|
||||||
printf("ClassFlowControll::GetJPGStream %s\n", _fn.c_str());
|
ESP_LOGD(TAG, "ClassFlowControll::GetJPGStream %s", _fn.c_str());
|
||||||
|
|
||||||
CImageBasis *_send = NULL;
|
CImageBasis *_send = NULL;
|
||||||
esp_err_t result = ESP_FAIL;
|
esp_err_t result = ESP_FAIL;
|
||||||
@@ -566,7 +566,7 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
|
|
||||||
if (flowalignment == NULL)
|
if (flowalignment == NULL)
|
||||||
{
|
{
|
||||||
printf("Can't continue, flowalignment is NULL\n");
|
ESP_LOGD(TAG, "Can't continue, flowalignment is NULL");
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,7 +589,7 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
std::vector<HTMLInfo*> htmlinfo;
|
std::vector<HTMLInfo*> htmlinfo;
|
||||||
htmlinfo = GetAllDigital();
|
htmlinfo = GetAllDigital();
|
||||||
printf("After getClassFlowControll::GetAllDigital\n");
|
ESP_LOGD(TAG, "After getClassFlowControll::GetAllDigital");
|
||||||
|
|
||||||
for (int i = 0; i < htmlinfo.size(); ++i)
|
for (int i = 0; i < htmlinfo.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ extern "C" {
|
|||||||
#include "time_sntp.h"
|
#include "time_sntp.h"
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
#include "CImageBasis.h"
|
#include "CImageBasis.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
|
||||||
ClassFlowImage::ClassFlowImage(const char* logTag)
|
ClassFlowImage::ClassFlowImage(const char* logTag)
|
||||||
{
|
{
|
||||||
@@ -79,7 +81,7 @@ void ClassFlowImage::LogImage(string logPath, string name, float *resultFloat, i
|
|||||||
nm = FormatFileName(nm);
|
nm = FormatFileName(nm);
|
||||||
string output = "/sdcard/img_tmp/" + name + ".jpg";
|
string output = "/sdcard/img_tmp/" + name + ".jpg";
|
||||||
output = FormatFileName(output);
|
output = FormatFileName(output);
|
||||||
printf("save to file: %s\n", nm.c_str());
|
ESP_LOGD(logTag, "save to file: %s", nm.c_str());
|
||||||
_img->SaveToFile(nm);
|
_img->SaveToFile(nm);
|
||||||
// CopyFile(output, nm);
|
// CopyFile(output, nm);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,12 @@
|
|||||||
#include "time_sntp.h"
|
#include "time_sntp.h"
|
||||||
#include "interface_influxdb.h"
|
#include "interface_influxdb.h"
|
||||||
#include "ClassFlowPostProcessing.h"
|
#include "ClassFlowPostProcessing.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
static const char* TAG = "class_flow_influxDb";
|
||||||
|
|
||||||
void ClassFlowInfluxDB::SetInitialParameter(void)
|
void ClassFlowInfluxDB::SetInitialParameter(void)
|
||||||
{
|
{
|
||||||
uri = "";
|
uri = "";
|
||||||
@@ -76,7 +79,7 @@ bool ClassFlowInfluxDB::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
|
|
||||||
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
|
||||||
{
|
{
|
||||||
printf("while loop reading line: %s\n", aktparamgraph.c_str());
|
ESP_LOGD(TAG, "while loop reading line: %s", aktparamgraph.c_str());
|
||||||
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
zerlegt = this->ZerlegeZeile(aktparamgraph);
|
||||||
if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1))
|
if ((toUpper(zerlegt[0]) == "USER") && (zerlegt.size() > 1))
|
||||||
{
|
{
|
||||||
@@ -102,11 +105,11 @@ bool ClassFlowInfluxDB::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
|
|
||||||
if ((uri.length() > 0) && (database.length() > 0) && (measurement.length() > 0))
|
if ((uri.length() > 0) && (database.length() > 0) && (measurement.length() > 0))
|
||||||
{
|
{
|
||||||
printf("Init InfluxDB with uri: %s, measurement: %s, user: %s, password: %s\n", uri.c_str(), measurement.c_str(), user.c_str(), password.c_str());
|
ESP_LOGD(TAG, "Init InfluxDB with uri: %s, measurement: %s, user: %s, password: %s", uri.c_str(), measurement.c_str(), user.c_str(), password.c_str());
|
||||||
InfluxDBInit(uri, database, measurement, user, password);
|
InfluxDBInit(uri, database, measurement, user, password);
|
||||||
InfluxDBenable = true;
|
InfluxDBenable = true;
|
||||||
} else {
|
} else {
|
||||||
printf("InfluxDB init skipped as we are missing some parameters");
|
ESP_LOGD(TAG, "InfluxDB init skipped as we are missing some parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#define __HIDE_PASSWORD
|
#define __HIDE_PASSWORD
|
||||||
|
|
||||||
|
static const char *TAG = "class_flow_MQTT";
|
||||||
|
|
||||||
void ClassFlowMQTT::SetInitialParameter(void)
|
void ClassFlowMQTT::SetInitialParameter(void)
|
||||||
{
|
{
|
||||||
uri = "";
|
uri = "";
|
||||||
@@ -120,19 +122,19 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __HIDE_PASSWORD
|
#ifdef __HIDE_PASSWORD
|
||||||
printf("Init Read with uri: %s, clientname: %s, user: %s, password: XXXXXX, maintopic: %s\n", uri.c_str(), clientname.c_str(), user.c_str(), mainerrortopic.c_str());
|
ESP_LOGD(TAG, "Init Read with uri: %s, clientname: %s, user: %s, password: XXXXXX, maintopic: %s", uri.c_str(), clientname.c_str(), user.c_str(), mainerrortopic.c_str());
|
||||||
#else
|
#else
|
||||||
printf("Init Read with uri: %s, clientname: %s, user: %s, password: %s, maintopic: %s\n", uri.c_str(), clientname.c_str(), user.c_str(), password.c_str(), mainerrortopic.c_str());
|
ESP_LOGD(TAG, "Init Read with uri: %s, clientname: %s, user: %s, password: %s, maintopic: %s", uri.c_str(), clientname.c_str(), user.c_str(), password.c_str(), mainerrortopic.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!MQTTisConnected() && (uri.length() > 0) && (maintopic.length() > 0))
|
if (!MQTTisConnected() && (uri.length() > 0) && (maintopic.length() > 0))
|
||||||
{
|
{
|
||||||
printf("InitMQTTInit\n");
|
ESP_LOGD(TAG, "InitMQTTInit");
|
||||||
mainerrortopic = maintopic + "/connection";
|
mainerrortopic = maintopic + "/connection";
|
||||||
#ifdef __HIDE_PASSWORD
|
#ifdef __HIDE_PASSWORD
|
||||||
printf("Init MQTT with uri: %s, clientname: %s, user: %s, password: XXXXXXXX, maintopic: %s\n", uri.c_str(), clientname.c_str(), user.c_str(), mainerrortopic.c_str());
|
ESP_LOGD(TAG, "Init MQTT with uri: %s, clientname: %s, user: %s, password: XXXXXXXX, maintopic: %s", uri.c_str(), clientname.c_str(), user.c_str(), mainerrortopic.c_str());
|
||||||
#else
|
#else
|
||||||
printf("Init MQTT with uri: %s, clientname: %s, user: %s, password: %s, maintopic: %s\n", uri.c_str(), clientname.c_str(), user.c_str(), password.c_str(), mainerrortopic.c_str());
|
ESP_LOGD(TAG, "Init MQTT with uri: %s, clientname: %s, user: %s, password: %s, maintopic: %s", uri.c_str(), clientname.c_str(), user.c_str(), password.c_str(), mainerrortopic.c_str());
|
||||||
#endif
|
#endif
|
||||||
if (!MQTTInit(uri, clientname, user, password, mainerrortopic, keepAlive))
|
if (!MQTTInit(uri, clientname, user, password, mainerrortopic, keepAlive))
|
||||||
{ // Failed
|
{ // Failed
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "ClassControllCamera.h"
|
#include "ClassControllCamera.h"
|
||||||
|
|
||||||
#include "esp_wifi.h"
|
#include "esp_wifi.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ void ClassFlowMakeImage::takePictureWithFlash(int flashdauer)
|
|||||||
rawImage->width = image_width;
|
rawImage->width = image_width;
|
||||||
rawImage->height = image_height;
|
rawImage->height = image_height;
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
printf("Flashdauer: %d\n", flashdauer);
|
ESP_LOGD(TAG, "Flashdauer: %d", flashdauer);
|
||||||
Camera.CaptureToBasisImage(rawImage, flashdauer);
|
Camera.CaptureToBasisImage(rawImage, flashdauer);
|
||||||
time(&TimeImageTaken);
|
time(&TimeImageTaken);
|
||||||
localtime(&TimeImageTaken);
|
localtime(&TimeImageTaken);
|
||||||
@@ -145,7 +146,7 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
waitbeforepicture_store = waitbeforepicture;
|
waitbeforepicture_store = waitbeforepicture;
|
||||||
if (FixedExposure && (waitbeforepicture > 0))
|
if (FixedExposure && (waitbeforepicture > 0))
|
||||||
{
|
{
|
||||||
// printf("Fixed Exposure enabled!\n");
|
// ESP_LOGD(TAG, "Fixed Exposure enabled!");
|
||||||
int flashdauer = (int) (waitbeforepicture * 1000);
|
int flashdauer = (int) (waitbeforepicture * 1000);
|
||||||
Camera.EnableAutoExposure(flashdauer);
|
Camera.EnableAutoExposure(flashdauer);
|
||||||
waitbeforepicture = 0.2;
|
waitbeforepicture = 0.2;
|
||||||
|
|||||||
@@ -9,6 +9,11 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "time_sntp.h"
|
#include "time_sntp.h"
|
||||||
|
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
static const char* TAG = "class_flow_postproc";
|
||||||
|
|
||||||
//#define SERIAL_DEBUG // testing debug on serial enabled
|
//#define SERIAL_DEBUG // testing debug on serial enabled
|
||||||
|
|
||||||
|
|
||||||
@@ -72,10 +77,10 @@ string ClassFlowPostProcessing::GetPreValue(std::string _number)
|
|||||||
|
|
||||||
void ClassFlowPostProcessing::SetPreValue(double zw, string _numbers, bool _extern)
|
void ClassFlowPostProcessing::SetPreValue(double zw, string _numbers, bool _extern)
|
||||||
{
|
{
|
||||||
printf("SetPrevalue: %f, %s\n", zw, _numbers.c_str());
|
ESP_LOGD(TAG, "SetPrevalue: %f, %s", zw, _numbers.c_str());
|
||||||
for (int j = 0; j < NUMBERS.size(); ++j)
|
for (int j = 0; j < NUMBERS.size(); ++j)
|
||||||
{
|
{
|
||||||
// printf("Number %d, %s\n", j, NUMBERS[j]->name.c_str());
|
// ESP_LOGD(TAG, "Number %d, %s", j, NUMBERS[j]->name.c_str());
|
||||||
if (NUMBERS[j]->name == _numbers)
|
if (NUMBERS[j]->name == _numbers)
|
||||||
{
|
{
|
||||||
NUMBERS[j]->PreValue = zw;
|
NUMBERS[j]->PreValue = zw;
|
||||||
@@ -86,7 +91,7 @@ void ClassFlowPostProcessing::SetPreValue(double zw, string _numbers, bool _exte
|
|||||||
time(&(NUMBERS[j]->lastvalue));
|
time(&(NUMBERS[j]->lastvalue));
|
||||||
localtime(&(NUMBERS[j]->lastvalue));
|
localtime(&(NUMBERS[j]->lastvalue));
|
||||||
}
|
}
|
||||||
// printf("Found %d! - set to %f\n", j, NUMBERS[j]->PreValue);
|
// ESP_LOGD(TAG, "Found %d! - set to %f", j, NUMBERS[j]->PreValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UpdatePreValueINI = true;
|
UpdatePreValueINI = true;
|
||||||
@@ -110,7 +115,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
fgets(zw, 1024, pFile);
|
fgets(zw, 1024, pFile);
|
||||||
printf("Read line Prevalue.ini: %s", zw);
|
ESP_LOGD(TAG, "Read line Prevalue.ini: %s", zw);
|
||||||
zwtime = trim(std::string(zw));
|
zwtime = trim(std::string(zw));
|
||||||
if (zwtime.length() == 0)
|
if (zwtime.length() == 0)
|
||||||
return false;
|
return false;
|
||||||
@@ -161,7 +166,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
|||||||
_done = true;
|
_done = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Read line Prevalue.ini: %s", zw);
|
ESP_LOGD(TAG, "Read line Prevalue.ini: %s", zw);
|
||||||
zerlegt = HelperZerlegeZeile(trim(std::string(zw)), "\t");
|
zerlegt = HelperZerlegeZeile(trim(std::string(zw)), "\t");
|
||||||
if (zerlegt.size() > 1)
|
if (zerlegt.size() > 1)
|
||||||
{
|
{
|
||||||
@@ -177,7 +182,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
|||||||
{
|
{
|
||||||
fgets(zw, 1024, pFile);
|
fgets(zw, 1024, pFile);
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
printf("%s", zw);
|
ESP_LOGD(TAG, "%s", zw);
|
||||||
zwvalue = trim(std::string(zw));
|
zwvalue = trim(std::string(zw));
|
||||||
NUMBERS[0]->PreValue = stod(zwvalue.c_str());
|
NUMBERS[0]->PreValue = stod(zwvalue.c_str());
|
||||||
|
|
||||||
@@ -194,7 +199,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
|
|||||||
whenStart.tm_sec = ss;
|
whenStart.tm_sec = ss;
|
||||||
whenStart.tm_isdst = -1;
|
whenStart.tm_isdst = -1;
|
||||||
|
|
||||||
printf("TIME: %d, %d, %d, %d, %d, %d\n", whenStart.tm_year, whenStart.tm_mon, whenStart.tm_wday, whenStart.tm_hour, whenStart.tm_min, whenStart.tm_sec);
|
ESP_LOGD(TAG, "TIME: %d, %d, %d, %d, %d, %d", whenStart.tm_year, whenStart.tm_mon, whenStart.tm_wday, whenStart.tm_hour, whenStart.tm_min, whenStart.tm_sec);
|
||||||
|
|
||||||
NUMBERS[0]->lastvalue = mktime(&whenStart);
|
NUMBERS[0]->lastvalue = mktime(&whenStart);
|
||||||
|
|
||||||
@@ -236,10 +241,10 @@ void ClassFlowPostProcessing::SavePreValue()
|
|||||||
struct tm* timeinfo = localtime(&NUMBERS[j]->lastvalue);
|
struct tm* timeinfo = localtime(&NUMBERS[j]->lastvalue);
|
||||||
strftime(buffer, 80, PREVALUE_TIME_FORMAT_OUTPUT, timeinfo);
|
strftime(buffer, 80, PREVALUE_TIME_FORMAT_OUTPUT, timeinfo);
|
||||||
NUMBERS[j]->timeStamp = std::string(buffer);
|
NUMBERS[j]->timeStamp = std::string(buffer);
|
||||||
// printf("SaverPreValue %d, Value: %f, Nachkomma %d\n", j, NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
// ESP_LOGD(TAG, "SaverPreValue %d, Value: %f, Nachkomma %d", j, NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
||||||
|
|
||||||
_zw = NUMBERS[j]->name + "\t" + NUMBERS[j]->timeStamp + "\t" + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + "\n";
|
_zw = NUMBERS[j]->name + "\t" + NUMBERS[j]->timeStamp + "\t" + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + "\n";
|
||||||
printf("Write PreValue Zeile: %s\n", _zw.c_str());
|
ESP_LOGD(TAG, "Write PreValue Zeile: %s", _zw.c_str());
|
||||||
if (pFile) {
|
if (pFile) {
|
||||||
fputs(_zw.c_str(), pFile);
|
fputs(_zw.c_str(), pFile);
|
||||||
}
|
}
|
||||||
@@ -278,7 +283,7 @@ void ClassFlowPostProcessing::handleDecimalExtendedResolution(string _decsep, st
|
|||||||
{
|
{
|
||||||
string _digit, _decpos;
|
string _digit, _decpos;
|
||||||
int _pospunkt = _decsep.find_first_of(".");
|
int _pospunkt = _decsep.find_first_of(".");
|
||||||
// printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
|
// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
|
||||||
if (_pospunkt > -1)
|
if (_pospunkt > -1)
|
||||||
_digit = _decsep.substr(0, _pospunkt);
|
_digit = _decsep.substr(0, _pospunkt);
|
||||||
else
|
else
|
||||||
@@ -308,7 +313,7 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val
|
|||||||
{
|
{
|
||||||
string _digit, _decpos;
|
string _digit, _decpos;
|
||||||
int _pospunkt = _decsep.find_first_of(".");
|
int _pospunkt = _decsep.find_first_of(".");
|
||||||
// printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
|
// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
|
||||||
if (_pospunkt > -1)
|
if (_pospunkt > -1)
|
||||||
_digit = _decsep.substr(0, _pospunkt);
|
_digit = _decsep.substr(0, _pospunkt);
|
||||||
else
|
else
|
||||||
@@ -324,7 +329,7 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val
|
|||||||
}
|
}
|
||||||
/* catch(const std::exception& e)
|
/* catch(const std::exception& e)
|
||||||
{
|
{
|
||||||
printf("ERROR - Decimalshift is not a number: %s\n", _value.c_str());
|
ESP_LOGD(TAG, "ERROR - Decimalshift is not a number: %s", _value.c_str());
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (_digit == "default") // erstmal auf default setzen (falls sonst nichts gesetzt)
|
if (_digit == "default") // erstmal auf default setzen (falls sonst nichts gesetzt)
|
||||||
@@ -347,7 +352,7 @@ void ClassFlowPostProcessing::handleAnalogDigitalTransitionStart(string _decsep,
|
|||||||
{
|
{
|
||||||
string _digit, _decpos;
|
string _digit, _decpos;
|
||||||
int _pospunkt = _decsep.find_first_of(".");
|
int _pospunkt = _decsep.find_first_of(".");
|
||||||
// printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
|
// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
|
||||||
if (_pospunkt > -1)
|
if (_pospunkt > -1)
|
||||||
_digit = _decsep.substr(0, _pospunkt);
|
_digit = _decsep.substr(0, _pospunkt);
|
||||||
else
|
else
|
||||||
@@ -372,7 +377,7 @@ void ClassFlowPostProcessing::handleMaxRateType(string _decsep, string _value)
|
|||||||
{
|
{
|
||||||
string _digit, _decpos;
|
string _digit, _decpos;
|
||||||
int _pospunkt = _decsep.find_first_of(".");
|
int _pospunkt = _decsep.find_first_of(".");
|
||||||
// printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
|
// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
|
||||||
if (_pospunkt > -1)
|
if (_pospunkt > -1)
|
||||||
_digit = _decsep.substr(0, _pospunkt);
|
_digit = _decsep.substr(0, _pospunkt);
|
||||||
else
|
else
|
||||||
@@ -404,7 +409,7 @@ void ClassFlowPostProcessing::handleMaxRateValue(string _decsep, string _value)
|
|||||||
{
|
{
|
||||||
string _digit, _decpos;
|
string _digit, _decpos;
|
||||||
int _pospunkt = _decsep.find_first_of(".");
|
int _pospunkt = _decsep.find_first_of(".");
|
||||||
// printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
|
// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
|
||||||
if (_pospunkt > -1)
|
if (_pospunkt > -1)
|
||||||
_digit = _decsep.substr(0, _pospunkt);
|
_digit = _decsep.substr(0, _pospunkt);
|
||||||
else
|
else
|
||||||
@@ -418,7 +423,7 @@ void ClassFlowPostProcessing::handleMaxRateValue(string _decsep, string _value)
|
|||||||
}
|
}
|
||||||
/* catch(const std::exception& e)
|
/* catch(const std::exception& e)
|
||||||
{
|
{
|
||||||
printf("ERROR - MaxRateValue is not a number: %s\n", _value.c_str());
|
ESP_LOGD(TAG, "ERROR - MaxRateValue is not a number: %s", _value.c_str());
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (_digit == "default") // erstmal auf default setzen (falls sonst nichts gesetzt)
|
if (_digit == "default") // erstmal auf default setzen (falls sonst nichts gesetzt)
|
||||||
@@ -541,7 +546,7 @@ void ClassFlowPostProcessing::InitNUMBERS()
|
|||||||
flowAnalog->UpdateNameNumbers(&name_numbers);
|
flowAnalog->UpdateNameNumbers(&name_numbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Anzahl NUMBERS: %d - DIGITS: %d, ANALOG: %d\n", name_numbers.size(), anzDIGIT, anzANALOG);
|
ESP_LOGD(TAG, "Anzahl NUMBERS: %d - DIGITS: %d, ANALOG: %d", name_numbers.size(), anzDIGIT, anzANALOG);
|
||||||
|
|
||||||
for (int _num = 0; _num < name_numbers.size(); ++_num)
|
for (int _num = 0; _num < name_numbers.size(); ++_num)
|
||||||
{
|
{
|
||||||
@@ -597,7 +602,7 @@ void ClassFlowPostProcessing::InitNUMBERS()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < NUMBERS.size(); ++i) {
|
for (int i = 0; i < NUMBERS.size(); ++i) {
|
||||||
printf("Number %s, Anz DIG: %d, Anz ANA %d\n", NUMBERS[i]->name.c_str(), NUMBERS[i]->AnzahlDigital, NUMBERS[i]->AnzahlAnalog);
|
ESP_LOGD(TAG, "Number %s, Anz DIG: %d, Anz ANA %d", NUMBERS[i]->name.c_str(), NUMBERS[i]->AnzahlDigital, NUMBERS[i]->AnzahlAnalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -666,7 +671,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
strftime(strftime_buf, sizeof(strftime_buf), "%Y-%m-%dT%H:%M:%S", timeinfo);
|
strftime(strftime_buf, sizeof(strftime_buf), "%Y-%m-%dT%H:%M:%S", timeinfo);
|
||||||
zwtime = std::string(strftime_buf);
|
zwtime = std::string(strftime_buf);
|
||||||
|
|
||||||
printf("Anzahl NUMBERS: %d\n", NUMBERS.size());
|
ESP_LOGD(TAG, "Anzahl NUMBERS: %d", NUMBERS.size());
|
||||||
|
|
||||||
for (int j = 0; j < NUMBERS.size(); ++j)
|
for (int j = 0; j < NUMBERS.size(); ++j)
|
||||||
{
|
{
|
||||||
@@ -691,7 +696,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("After analog->getReadout: ReturnRaw %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
ESP_LOGD(TAG, "After analog->getReadout: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
|
||||||
#endif
|
#endif
|
||||||
if (NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi)
|
if (NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi)
|
||||||
NUMBERS[j]->ReturnRawValue = "." + NUMBERS[j]->ReturnRawValue;
|
NUMBERS[j]->ReturnRawValue = "." + NUMBERS[j]->ReturnRawValue;
|
||||||
@@ -704,12 +709,12 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution, previous_value); // Extended Resolution nur falls es keine analogen Ziffern gibt
|
NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution, previous_value); // Extended Resolution nur falls es keine analogen Ziffern gibt
|
||||||
}
|
}
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("After digital->getReadout: ReturnRaw %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
ESP_LOGD(TAG, "After digital->getReadout: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
|
||||||
#endif
|
#endif
|
||||||
NUMBERS[j]->ReturnRawValue = ShiftDecimal(NUMBERS[j]->ReturnRawValue, NUMBERS[j]->DecimalShift);
|
NUMBERS[j]->ReturnRawValue = ShiftDecimal(NUMBERS[j]->ReturnRawValue, NUMBERS[j]->DecimalShift);
|
||||||
|
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("After ShiftDecimal: ReturnRaw %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
ESP_LOGD(TAG, "After ShiftDecimal: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (IgnoreLeadingNaN)
|
if (IgnoreLeadingNaN)
|
||||||
@@ -717,7 +722,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
NUMBERS[j]->ReturnRawValue.erase(0, 1);
|
NUMBERS[j]->ReturnRawValue.erase(0, 1);
|
||||||
|
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("After IgnoreLeadingNaN: ReturnRaw %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
ESP_LOGD(TAG, "After IgnoreLeadingNaN: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
|
||||||
#endif
|
#endif
|
||||||
NUMBERS[j]->ReturnValue = NUMBERS[j]->ReturnRawValue;
|
NUMBERS[j]->ReturnValue = NUMBERS[j]->ReturnRawValue;
|
||||||
|
|
||||||
@@ -734,17 +739,17 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("After findDelimiterPos: ReturnValue %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
ESP_LOGD(TAG, "After findDelimiterPos: ReturnValue %s", NUMBERS[j]->ReturnRawValue.c_str());
|
||||||
#endif
|
#endif
|
||||||
// Lösche führende Nullen (außer es ist nur noch einen 0)
|
// Lösche führende Nullen (außer es ist nur noch einen 0)
|
||||||
while ((NUMBERS[j]->ReturnValue.length() > 1) && (NUMBERS[j]->ReturnValue[0] == '0'))
|
while ((NUMBERS[j]->ReturnValue.length() > 1) && (NUMBERS[j]->ReturnValue[0] == '0'))
|
||||||
NUMBERS[j]->ReturnValue.erase(0, 1);
|
NUMBERS[j]->ReturnValue.erase(0, 1);
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("After removeLeadingZeros: ReturnValue %s\n", NUMBERS[j]->ReturnRawValue.c_str());
|
ESP_LOGD(TAG, "After removeLeadingZeros: ReturnValue %s", NUMBERS[j]->ReturnRawValue.c_str());
|
||||||
#endif
|
#endif
|
||||||
NUMBERS[j]->Value = std::stod(NUMBERS[j]->ReturnValue);
|
NUMBERS[j]->Value = std::stod(NUMBERS[j]->ReturnValue);
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("After setting the Value: Value %f and as double is %f\n", NUMBERS[j]->Value, std::stod(NUMBERS[j]->ReturnValue));
|
ESP_LOGD(TAG, "After setting the Value: Value %f and as double is %f", NUMBERS[j]->Value, std::stod(NUMBERS[j]->ReturnValue));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (NUMBERS[j]->checkDigitIncreaseConsistency)
|
if (NUMBERS[j]->checkDigitIncreaseConsistency)
|
||||||
@@ -752,20 +757,20 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
if (flowDigit)
|
if (flowDigit)
|
||||||
{
|
{
|
||||||
if (flowDigit->getCNNType() != Digital)
|
if (flowDigit->getCNNType() != Digital)
|
||||||
printf("checkDigitIncreaseConsistency = true - ignored due to wrong CNN-Type (not Digital Classification)\n");
|
ESP_LOGD(TAG, "checkDigitIncreaseConsistency = true - ignored due to wrong CNN-Type (not Digital Classification)");
|
||||||
else
|
else
|
||||||
NUMBERS[j]->Value = checkDigitConsistency(NUMBERS[j]->Value, NUMBERS[j]->DecimalShift, NUMBERS[j]->analog_roi != NULL, NUMBERS[j]->PreValue);
|
NUMBERS[j]->Value = checkDigitConsistency(NUMBERS[j]->Value, NUMBERS[j]->DecimalShift, NUMBERS[j]->analog_roi != NULL, NUMBERS[j]->PreValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("checkDigitIncreaseConsistency = true - no digital numbers defined!\n");
|
ESP_LOGD(TAG, "checkDigitIncreaseConsistency = true - no digital numbers defined!");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("After checkDigitIncreaseConsistency: Value %f\n", NUMBERS[j]->Value);
|
ESP_LOGD(TAG, "After checkDigitIncreaseConsistency: Value %f", NUMBERS[j]->Value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -774,7 +779,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
if ((NUMBERS[j]->Value < NUMBERS[j]->PreValue))
|
if ((NUMBERS[j]->Value < NUMBERS[j]->PreValue))
|
||||||
{
|
{
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("Neg: value=%f, preValue=%f, preToll%f\n", NUMBERS[j]->Value, NUMBERS[j]->PreValue,
|
ESP_LOGD(TAG, "Neg: value=%f, preValue=%f, preToll%f", NUMBERS[j]->Value, NUMBERS[j]->PreValue,
|
||||||
NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))
|
NUMBERS[j]->PreValue-(2/pow(10, NUMBERS[j]->Nachkomma))
|
||||||
) ;
|
) ;
|
||||||
#endif
|
#endif
|
||||||
@@ -793,7 +798,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("After AllowNegativeRates: Value %f\n", NUMBERS[j]->Value);
|
ESP_LOGD(TAG, "After AllowNegativeRates: Value %f", NUMBERS[j]->Value);
|
||||||
#endif
|
#endif
|
||||||
double difference = difftime(imagetime, NUMBERS[j]->lastvalue); // in Sekunden
|
double difference = difftime(imagetime, NUMBERS[j]->lastvalue); // in Sekunden
|
||||||
difference /= 60;
|
difference /= 60;
|
||||||
@@ -819,7 +824,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("After MaxRateCheck: Value %f\n", NUMBERS[j]->Value);
|
ESP_LOGD(TAG, "After MaxRateCheck: Value %f", NUMBERS[j]->Value);
|
||||||
#endif
|
#endif
|
||||||
NUMBERS[j]->ReturnChangeAbsolute = RundeOutput(NUMBERS[j]->Value - NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
NUMBERS[j]->ReturnChangeAbsolute = RundeOutput(NUMBERS[j]->Value - NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
|
||||||
NUMBERS[j]->lastvalue = imagetime;
|
NUMBERS[j]->lastvalue = imagetime;
|
||||||
@@ -834,7 +839,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
|
|||||||
UpdatePreValueINI = true;
|
UpdatePreValueINI = true;
|
||||||
|
|
||||||
string _zw = "PostProcessing - Raw: " + NUMBERS[j]->ReturnRawValue + " Value: " + NUMBERS[j]->ReturnValue + " Error: " + NUMBERS[j]->ErrorMessageText;
|
string _zw = "PostProcessing - Raw: " + NUMBERS[j]->ReturnRawValue + " Value: " + NUMBERS[j]->ReturnValue + " Error: " + NUMBERS[j]->ErrorMessageText;
|
||||||
printf("%s\n", zw.c_str());
|
ESP_LOGD(TAG, "%s", zw.c_str());
|
||||||
LogFile.WriteToFile(_zw);
|
LogFile.WriteToFile(_zw);
|
||||||
WriteDataLog(j);
|
WriteDataLog(j);
|
||||||
}
|
}
|
||||||
@@ -853,7 +858,7 @@ void ClassFlowPostProcessing::WriteDataLog(int _analog)
|
|||||||
digital = flowDigit->getReadoutRawString(_analog);
|
digital = flowDigit->getReadoutRawString(_analog);
|
||||||
// LogFile.WriteToFile(analog);
|
// LogFile.WriteToFile(analog);
|
||||||
LogFile.WriteToData(NUMBERS[_analog]->ReturnRawValue, NUMBERS[_analog]->ReturnValue, NUMBERS[_analog]->ReturnPreValue, NUMBERS[_analog]->ErrorMessageText, digital, analog);
|
LogFile.WriteToData(NUMBERS[_analog]->ReturnRawValue, NUMBERS[_analog]->ReturnValue, NUMBERS[_analog]->ReturnPreValue, NUMBERS[_analog]->ErrorMessageText, digital, analog);
|
||||||
printf("WriteDataLog: %s, %s, %s, %s, %s", NUMBERS[_analog]->ReturnRawValue.c_str(), NUMBERS[_analog]->ReturnValue.c_str(), NUMBERS[_analog]->ErrorMessageText.c_str(), digital.c_str(), analog.c_str());
|
ESP_LOGD(TAG, "WriteDataLog: %s, %s, %s, %s, %s", NUMBERS[_analog]->ReturnRawValue.c_str(), NUMBERS[_analog]->ReturnValue.c_str(), NUMBERS[_analog]->ErrorMessageText.c_str(), digital.c_str(), analog.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -863,7 +868,7 @@ void ClassFlowPostProcessing::UpdateNachkommaDecimalShift()
|
|||||||
{
|
{
|
||||||
if (NUMBERS[j]->digit_roi && !NUMBERS[j]->analog_roi) // es gibt nur digitale ziffern
|
if (NUMBERS[j]->digit_roi && !NUMBERS[j]->analog_roi) // es gibt nur digitale ziffern
|
||||||
{
|
{
|
||||||
// printf("Nurdigital\n");
|
// ESP_LOGD(TAG, "Nurdigital");
|
||||||
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
|
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
|
||||||
|
|
||||||
if (NUMBERS[j]->isExtendedResolution && flowDigit->isExtendedResolution()) // extended resolution ist an und soll auch bei dieser Ziffer verwendet werden
|
if (NUMBERS[j]->isExtendedResolution && flowDigit->isExtendedResolution()) // extended resolution ist an und soll auch bei dieser Ziffer verwendet werden
|
||||||
@@ -874,7 +879,7 @@ void ClassFlowPostProcessing::UpdateNachkommaDecimalShift()
|
|||||||
|
|
||||||
if (!NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) // es gibt nur analoge ziffern
|
if (!NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) // es gibt nur analoge ziffern
|
||||||
{
|
{
|
||||||
// printf("Nur analog\n");
|
// ESP_LOGD(TAG, "Nur analog");
|
||||||
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
|
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
|
||||||
if (NUMBERS[j]->isExtendedResolution && flowAnalog->isExtendedResolution()) // extended resolution ist an und soll auch bei dieser Ziffer verwendet werden
|
if (NUMBERS[j]->isExtendedResolution && flowAnalog->isExtendedResolution()) // extended resolution ist an und soll auch bei dieser Ziffer verwendet werden
|
||||||
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShift-1;
|
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShift-1;
|
||||||
@@ -884,7 +889,7 @@ void ClassFlowPostProcessing::UpdateNachkommaDecimalShift()
|
|||||||
|
|
||||||
if (NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) // digital + analog
|
if (NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) // digital + analog
|
||||||
{
|
{
|
||||||
// printf("Nur digital + analog\n");
|
// ESP_LOGD(TAG, "Nur digital + analog");
|
||||||
|
|
||||||
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
|
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
|
||||||
NUMBERS[j]->Nachkomma = NUMBERS[j]->analog_roi->ROI.size() - NUMBERS[j]->DecimalShift;
|
NUMBERS[j]->Nachkomma = NUMBERS[j]->analog_roi->ROI.size() - NUMBERS[j]->DecimalShift;
|
||||||
@@ -894,7 +899,7 @@ void ClassFlowPostProcessing::UpdateNachkommaDecimalShift()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("UpdateNachkommaDecShift NUMBER%i: Nachkomma %i, DecShift %i\n", j, NUMBERS[j]->Nachkomma,NUMBERS[j]->DecimalShift);
|
ESP_LOGD(TAG, "UpdateNachkommaDecShift NUMBER%i: Nachkomma %i, DecShift %i", j, NUMBERS[j]->Nachkomma,NUMBERS[j]->DecimalShift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -916,7 +921,7 @@ string ClassFlowPostProcessing::getReadoutParam(bool _rawValue, bool _noerror, i
|
|||||||
string ClassFlowPostProcessing::RundeOutput(double _in, int _anzNachkomma){
|
string ClassFlowPostProcessing::RundeOutput(double _in, int _anzNachkomma){
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
int _zw = _in;
|
int _zw = _in;
|
||||||
// printf("AnzNachkomma: %d\n", _anzNachkomma);
|
// ESP_LOGD(TAG, "AnzNachkomma: %d", _anzNachkomma);
|
||||||
|
|
||||||
if (_anzNachkomma < 0) {
|
if (_anzNachkomma < 0) {
|
||||||
_anzNachkomma = 0;
|
_anzNachkomma = 0;
|
||||||
@@ -981,7 +986,7 @@ float ClassFlowPostProcessing::checkDigitConsistency(double input, int _decilams
|
|||||||
pot++;
|
pot++;
|
||||||
}
|
}
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("checkDigitConsistency: pot=%d, decimalshift=%d\n", pot, _decilamshift);
|
ESP_LOGD(TAG, "checkDigitConsistency: pot=%d, decimalshift=%d", pot, _decilamshift);
|
||||||
#endif
|
#endif
|
||||||
pot_max = ((int) log10(input)) + 1;
|
pot_max = ((int) log10(input)) + 1;
|
||||||
while (pot <= pot_max)
|
while (pot <= pot_max)
|
||||||
@@ -1013,7 +1018,7 @@ float ClassFlowPostProcessing::checkDigitConsistency(double input, int _decilams
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef SERIAL_DEBUG
|
#ifdef SERIAL_DEBUG
|
||||||
printf("checkDigitConsistency: input=%f", input);
|
ESP_LOGD(TAG, "checkDigitConsistency: input=%f", input);
|
||||||
#endif
|
#endif
|
||||||
pot++;
|
pot++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ extern "C" {
|
|||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
//#include "ClassLogFile.h"
|
//#include "ClassLogFile.h"
|
||||||
|
|
||||||
|
static const char* TAG = "helper";
|
||||||
|
|
||||||
//#define ISWINDOWS_TRUE
|
//#define ISWINDOWS_TRUE
|
||||||
#define PATH_MAX_STRING_SIZE 256
|
#define PATH_MAX_STRING_SIZE 256
|
||||||
|
|
||||||
@@ -90,13 +92,13 @@ FILE* OpenFileAndWait(const char* nm, const char* _mode, int _waitsec)
|
|||||||
{
|
{
|
||||||
FILE *pfile;
|
FILE *pfile;
|
||||||
|
|
||||||
printf("open file %s in mode %s\n", nm, _mode);
|
ESP_LOGD(TAG, "open file %s in mode %s", nm, _mode);
|
||||||
|
|
||||||
if ((pfile = fopen(nm, _mode)) != NULL) {
|
if ((pfile = fopen(nm, _mode)) != NULL) {
|
||||||
printf("File %s successfully opened\n", nm);
|
ESP_LOGD(TAG, "File %s successfully opened", nm);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Error: file %s does not exist!\n", nm);
|
ESP_LOGD(TAG, "Error: file %s does not exist!", nm);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +108,7 @@ FILE* OpenFileAndWait(const char* nm, const char* _mode, int _waitsec)
|
|||||||
TickType_t xDelay;
|
TickType_t xDelay;
|
||||||
xDelay = _waitsec * 1000 / portTICK_PERIOD_MS;
|
xDelay = _waitsec * 1000 / portTICK_PERIOD_MS;
|
||||||
std::string zw = "File is locked: " + std::string(nm) + " - wait for " + std::to_string(_waitsec) + " seconds";
|
std::string zw = "File is locked: " + std::string(nm) + " - wait for " + std::to_string(_waitsec) + " seconds";
|
||||||
printf(zw.c_str());
|
ESP_LOGD(TAG, "%s", zw.c_str());
|
||||||
printf("\n");
|
|
||||||
LogFile.WriteToFile(zw);
|
LogFile.WriteToFile(zw);
|
||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
pfile = fopen(nm, _mode);
|
pfile = fopen(nm, _mode);
|
||||||
@@ -159,7 +160,7 @@ void MakeDir(std::string _what)
|
|||||||
// chdir(_where.c_str());
|
// chdir(_where.c_str());
|
||||||
|
|
||||||
if (mkdir(_what.c_str(), S_IRWXU|S_IRWXG|S_IROTH))
|
if (mkdir(_what.c_str(), S_IRWXU|S_IRWXG|S_IROTH))
|
||||||
printf("Problem with MakeDir: %s \n", _what.c_str());
|
ESP_LOGD(TAG, "Problem with MakeDir: %s", _what.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -233,7 +234,7 @@ void RenameFile(string from, string to)
|
|||||||
FILE* fpSourceFile = OpenFileAndWait(from.c_str(), "rb");
|
FILE* fpSourceFile = OpenFileAndWait(from.c_str(), "rb");
|
||||||
if (!fpSourceFile) // Sourcefile existiert nicht sonst gibt es einen Fehler beim Kopierversuch!
|
if (!fpSourceFile) // Sourcefile existiert nicht sonst gibt es einen Fehler beim Kopierversuch!
|
||||||
{
|
{
|
||||||
printf("DeleteFile: File %s existiert nicht!\n", from.c_str());
|
ESP_LOGD(TAG, "DeleteFile: File %s existiert nicht!", from.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fclose(fpSourceFile);
|
fclose(fpSourceFile);
|
||||||
@@ -249,7 +250,7 @@ void DeleteFile(string fn)
|
|||||||
FILE* fpSourceFile = OpenFileAndWait(fn.c_str(), "rb");
|
FILE* fpSourceFile = OpenFileAndWait(fn.c_str(), "rb");
|
||||||
if (!fpSourceFile) // Sourcefile existiert nicht sonst gibt es einen Fehler beim Kopierversuch!
|
if (!fpSourceFile) // Sourcefile existiert nicht sonst gibt es einen Fehler beim Kopierversuch!
|
||||||
{
|
{
|
||||||
printf("DeleteFile: File %s existiert nicht!\n", fn.c_str());
|
ESP_LOGD(TAG, "DeleteFile: File %s existiert nicht!", fn.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fclose(fpSourceFile);
|
fclose(fpSourceFile);
|
||||||
@@ -265,7 +266,7 @@ void CopyFile(string input, string output)
|
|||||||
|
|
||||||
if (toUpper(input).compare("/SDCARD/WLAN.INI") == 0)
|
if (toUpper(input).compare("/SDCARD/WLAN.INI") == 0)
|
||||||
{
|
{
|
||||||
printf("wlan.ini kann nicht kopiert werden!\n");
|
ESP_LOGD(TAG, "wlan.ini kann nicht kopiert werden!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,7 +274,7 @@ void CopyFile(string input, string output)
|
|||||||
FILE* fpSourceFile = OpenFileAndWait(input.c_str(), "rb");
|
FILE* fpSourceFile = OpenFileAndWait(input.c_str(), "rb");
|
||||||
if (!fpSourceFile) // Sourcefile existiert nicht sonst gibt es einen Fehler beim Kopierversuch!
|
if (!fpSourceFile) // Sourcefile existiert nicht sonst gibt es einen Fehler beim Kopierversuch!
|
||||||
{
|
{
|
||||||
printf("File %s existiert nicht!\n", input.c_str());
|
ESP_LOGD(TAG, "File %s existiert nicht!", input.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,7 +292,7 @@ void CopyFile(string input, string output)
|
|||||||
// Close The Files
|
// Close The Files
|
||||||
fclose(fpSourceFile);
|
fclose(fpSourceFile);
|
||||||
fclose(fpTargetFile);
|
fclose(fpTargetFile);
|
||||||
printf("File copied: %s to %s", input.c_str(), output.c_str());
|
ESP_LOGD(TAG, "File copied: %s to %s", input.c_str(), output.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
string getFileFullFileName(string filename)
|
string getFileFullFileName(string filename)
|
||||||
@@ -301,7 +302,7 @@ string getFileFullFileName(string filename)
|
|||||||
if (lastpos == string::npos)
|
if (lastpos == string::npos)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
// printf("Last position: %d\n", lastpos);
|
// ESP_LOGD(TAG, "Last position: %d", lastpos);
|
||||||
|
|
||||||
string zw = filename.substr(lastpos + 1, filename.size() - lastpos);
|
string zw = filename.substr(lastpos + 1, filename.size() - lastpos);
|
||||||
|
|
||||||
@@ -318,7 +319,7 @@ string getDirectory(string filename)
|
|||||||
if (lastpos == string::npos)
|
if (lastpos == string::npos)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
// printf("Directory: %d\n", lastpos);
|
// ESP_LOGD(TAG, "Directory: %d", lastpos);
|
||||||
|
|
||||||
string zw = filename.substr(0, lastpos - 1);
|
string zw = filename.substr(0, lastpos - 1);
|
||||||
return zw;
|
return zw;
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <esp_log.h>
|
||||||
|
|
||||||
|
static const char* TAG = "c_align_and_cut_image";
|
||||||
|
|
||||||
//#define GET_MEMORY malloc
|
//#define GET_MEMORY malloc
|
||||||
#define GET_MEMORY(X) heap_caps_malloc(X, MALLOC_CAP_SPIRAM)
|
#define GET_MEMORY(X) heap_caps_malloc(X, MALLOC_CAP_SPIRAM)
|
||||||
@@ -43,14 +46,14 @@ bool CAlignAndCutImage::Align(RefInfo *_temp1, RefInfo *_temp2)
|
|||||||
|
|
||||||
r0_x = _temp1->target_x;
|
r0_x = _temp1->target_x;
|
||||||
r0_y = _temp1->target_y;
|
r0_y = _temp1->target_y;
|
||||||
printf("Vor ft->FindTemplate(_temp1); %s\n", _temp1->image_file.c_str());
|
ESP_LOGD(TAG, "Vor ft->FindTemplate(_temp1); %s", _temp1->image_file.c_str());
|
||||||
isSimilar1 = ft->FindTemplate(_temp1);
|
isSimilar1 = ft->FindTemplate(_temp1);
|
||||||
_temp1->width = ft->tpl_width;
|
_temp1->width = ft->tpl_width;
|
||||||
_temp1->height = ft->tpl_height;
|
_temp1->height = ft->tpl_height;
|
||||||
|
|
||||||
r1_x = _temp2->target_x;
|
r1_x = _temp2->target_x;
|
||||||
r1_y = _temp2->target_y;
|
r1_y = _temp2->target_y;
|
||||||
printf("Vor ft->FindTemplate(_temp2); %s\n", _temp2->image_file.c_str());
|
ESP_LOGD(TAG, "Vor ft->FindTemplate(_temp2); %s", _temp2->image_file.c_str());
|
||||||
isSimilar2 = ft->FindTemplate(_temp2);
|
isSimilar2 = ft->FindTemplate(_temp2);
|
||||||
_temp2->width = ft->tpl_width;
|
_temp2->width = ft->tpl_width;
|
||||||
_temp2->height = ft->tpl_height;
|
_temp2->height = ft->tpl_height;
|
||||||
@@ -86,7 +89,7 @@ bool CAlignAndCutImage::Align(RefInfo *_temp1, RefInfo *_temp2)
|
|||||||
CRotateImage rt(this, ImageTMP);
|
CRotateImage rt(this, ImageTMP);
|
||||||
rt.Translate(dx, dy);
|
rt.Translate(dx, dy);
|
||||||
rt.Rotate(d_winkel, _temp1->target_x, _temp1->target_y);
|
rt.Rotate(d_winkel, _temp1->target_x, _temp1->target_y);
|
||||||
printf("Alignment: dx %d - dy %d - rot %f\n", dx, dy, d_winkel);
|
ESP_LOGD(TAG, "Alignment: dx %d - dy %d - rot %f", dx, dy, d_winkel);
|
||||||
|
|
||||||
return (isSimilar1 && isSimilar2);
|
return (isSimilar1 && isSimilar2);
|
||||||
}
|
}
|
||||||
@@ -147,7 +150,7 @@ void CAlignAndCutImage::CutAndSave(int x1, int y1, int dx, int dy, CImageBasis *
|
|||||||
|
|
||||||
if ((_target->height != dy) || (_target->width != dx) || (_target->channels != channels))
|
if ((_target->height != dy) || (_target->width != dx) || (_target->channels != channels))
|
||||||
{
|
{
|
||||||
printf("CAlignAndCutImage::CutAndSave - Image size does not match !!");
|
ESP_LOGD(TAG, "CAlignAndCutImage::CutAndSave - Image size does not match!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
|
|
||||||
|
#include <esp_log.h>
|
||||||
|
|
||||||
|
static const char* TAG = "c_find_template";
|
||||||
|
|
||||||
// #define DEBUG_DETAIL_ON
|
// #define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
|
||||||
@@ -9,7 +13,7 @@ bool CFindTemplate::FindTemplate(RefInfo *_ref)
|
|||||||
{
|
{
|
||||||
uint8_t* rgb_template = stbi_load(_ref->image_file.c_str(), &tpl_width, &tpl_height, &tpl_bpp, channels);
|
uint8_t* rgb_template = stbi_load(_ref->image_file.c_str(), &tpl_width, &tpl_height, &tpl_bpp, channels);
|
||||||
|
|
||||||
// printf("FindTemplate 01\n");
|
// ESP_LOGD(TAG, "FindTemplate 01");
|
||||||
|
|
||||||
int ow, ow_start, ow_stop;
|
int ow, ow_start, ow_stop;
|
||||||
int oh, oh_start, oh_stop;
|
int oh, oh_start, oh_stop;
|
||||||
@@ -45,7 +49,7 @@ bool CFindTemplate::FindTemplate(RefInfo *_ref)
|
|||||||
int min, max;
|
int min, max;
|
||||||
bool isSimilar = false;
|
bool isSimilar = false;
|
||||||
|
|
||||||
// printf("FindTemplate 02\n");
|
// ESP_LOGD(TAG, "FindTemplate 02");
|
||||||
|
|
||||||
if ((_ref->alignment_algo == 2) && (_ref->fastalg_x > -1) && (_ref->fastalg_y > -1)) // für Testzwecke immer Berechnen
|
if ((_ref->alignment_algo == 2) && (_ref->fastalg_x > -1) && (_ref->fastalg_y > -1)) // für Testzwecke immer Berechnen
|
||||||
{
|
{
|
||||||
@@ -57,7 +61,7 @@ bool CFindTemplate::FindTemplate(RefInfo *_ref)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("FindTemplate 03\n");
|
// ESP_LOGD(TAG, "FindTemplate 03");
|
||||||
|
|
||||||
|
|
||||||
if (isSimilar)
|
if (isSimilar)
|
||||||
@@ -70,7 +74,7 @@ bool CFindTemplate::FindTemplate(RefInfo *_ref)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("FindTemplate 04\n");
|
// ESP_LOGD(TAG, "FindTemplate 04");
|
||||||
|
|
||||||
|
|
||||||
double aktSAD;
|
double aktSAD;
|
||||||
@@ -78,7 +82,7 @@ bool CFindTemplate::FindTemplate(RefInfo *_ref)
|
|||||||
|
|
||||||
RGBImageLock();
|
RGBImageLock();
|
||||||
|
|
||||||
// printf("FindTemplate 05\n");
|
// ESP_LOGD(TAG, "FindTemplate 05");
|
||||||
int xouter, youter, tpl_x, tpl_y, _ch;
|
int xouter, youter, tpl_x, tpl_y, _ch;
|
||||||
int _anzchannels = channels;
|
int _anzchannels = channels;
|
||||||
if (_ref->alignment_algo == 0) // 0 = "Default" (nur R-Kanal)
|
if (_ref->alignment_algo == 0) // 0 = "Default" (nur R-Kanal)
|
||||||
@@ -106,14 +110,14 @@ bool CFindTemplate::FindTemplate(RefInfo *_ref)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("FindTemplate 06\n");
|
// ESP_LOGD(TAG, "FindTemplate 06");
|
||||||
|
|
||||||
|
|
||||||
if (_ref->alignment_algo == 2)
|
if (_ref->alignment_algo == 2)
|
||||||
CalculateSimularities(rgb_template, _ref->found_x, _ref->found_y, ow, oh, min, avg, max, SAD, _ref->fastalg_SAD, _ref->fastalg_SAD_criteria);
|
CalculateSimularities(rgb_template, _ref->found_x, _ref->found_y, ow, oh, min, avg, max, SAD, _ref->fastalg_SAD, _ref->fastalg_SAD_criteria);
|
||||||
|
|
||||||
|
|
||||||
// printf("FindTemplate 07\n");
|
// ESP_LOGD(TAG, "FindTemplate 07");
|
||||||
|
|
||||||
_ref->fastalg_x = _ref->found_x;
|
_ref->fastalg_x = _ref->found_x;
|
||||||
_ref->fastalg_y = _ref->found_y;
|
_ref->fastalg_y = _ref->found_y;
|
||||||
@@ -132,7 +136,7 @@ bool CFindTemplate::FindTemplate(RefInfo *_ref)
|
|||||||
RGBImageRelease();
|
RGBImageRelease();
|
||||||
stbi_image_free(rgb_template);
|
stbi_image_free(rgb_template);
|
||||||
|
|
||||||
// printf("FindTemplate 08\n");
|
// ESP_LOGD(TAG, "FindTemplate 08");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -173,7 +177,7 @@ bool CFindTemplate::CalculateSimularities(uint8_t* _rgb_tmpl, int _startx, int _
|
|||||||
|
|
||||||
float _SADdif = abs(SAD - _SADold);
|
float _SADdif = abs(SAD - _SADold);
|
||||||
|
|
||||||
printf("Anzahl %ld, avgDifSum %fd, avg %f, SAD_neu: %fd, _SAD_old: %f, _SAD_crit:%f\n", anz, avgDifSum, avg, SAD, _SADold, _SADdif);
|
ESP_LOGD(TAG, "Anzahl %ld, avgDifSum %fd, avg %f, SAD_neu: %fd, _SAD_old: %f, _SAD_crit:%f", anz, avgDifSum, avg, SAD, _SADold, _SADdif);
|
||||||
|
|
||||||
if (_SADdif <= _SADcrit)
|
if (_SADdif <= _SADcrit)
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ uint8_t * CImageBasis::RGBImageLock(int _waitmaxsec)
|
|||||||
if (islocked)
|
if (islocked)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Image is locked: sleep for : %ds\n", _waitmaxsec);
|
ESP_LOGD(TAG, "Image is locked: sleep for: %ds", _waitmaxsec);
|
||||||
#endif
|
#endif
|
||||||
TickType_t xDelay;
|
TickType_t xDelay;
|
||||||
xDelay = 1000 / portTICK_PERIOD_MS;
|
xDelay = 1000 / portTICK_PERIOD_MS;
|
||||||
@@ -61,7 +61,7 @@ uint8_t * CImageBasis::RGBImageGet()
|
|||||||
|
|
||||||
void writejpghelp(void *context, void *data, int size)
|
void writejpghelp(void *context, void *data, int size)
|
||||||
{
|
{
|
||||||
// printf("Size all: %d, size %d\n", ((ImageData*)context)->size, size);
|
// ESP_LOGD(TAG, "Size all: %d, size %d", ((ImageData*)context)->size, size);
|
||||||
ImageData* _zw = (ImageData*) context;
|
ImageData* _zw = (ImageData*) context;
|
||||||
uint8_t *voidstart = _zw->data;
|
uint8_t *voidstart = _zw->data;
|
||||||
uint8_t *datastart = (uint8_t*) data;
|
uint8_t *datastart = (uint8_t*) data;
|
||||||
@@ -146,7 +146,7 @@ bool CImageBasis::CopyFromMemory(uint8_t* _source, int _size)
|
|||||||
int gr = height * width * channels;
|
int gr = height * width * channels;
|
||||||
if (gr != _size) // Größe passt nicht
|
if (gr != _size) // Größe passt nicht
|
||||||
{
|
{
|
||||||
printf("Cannot copy image from memory - sizes do not match: should be %d, but is %d\n", _size, gr);
|
ESP_LOGD(TAG, "Cannot copy image from memory - sizes do not match: should be %d, but is %d", _size, gr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ void CImageBasis::LoadFromMemory(stbi_uc *_buffer, int len)
|
|||||||
stbi_image_free(rgb_image);
|
stbi_image_free(rgb_image);
|
||||||
rgb_image = stbi_load_from_memory(_buffer, len, &width, &height, &channels, 3);
|
rgb_image = stbi_load_from_memory(_buffer, len, &width, &height, &channels, 3);
|
||||||
bpp = channels;
|
bpp = channels;
|
||||||
printf("Image loaded from memory: %d, %d, %d\n", width, height, channels);
|
ESP_LOGD(TAG, "Image loaded from memory: %d, %d, %d", width, height, channels);
|
||||||
if ((width * height * channels) == 0)
|
if ((width * height * channels) == 0)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Image with size 0 loaded --> reboot to be done! "
|
ESP_LOGE(TAG, "Image with size 0 loaded --> reboot to be done! "
|
||||||
@@ -392,7 +392,7 @@ CImageBasis::CImageBasis(CImageBasis *_copyfrom, int _anzrepeat)
|
|||||||
int anz = 1;
|
int anz = 1;
|
||||||
while (!rgb_image && (anz < _anzrepeat))
|
while (!rgb_image && (anz < _anzrepeat))
|
||||||
{
|
{
|
||||||
printf("Create Image from Copy - Memory is full - try again: %d.\n", anz);
|
ESP_LOGD(TAG, "Create Image from Copy - Memory is full - try again: %d", anz);
|
||||||
rgb_image = (unsigned char*) malloc(memsize);
|
rgb_image = (unsigned char*) malloc(memsize);
|
||||||
anz++;
|
anz++;
|
||||||
}
|
}
|
||||||
@@ -400,8 +400,8 @@ CImageBasis::CImageBasis(CImageBasis *_copyfrom, int _anzrepeat)
|
|||||||
|
|
||||||
if (!rgb_image)
|
if (!rgb_image)
|
||||||
{
|
{
|
||||||
printf(getESPHeapInfo().c_str());
|
ESP_LOGD(TAG, "%s", getESPHeapInfo().c_str());
|
||||||
printf("\nNo more free memory!! Needed: %d %d %d %d\n", width, height, channels, memsize);
|
ESP_LOGD(TAG, "No more free memory!! Needed: %d %d %d %d", width, height, channels, memsize);
|
||||||
RGBImageRelease();
|
RGBImageRelease();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -424,8 +424,8 @@ CImageBasis::CImageBasis(int _width, int _height, int _channels)
|
|||||||
rgb_image = (unsigned char*)GET_MEMORY(memsize);
|
rgb_image = (unsigned char*)GET_MEMORY(memsize);
|
||||||
if (!rgb_image)
|
if (!rgb_image)
|
||||||
{
|
{
|
||||||
printf(getESPHeapInfo().c_str());
|
ESP_LOGD(TAG, "%s", getESPHeapInfo().c_str());
|
||||||
printf("\nNo more free memory!! Needed: %d %d %d %d\n", width, height, channels, memsize);
|
ESP_LOGD(TAG, "No more free memory!! Needed: %d %d %d %d", width, height, channels, memsize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -438,21 +438,21 @@ CImageBasis::CImageBasis(std::string _image)
|
|||||||
externalImage = false;
|
externalImage = false;
|
||||||
filename = _image;
|
filename = _image;
|
||||||
long zwld = esp_get_free_heap_size();
|
long zwld = esp_get_free_heap_size();
|
||||||
printf("freeheapsize before: %ld\n", zwld);
|
ESP_LOGD(TAG, "freeheapsize before: %ld", zwld);
|
||||||
|
|
||||||
RGBImageLock();
|
RGBImageLock();
|
||||||
rgb_image = stbi_load(_image.c_str(), &width, &height, &bpp, channels);
|
rgb_image = stbi_load(_image.c_str(), &width, &height, &bpp, channels);
|
||||||
RGBImageRelease();
|
RGBImageRelease();
|
||||||
|
|
||||||
zwld = esp_get_free_heap_size();
|
zwld = esp_get_free_heap_size();
|
||||||
printf("freeheapsize after : %ld\n", zwld);
|
ESP_LOGD(TAG, "freeheapsize after : %ld", zwld);
|
||||||
|
|
||||||
std::string zw = "Image Load failed:" + _image + "\n";
|
std::string zw = "Image Load failed:" + _image;
|
||||||
if (rgb_image == NULL)
|
if (rgb_image == NULL)
|
||||||
printf(zw.c_str());
|
ESP_LOGD(TAG, "%s", zw.c_str());
|
||||||
zw = "CImageBasis after load " + _image + "\n";
|
zw = "CImageBasis after load " + _image + "\n";
|
||||||
printf(zw.c_str());
|
ESP_LOGD(TAG, "%s", zw.c_str());
|
||||||
printf("w %d, h %d, b %d, c %d\n", width, height, bpp, channels);
|
ESP_LOGD(TAG, "w %d, h %d, b %d, c %d", width, height, bpp, channels);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,7 +543,7 @@ void CImageBasis::Resize(int _new_dx, int _new_dy, CImageBasis *_target)
|
|||||||
{
|
{
|
||||||
if ((_target->height != _new_dy) || (_target->width != _new_dx) || (_target->channels != channels))
|
if ((_target->height != _new_dy) || (_target->width != _new_dx) || (_target->channels != channels))
|
||||||
{
|
{
|
||||||
printf("CImageBasis::Resize - Target image size does not fit !!");
|
ESP_LOGD(TAG, "CImageBasis::Resize - Target image size does not fit!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -280,13 +280,13 @@ void CRotateImage::RotateAntiAliasing(float _angle, int _centerx, int _centery)
|
|||||||
|
|
||||||
void CRotateImage::Rotate(float _angle)
|
void CRotateImage::Rotate(float _angle)
|
||||||
{
|
{
|
||||||
// printf("width %d, height %d\n", width, height);
|
// ESP_LOGD(TAG, "width %d, height %d", width, height);
|
||||||
Rotate(_angle, width / 2, height / 2);
|
Rotate(_angle, width / 2, height / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRotateImage::RotateAntiAliasing(float _angle)
|
void CRotateImage::RotateAntiAliasing(float _angle)
|
||||||
{
|
{
|
||||||
// printf("width %d, height %d\n", width, height);
|
// ESP_LOGD(TAG, "width %d, height %d", width, height);
|
||||||
RotateAntiAliasing(_angle, width / 2, height / 2);
|
RotateAntiAliasing(_angle, width / 2, height / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ std::string ClassLogFile::getESPHeapInfo(){
|
|||||||
|
|
||||||
void ClassLogFile::WriteToData(std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ErrorMessageText, std::string _digital, std::string _analog)
|
void ClassLogFile::WriteToData(std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ErrorMessageText, std::string _digital, std::string _analog)
|
||||||
{
|
{
|
||||||
printf("Start WriteToData\n");
|
ESP_LOGD(TAG, "Start WriteToData\n");
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm* timeinfo;
|
struct tm* timeinfo;
|
||||||
char buffer[30];
|
char buffer[30];
|
||||||
@@ -82,7 +82,7 @@ void ClassLogFile::WriteToData(std::string _ReturnRawValue, std::string _ReturnV
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Datalogfile: %s\n", logpath.c_str());
|
ESP_LOGD(TAG, "Datalogfile: %s", logpath.c_str());
|
||||||
pFile = fopen(logpath.c_str(), "a+");
|
pFile = fopen(logpath.c_str(), "a+");
|
||||||
|
|
||||||
if (pFile!=NULL) {
|
if (pFile!=NULL) {
|
||||||
@@ -130,7 +130,7 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, std::string info, bool
|
|||||||
|
|
||||||
// pFile = OpenFileAndWait(_fn.c_str(), "a");
|
// pFile = OpenFileAndWait(_fn.c_str(), "a");
|
||||||
pFile = fopen(_fn.c_str(), "a+");
|
pFile = fopen(_fn.c_str(), "a+");
|
||||||
// printf("Logfile opened: %s\n", _fn.c_str());
|
// ESP_LOGD(TAG, "Logfile opened: %s", _fn.c_str());
|
||||||
|
|
||||||
if (pFile!=NULL) {
|
if (pFile!=NULL) {
|
||||||
if (_time)
|
if (_time)
|
||||||
@@ -186,7 +186,7 @@ void ClassLogFile::WriteToFile(std::string info, bool _time)
|
|||||||
std::string logpath = logroot + "/" + buffer;
|
std::string logpath = logroot + "/" + buffer;
|
||||||
|
|
||||||
WriteToDedicatedFile(logpath, info, _time);
|
WriteToDedicatedFile(logpath, info, _time);
|
||||||
printf((info + "\n").c_str());
|
ESP_LOGD(TAG, "%s", info.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ClassLogFile::GetCurrentFileName()
|
std::string ClassLogFile::GetCurrentFileName()
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
#include "CTfLiteClass.h"
|
#include "CTfLiteClass.h"
|
||||||
#include "ClassLogFile.h"
|
#include "ClassLogFile.h"
|
||||||
#include "Helper.h"
|
#include "Helper.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
// #define DEBUG_DETAIL_ON
|
// #define DEBUG_DETAIL_ON
|
||||||
|
|
||||||
|
|
||||||
|
static const char *TAG = "ctflite_class";
|
||||||
|
|
||||||
float CTfLiteClass::GetOutputValue(int nr)
|
float CTfLiteClass::GetOutputValue(int nr)
|
||||||
{
|
{
|
||||||
TfLiteTensor* output2 = this->interpreter->output(0);
|
TfLiteTensor* output2 = this->interpreter->output(0);
|
||||||
@@ -41,7 +45,7 @@ int CTfLiteClass::GetOutClassification(int _von, int _bis)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int numeroutput = output2->dims->data[1];
|
int numeroutput = output2->dims->data[1];
|
||||||
//printf("\n number output neurons: %d\n\n", numeroutput);
|
//ESP_LOGD(TAG, "number output neurons: %d", numeroutput);
|
||||||
|
|
||||||
if (_bis == -1)
|
if (_bis == -1)
|
||||||
_bis = numeroutput -1;
|
_bis = numeroutput -1;
|
||||||
@@ -51,7 +55,7 @@ int CTfLiteClass::GetOutClassification(int _von, int _bis)
|
|||||||
|
|
||||||
if (_bis >= numeroutput)
|
if (_bis >= numeroutput)
|
||||||
{
|
{
|
||||||
printf("ANZAHL OUTPUT NEURONS passt nicht zu geforderter Classifizierung!");
|
ESP_LOGD(TAG, "ANZAHL OUTPUT NEURONS passt nicht zu geforderter Classifizierung!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,13 +78,13 @@ void CTfLiteClass::GetInputDimension(bool silent = false)
|
|||||||
TfLiteTensor* input2 = this->interpreter->input(0);
|
TfLiteTensor* input2 = this->interpreter->input(0);
|
||||||
|
|
||||||
int numdim = input2->dims->size;
|
int numdim = input2->dims->size;
|
||||||
if (!silent) printf("NumDimension: %d\n", numdim);
|
if (!silent) ESP_LOGD(TAG, "NumDimension: %d", numdim);
|
||||||
|
|
||||||
int sizeofdim;
|
int sizeofdim;
|
||||||
for (int j = 0; j < numdim; ++j)
|
for (int j = 0; j < numdim; ++j)
|
||||||
{
|
{
|
||||||
sizeofdim = input2->dims->data[j];
|
sizeofdim = input2->dims->data[j];
|
||||||
if (!silent) printf("SizeOfDimension %d: %d\n", j, sizeofdim);
|
if (!silent) ESP_LOGD(TAG, "SizeOfDimension %d: %d", j, sizeofdim);
|
||||||
if (j == 1) im_height = sizeofdim;
|
if (j == 1) im_height = sizeofdim;
|
||||||
if (j == 2) im_width = sizeofdim;
|
if (j == 2) im_width = sizeofdim;
|
||||||
if (j == 3) im_channel = sizeofdim;
|
if (j == 3) im_channel = sizeofdim;
|
||||||
@@ -106,13 +110,13 @@ int CTfLiteClass::GetAnzOutPut(bool silent)
|
|||||||
TfLiteTensor* output2 = this->interpreter->output(0);
|
TfLiteTensor* output2 = this->interpreter->output(0);
|
||||||
|
|
||||||
int numdim = output2->dims->size;
|
int numdim = output2->dims->size;
|
||||||
if (!silent) printf("NumDimension: %d\n", numdim);
|
if (!silent) ESP_LOGD(TAG, "NumDimension: %d", numdim);
|
||||||
|
|
||||||
int sizeofdim;
|
int sizeofdim;
|
||||||
for (int j = 0; j < numdim; ++j)
|
for (int j = 0; j < numdim; ++j)
|
||||||
{
|
{
|
||||||
sizeofdim = output2->dims->data[j];
|
sizeofdim = output2->dims->data[j];
|
||||||
if (!silent) printf("SizeOfDimension %d: %d\n", j, sizeofdim);
|
if (!silent) ESP_LOGD(TAG, "SizeOfDimension %d: %d", j, sizeofdim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,7 +127,7 @@ int CTfLiteClass::GetAnzOutPut(bool silent)
|
|||||||
for (int i = 0; i < numeroutput; ++i)
|
for (int i = 0; i < numeroutput; ++i)
|
||||||
{
|
{
|
||||||
fo = output2->data.f[i];
|
fo = output2->data.f[i];
|
||||||
if (!silent) printf("Result %d: %f\n", i, fo);
|
if (!silent) ESP_LOGD(TAG, "Result %d: %f", i, fo);
|
||||||
}
|
}
|
||||||
return numeroutput;
|
return numeroutput;
|
||||||
}
|
}
|
||||||
@@ -143,7 +147,7 @@ bool CTfLiteClass::LoadInputImageBasis(CImageBasis *rs)
|
|||||||
unsigned int w = rs->width;
|
unsigned int w = rs->width;
|
||||||
unsigned int h = rs->height;
|
unsigned int h = rs->height;
|
||||||
unsigned char red, green, blue;
|
unsigned char red, green, blue;
|
||||||
// printf("Image: %s size: %d x %d\n", _fn.c_str(), w, h);
|
// ESP_LOGD(TAG, "Image: %s size: %d x %d\n", _fn.c_str(), w, h);
|
||||||
|
|
||||||
input_i = 0;
|
input_i = 0;
|
||||||
float* input_data_ptr = (interpreter->input(0))->data.f;
|
float* input_data_ptr = (interpreter->input(0))->data.f;
|
||||||
@@ -174,9 +178,9 @@ void CTfLiteClass::MakeAllocate()
|
|||||||
{
|
{
|
||||||
static tflite::AllOpsResolver resolver;
|
static tflite::AllOpsResolver resolver;
|
||||||
|
|
||||||
// printf(LogFile.getESPHeapInfo().c_str()); printf("\n");
|
// ESP_LOGD(TAG, "%s", LogFile.getESPHeapInfo().c_str());
|
||||||
this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter);
|
this->interpreter = new tflite::MicroInterpreter(this->model, resolver, this->tensor_arena, this->kTensorArenaSize, this->error_reporter);
|
||||||
// printf(LogFile.getESPHeapInfo().c_str()); printf("\n");
|
// ESP_LOGD(TAG, "%s", LogFile.getESPHeapInfo().c_str());
|
||||||
|
|
||||||
TfLiteStatus allocate_status = this->interpreter->AllocateTensors();
|
TfLiteStatus allocate_status = this->interpreter->AllocateTensors();
|
||||||
if (allocate_status != kTfLiteOk) {
|
if (allocate_status != kTfLiteOk) {
|
||||||
@@ -186,14 +190,14 @@ void CTfLiteClass::MakeAllocate()
|
|||||||
this->GetInputDimension();
|
this->GetInputDimension();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// printf("Allocate Done.\n");
|
// ESP_LOGD(TAG, "Allocate Done");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTfLiteClass::GetInputTensorSize(){
|
void CTfLiteClass::GetInputTensorSize(){
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
float *zw = this->input;
|
float *zw = this->input;
|
||||||
int test = sizeof(zw);
|
int test = sizeof(zw);
|
||||||
printf("Input Tensor Dimension: %d\n", test);
|
ESP_LOGD(TAG, "Input Tensor Dimension: %d", test);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +217,7 @@ unsigned char* CTfLiteClass::ReadFileToCharArray(std::string _fn)
|
|||||||
|
|
||||||
if (size == -1)
|
if (size == -1)
|
||||||
{
|
{
|
||||||
printf("\nFile doesn't exist.\n");
|
ESP_LOGD(TAG, "File doesn't exist");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +226,7 @@ unsigned char* CTfLiteClass::ReadFileToCharArray(std::string _fn)
|
|||||||
while (!result && (anz < 6)) // maximal 5x versuchen (= 5s)
|
while (!result && (anz < 6)) // maximal 5x versuchen (= 5s)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Speicher ist voll - Versuche es erneut: %d.\n", anz);
|
ESP_LOGD(TAG, "Speicher ist voll - Versuche es erneut: %d", anz);
|
||||||
#endif
|
#endif
|
||||||
result = (unsigned char*) malloc(size);
|
result = (unsigned char*) malloc(size);
|
||||||
anz++;
|
anz++;
|
||||||
@@ -234,7 +238,7 @@ unsigned char* CTfLiteClass::ReadFileToCharArray(std::string _fn)
|
|||||||
fread(result, 1, size, f);
|
fread(result, 1, size, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}else {
|
}else {
|
||||||
printf("\nNo free memory available.\n");
|
ESP_LOGD(TAG, "No free memory available");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ bool isSetupModusActive() {
|
|||||||
void KillTFliteTasks()
|
void KillTFliteTasks()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Handle: xHandleblink_task_doFlow: %ld\n", (long) xHandleblink_task_doFlow);
|
ESP_LOGD(TAGTFLITE, "Handle: xHandleblink_task_doFlow: %ld", (long) xHandleblink_task_doFlow);
|
||||||
#endif
|
#endif
|
||||||
if (xHandleblink_task_doFlow != NULL)
|
if (xHandleblink_task_doFlow != NULL)
|
||||||
{
|
{
|
||||||
@@ -75,12 +75,12 @@ void KillTFliteTasks()
|
|||||||
xHandleblink_task_doFlow = NULL;
|
xHandleblink_task_doFlow = NULL;
|
||||||
vTaskDelete(xHandleblink_task_doFlowTmp);
|
vTaskDelete(xHandleblink_task_doFlowTmp);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Killed: xHandleblink_task_doFlow\n");
|
ESP_LOGD(TAGTFLITE, "Killed: xHandleblink_task_doFlow");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Handle: xHandletask_autodoFlow: %ld\n", (long) xHandletask_autodoFlow);
|
ESP_LOGD(TAGTFLITE, "Handle: xHandletask_autodoFlow: %ld", (long) xHandletask_autodoFlow);
|
||||||
#endif
|
#endif
|
||||||
if (xHandletask_autodoFlow != NULL)
|
if (xHandletask_autodoFlow != NULL)
|
||||||
{
|
{
|
||||||
@@ -88,7 +88,7 @@ void KillTFliteTasks()
|
|||||||
xHandletask_autodoFlow = NULL;
|
xHandletask_autodoFlow = NULL;
|
||||||
vTaskDelete(xHandletask_autodoFlowTmp);
|
vTaskDelete(xHandletask_autodoFlowTmp);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Killed: xHandletask_autodoFlow\n");
|
ESP_LOGD(TAGTFLITE, "Killed: xHandletask_autodoFlow");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,11 +97,11 @@ void KillTFliteTasks()
|
|||||||
void doInit(void)
|
void doInit(void)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Start tfliteflow.InitFlow(config);\n");
|
ESP_LOGD(TAGTFLITE, "Start tfliteflow.InitFlow(config);");
|
||||||
#endif
|
#endif
|
||||||
tfliteflow.InitFlow(CONFIG_FILE);
|
tfliteflow.InitFlow(CONFIG_FILE);
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Finished tfliteflow.InitFlow(config);\n");
|
ESP_LOGD(TAGTFLITE, "Finished tfliteflow.InitFlow(config);");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,13 +110,13 @@ bool doflow(void)
|
|||||||
{
|
{
|
||||||
|
|
||||||
std::string zw_time = gettimestring(LOGFILE_TIME_FORMAT);
|
std::string zw_time = gettimestring(LOGFILE_TIME_FORMAT);
|
||||||
printf("doflow - start %s\n", zw_time.c_str());
|
ESP_LOGD(TAGTFLITE, "doflow - start %s", zw_time.c_str());
|
||||||
flowisrunning = true;
|
flowisrunning = true;
|
||||||
tfliteflow.doFlow(zw_time);
|
tfliteflow.doFlow(zw_time);
|
||||||
flowisrunning = false;
|
flowisrunning = false;
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("doflow - end %s\n", zw_time.c_str());
|
ESP_LOGD(TAGTFLITE, "doflow - end %s", zw_time.c_str());
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ bool doflow(void)
|
|||||||
void blink_task_doFlow(void *pvParameter)
|
void blink_task_doFlow(void *pvParameter)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("blink_task_doFlow\n");
|
ESP_LOGD(TAGTFLITE, "blink_task_doFlow");
|
||||||
#endif
|
#endif
|
||||||
if (!flowisrunning)
|
if (!flowisrunning)
|
||||||
{
|
{
|
||||||
@@ -141,7 +141,7 @@ esp_err_t handler_init(httpd_req_t *req)
|
|||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("handler_init - Start");
|
LogFile.WriteHeapInfo("handler_init - Start");
|
||||||
printf("handler_doinit uri:\n"); printf(req->uri); printf("\n");
|
ESP_LOGD(TAGTFLITE, "handler_doinit uri: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* resp_str = "Init started<br>";
|
const char* resp_str = "Init started<br>";
|
||||||
@@ -167,7 +167,7 @@ esp_err_t handler_doflow(httpd_req_t *req)
|
|||||||
LogFile.WriteHeapInfo("handler_doflow - Start");
|
LogFile.WriteHeapInfo("handler_doflow - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("handler_doFlow uri: "); printf(req->uri); printf("\n");
|
ESP_LOGD(TAGTFLITE, "handler_doFlow uri: %s", req->uri);
|
||||||
|
|
||||||
if (flowisrunning)
|
if (flowisrunning)
|
||||||
{
|
{
|
||||||
@@ -199,7 +199,7 @@ esp_err_t handler_json(httpd_req_t *req)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
printf("handler_JSON uri:\n"); printf(req->uri); printf("\n");
|
ESP_LOGD(TAGTFLITE, "handler_JSON uri: %s", req->uri);
|
||||||
|
|
||||||
char _query[100];
|
char _query[100];
|
||||||
// char _size[10];
|
// char _size[10];
|
||||||
@@ -236,18 +236,18 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
|||||||
std::string _type = "value";
|
std::string _type = "value";
|
||||||
string zw;
|
string zw;
|
||||||
|
|
||||||
printf("handler_wasserzaehler uri:\n"); printf(req->uri); printf("\n");
|
ESP_LOGD(TAGTFLITE, "handler_wasserzaehler uri: %s", req->uri);
|
||||||
|
|
||||||
char _query[100];
|
char _query[100];
|
||||||
char _size[10];
|
char _size[10];
|
||||||
|
|
||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
// printf("Query: "); printf(_query); printf("\n");
|
// ESP_LOGD(TAGTFLITE, "Query: %s", _query);
|
||||||
if (httpd_query_key_value(_query, "all", _size, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "all", _size, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("all is found"); printf(_size); printf("\n");
|
ESP_LOGD(TAGTFLITE, "all is found%s", _size);
|
||||||
#endif
|
#endif
|
||||||
_all = true;
|
_all = true;
|
||||||
}
|
}
|
||||||
@@ -255,7 +255,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
|||||||
if (httpd_query_key_value(_query, "type", _size, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "type", _size, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("all is found"); printf(_size); printf("\n");
|
ESP_LOGD(TAGTFLITE, "all is found: %s", _size);
|
||||||
#endif
|
#endif
|
||||||
_type = std::string(_size);
|
_type = std::string(_size);
|
||||||
}
|
}
|
||||||
@@ -263,14 +263,14 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
|||||||
if (httpd_query_key_value(_query, "rawvalue", _size, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "rawvalue", _size, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("rawvalue is found"); printf(_size); printf("\n");
|
ESP_LOGD(TAGTFLITE, "rawvalue is found: %s", _size);
|
||||||
#endif
|
#endif
|
||||||
_rawValue = true;
|
_rawValue = true;
|
||||||
}
|
}
|
||||||
if (httpd_query_key_value(_query, "noerror", _size, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "noerror", _size, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("noerror is found"); printf(_size); printf("\n");
|
ESP_LOGD(TAGTFLITE, "noerror is found: %s", _size);
|
||||||
#endif
|
#endif
|
||||||
_noerror = true;
|
_noerror = true;
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
|||||||
if (_all)
|
if (_all)
|
||||||
{
|
{
|
||||||
httpd_resp_set_type(req, "text/plain");
|
httpd_resp_set_type(req, "text/plain");
|
||||||
printf("TYPE: %s\n", _type.c_str());
|
ESP_LOGD(TAGTFLITE, "TYPE: %s", _type.c_str());
|
||||||
int _intype = READOUT_TYPE_VALUE;
|
int _intype = READOUT_TYPE_VALUE;
|
||||||
if (_type == "prevalue")
|
if (_type == "prevalue")
|
||||||
_intype = READOUT_TYPE_PREVALUE;
|
_intype = READOUT_TYPE_PREVALUE;
|
||||||
@@ -292,7 +292,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
|||||||
|
|
||||||
|
|
||||||
zw = tfliteflow.getReadoutAll(_intype);
|
zw = tfliteflow.getReadoutAll(_intype);
|
||||||
printf("ZW: %s\n", zw.c_str());
|
ESP_LOGD(TAGTFLITE, "ZW: %s", zw.c_str());
|
||||||
if (zw.length() > 0)
|
if (zw.length() > 0)
|
||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
httpd_resp_sendstr_chunk(req, NULL);
|
httpd_resp_sendstr_chunk(req, NULL);
|
||||||
@@ -304,7 +304,7 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
|
|||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
|
|
||||||
string query = std::string(_query);
|
string query = std::string(_query);
|
||||||
// printf("Query: %s\n", query.c_str());
|
// ESP_LOGD(TAGTFLITE, "Query: %s, query.c_str());
|
||||||
if (query.find("full") != std::string::npos)
|
if (query.find("full") != std::string::npos)
|
||||||
{
|
{
|
||||||
string txt, zw;
|
string txt, zw;
|
||||||
@@ -380,7 +380,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
LogFile.WriteHeapInfo("handler_editflow - Start");
|
LogFile.WriteHeapInfo("handler_editflow - Start");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("handler_editflow uri: "); printf(req->uri); printf("\n");
|
ESP_LOGD(TAGTFLITE, "handler_editflow uri: %s", req->uri);
|
||||||
|
|
||||||
char _query[200];
|
char _query[200];
|
||||||
char _valuechar[30];
|
char _valuechar[30];
|
||||||
@@ -391,7 +391,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("task is found: %s\n", _valuechar);
|
ESP_LOGD(TAGTFLITE, "task is found: %s", _valuechar);
|
||||||
#endif
|
#endif
|
||||||
_task = string(_valuechar);
|
_task = string(_valuechar);
|
||||||
}
|
}
|
||||||
@@ -399,7 +399,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
|
|
||||||
if (_task.compare("tflite") == 0)
|
if (_task.compare("tflite") == 0)
|
||||||
{
|
{
|
||||||
printf("Get tflite list\n");
|
ESP_LOGD(TAGTFLITE, "Get tflite list");
|
||||||
return get_tflite_file_handler(req);
|
return get_tflite_file_handler(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,8 +414,8 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
out = string(_valuechar);
|
out = string(_valuechar);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("in: "); printf(in.c_str()); printf("\n");
|
ESP_LOGD(TAGTFLITE, "in: %s", in.c_str());
|
||||||
printf("out: "); printf(out.c_str()); printf("\n");
|
ESP_LOGD(TAGTFLITE, "out: %s", out.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
in = "/sdcard" + in;
|
in = "/sdcard" + in;
|
||||||
@@ -456,12 +456,12 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
dy = stoi(zw);
|
dy = stoi(zw);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("in: "); printf(in.c_str()); printf("\n");
|
ESP_LOGD(TAGTFLITE, "in: %s", in.c_str());
|
||||||
printf("out: "); printf(out.c_str()); printf("\n");
|
ESP_LOGD(TAGTFLITE, "out: %s", out.c_str());
|
||||||
printf("x: "); printf(zw.c_str()); printf("\n");
|
ESP_LOGD(TAGTFLITE, "x: %s", zw.c_str());
|
||||||
printf("y: "); printf(zw.c_str()); printf("\n");
|
ESP_LOGD(TAGTFLITE, "y: %s", zw.c_str());
|
||||||
printf("dx: "); printf(zw.c_str()); printf("\n");
|
ESP_LOGD(TAGTFLITE, "dx: %s", zw.c_str());
|
||||||
printf("dy: "); printf(zw.c_str()); printf("\n");
|
ESP_LOGD(TAGTFLITE, "dy: %s", zw.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "enhance", _valuechar, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "enhance", _valuechar, 10) == ESP_OK)
|
||||||
@@ -529,11 +529,11 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
|
// ESP_LOGD(TAGTFLITE, "Parameter host: %s", _host.c_str());
|
||||||
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
|
// string zwzw = "Do " + _task + " start\n"; ESP_LOGD(TAGTFLITE, zwzw.c_str());
|
||||||
Camera.SetBrightnessContrastSaturation(bri, con, sat);
|
Camera.SetBrightnessContrastSaturation(bri, con, sat);
|
||||||
Camera.SetLEDIntensity(intens);
|
Camera.SetLEDIntensity(intens);
|
||||||
printf("test_take - vor MakeImage");
|
ESP_LOGD(TAGTFLITE, "test_take - vor MakeImage");
|
||||||
std::string zw = tfliteflow.doSingleStep("[MakeImage]", _host);
|
std::string zw = tfliteflow.doSingleStep("[MakeImage]", _host);
|
||||||
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
|
||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
@@ -546,9 +546,9 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
|
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
|
||||||
_host = std::string(_valuechar);
|
_host = std::string(_valuechar);
|
||||||
}
|
}
|
||||||
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
|
// ESP_LOGD(TAGTFLITE, "Parameter host: %s", _host.c_str());
|
||||||
|
|
||||||
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
|
// string zwzw = "Do " + _task + " start\n"; ESP_LOGD(TAGTFLITE, zwzw.c_str());
|
||||||
std::string zw = tfliteflow.doSingleStep("[Alignment]", _host);
|
std::string zw = tfliteflow.doSingleStep("[Alignment]", _host);
|
||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
}
|
}
|
||||||
@@ -573,7 +573,7 @@ esp_err_t handler_statusflow(httpd_req_t *req)
|
|||||||
const char* resp_str;
|
const char* resp_str;
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("handler_prevalue:\n"); printf(req->uri); printf("\n");
|
ESP_LOGD(TAGTFLITE, "handler_prevalue: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string* zw = tfliteflow.getActStatus();
|
string* zw = tfliteflow.getActStatus();
|
||||||
@@ -651,7 +651,7 @@ esp_err_t handler_prevalue(httpd_req_t *req)
|
|||||||
string zw;
|
string zw;
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("handler_prevalue:\n"); printf(req->uri); printf("\n");
|
ESP_LOGD(TAGTFLITE, "handler_prevalue: %s", req->uri);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char _query[100];
|
char _query[100];
|
||||||
@@ -661,13 +661,13 @@ esp_err_t handler_prevalue(httpd_req_t *req)
|
|||||||
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Query: "); printf(_query); printf("\n");
|
ESP_LOGD(TAGTFLITE, "Query: %s", _query);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (httpd_query_key_value(_query, "value", _size, 10) == ESP_OK)
|
if (httpd_query_key_value(_query, "value", _size, 10) == ESP_OK)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Value: "); printf(_size); printf("\n");
|
ESP_LOGD(TAGTFLITE, "Value: %s", _size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,7 +703,7 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
{
|
{
|
||||||
int64_t fr_start, fr_delta_ms;
|
int64_t fr_start, fr_delta_ms;
|
||||||
|
|
||||||
printf("task_autodoFlow: start\r\n");
|
ESP_LOGD(TAGTFLITE, "task_autodoFlow: start");
|
||||||
doInit();
|
doInit();
|
||||||
gpio_handler_init();
|
gpio_handler_init();
|
||||||
|
|
||||||
@@ -718,24 +718,24 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
{
|
{
|
||||||
std::string _zw = "task_autodoFlow - next round - Round #" + std::to_string(++countRounds);
|
std::string _zw = "task_autodoFlow - next round - Round #" + std::to_string(++countRounds);
|
||||||
LogFile.WriteToFile(_zw);
|
LogFile.WriteToFile(_zw);
|
||||||
printf("Autoflow: start\n");
|
ESP_LOGD(TAGTFLITE, "Autoflow: start");
|
||||||
fr_start = esp_timer_get_time();
|
fr_start = esp_timer_get_time();
|
||||||
|
|
||||||
if (flowisrunning)
|
if (flowisrunning)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Autoflow: doFlow is already running!\n");
|
ESP_LOGD(TAGTFLITE, "Autoflow: doFlow is already running!");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Autoflow: doFlow is started\n");
|
ESP_LOGD(TAGTFLITE, "Autoflow: doFlow is started");
|
||||||
#endif
|
#endif
|
||||||
flowisrunning = true;
|
flowisrunning = true;
|
||||||
doflow();
|
doflow();
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("Remove older log files\n");
|
ESP_LOGD(TAGTFLITE, "Remove older log files");
|
||||||
#endif
|
#endif
|
||||||
LogFile.RemoveOld();
|
LogFile.RemoveOld();
|
||||||
}
|
}
|
||||||
@@ -747,18 +747,18 @@ void task_autodoFlow(void *pvParameter)
|
|||||||
stream << std::fixed << std::setprecision(1) << cputmp;
|
stream << std::fixed << std::setprecision(1) << cputmp;
|
||||||
string zwtemp = "CPU Temperature: " + stream.str();
|
string zwtemp = "CPU Temperature: " + stream.str();
|
||||||
LogFile.WriteToFile(zwtemp);
|
LogFile.WriteToFile(zwtemp);
|
||||||
printf("CPU Temperature: %.2f\n", cputmp);
|
ESP_LOGD(TAGTFLITE, "CPU Temperature: %.2f", cputmp);
|
||||||
fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000;
|
fr_delta_ms = (esp_timer_get_time() - fr_start) / 1000;
|
||||||
if (auto_intervall > fr_delta_ms)
|
if (auto_intervall > fr_delta_ms)
|
||||||
{
|
{
|
||||||
const TickType_t xDelay = (auto_intervall - fr_delta_ms) / portTICK_PERIOD_MS;
|
const TickType_t xDelay = (auto_intervall - fr_delta_ms) / portTICK_PERIOD_MS;
|
||||||
printf("Autoflow: sleep for : %ldms\n", (long) xDelay);
|
ESP_LOGD(TAGTFLITE, "Autoflow: sleep for: %ldms", (long) xDelay);
|
||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vTaskDelete(NULL); //Delete this task if it exits from the loop above
|
vTaskDelete(NULL); //Delete this task if it exits from the loop above
|
||||||
xHandletask_autodoFlow = NULL;
|
xHandletask_autodoFlow = NULL;
|
||||||
printf("task_autodoFlow: end\r\n");
|
ESP_LOGD(TAGTFLITE, "task_autodoFlow: end");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFliteDoAutoStart()
|
void TFliteDoAutoStart()
|
||||||
@@ -767,17 +767,17 @@ void TFliteDoAutoStart()
|
|||||||
|
|
||||||
int _i = configMINIMAL_STACK_SIZE;
|
int _i = configMINIMAL_STACK_SIZE;
|
||||||
|
|
||||||
printf("task_autodoFlow configMINIMAL_STACK_SIZE: %d\n", _i);
|
ESP_LOGD(TAGTFLITE, "task_autodoFlow configMINIMAL_STACK_SIZE: %d", _i);
|
||||||
printf("getESPHeapInfo: %s\n", getESPHeapInfo().c_str());
|
ESP_LOGD(TAGTFLITE, "getESPHeapInfo: %s", getESPHeapInfo().c_str());
|
||||||
|
|
||||||
xReturned = xTaskCreate(&task_autodoFlow, "task_autodoFlow", configMINIMAL_STACK_SIZE * 35, NULL, tskIDLE_PRIORITY+1, &xHandletask_autodoFlow);
|
xReturned = xTaskCreate(&task_autodoFlow, "task_autodoFlow", configMINIMAL_STACK_SIZE * 35, NULL, tskIDLE_PRIORITY+1, &xHandletask_autodoFlow);
|
||||||
if( xReturned != pdPASS )
|
if( xReturned != pdPASS )
|
||||||
{
|
{
|
||||||
|
|
||||||
//Memory: 64 --> 48 --> 35 --> 25
|
//Memory: 64 --> 48 --> 35 --> 25
|
||||||
printf("ERROR task_autodoFlow konnte nicht erzeugt werden !!\r\n");
|
ESP_LOGD(TAGTFLITE, "ERROR task_autodoFlow konnte nicht erzeugt werden!");
|
||||||
}
|
}
|
||||||
printf("getESPHeapInfo: %s\n", getESPHeapInfo().c_str());
|
ESP_LOGD(TAGTFLITE, "getESPHeapInfo: %s", getESPHeapInfo().c_str());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,14 +78,14 @@ void setup_time()
|
|||||||
ESP_LOGI(TAG, "The current date/time in Berlin is: %s", strftime_buf);
|
ESP_LOGI(TAG, "The current date/time in Berlin is: %s", strftime_buf);
|
||||||
|
|
||||||
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
||||||
printf("timeist %s\n", zw.c_str());
|
ESP_LOGD(TAG, "timeist %s", zw.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTimeZone(std::string _tzstring)
|
void setTimeZone(std::string _tzstring)
|
||||||
{
|
{
|
||||||
setenv("TZ", _tzstring.c_str(), 1);
|
setenv("TZ", _tzstring.c_str(), 1);
|
||||||
tzset();
|
tzset();
|
||||||
printf("TimeZone set to %s\n", _tzstring.c_str());
|
ESP_LOGD(TAG, "TimeZone set to %s", _tzstring.c_str());
|
||||||
_tzstring = "Time zone set to " + _tzstring;
|
_tzstring = "Time zone set to " + _tzstring;
|
||||||
LogFile.WriteToFile(_tzstring);
|
LogFile.WriteToFile(_tzstring);
|
||||||
}
|
}
|
||||||
@@ -109,14 +109,14 @@ static void obtain_time(void)
|
|||||||
|
|
||||||
void reset_servername(std::string _servername)
|
void reset_servername(std::string _servername)
|
||||||
{
|
{
|
||||||
printf("Set SNTP-Server: %s\n", _servername.c_str());
|
ESP_LOGD(TAG, "Set SNTP-Server: %s", _servername.c_str());
|
||||||
sntp_stop();
|
sntp_stop();
|
||||||
sntp_setoperatingmode(SNTP_OPMODE_POLL);
|
sntp_setoperatingmode(SNTP_OPMODE_POLL);
|
||||||
sntp_setservername(0, _servername.c_str());
|
sntp_setservername(0, _servername.c_str());
|
||||||
sntp_init();
|
sntp_init();
|
||||||
obtain_time();
|
obtain_time();
|
||||||
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
||||||
printf("Time ist %s\n", zw.c_str());
|
ESP_LOGD(TAG, "Time ist %s", zw.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initialize_sntp(void)
|
static void initialize_sntp(void)
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
static const char *TAG = "read_wlanini";
|
||||||
|
|
||||||
std::vector<string> ZerlegeZeileWLAN(std::string input, std::string _delimiter = "")
|
std::vector<string> ZerlegeZeileWLAN(std::string input, std::string _delimiter = "")
|
||||||
{
|
{
|
||||||
@@ -55,7 +57,7 @@ void LoadWlanFromFile(std::string fn, char *&_ssid, char *&_password, char *&_ho
|
|||||||
fn = FormatFileName(fn);
|
fn = FormatFileName(fn);
|
||||||
|
|
||||||
pFile = OpenFileAndWait(fn.c_str(), "r");
|
pFile = OpenFileAndWait(fn.c_str(), "r");
|
||||||
printf("file loaded\n");
|
ESP_LOGD(TAG, "file loaded");
|
||||||
|
|
||||||
if (pFile == NULL)
|
if (pFile == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -66,7 +68,7 @@ void LoadWlanFromFile(std::string fn, char *&_ssid, char *&_password, char *&_ho
|
|||||||
|
|
||||||
while ((line.size() > 0) || !(feof(pFile)))
|
while ((line.size() > 0) || !(feof(pFile)))
|
||||||
{
|
{
|
||||||
// printf("%s", line.c_str());
|
// ESP_LOGD(TAG, "%s", line.c_str());
|
||||||
zerlegt = ZerlegeZeileWLAN(line, "=");
|
zerlegt = ZerlegeZeileWLAN(line, "=");
|
||||||
zerlegt[0] = trim(zerlegt[0], " ");
|
zerlegt[0] = trim(zerlegt[0], " ");
|
||||||
|
|
||||||
@@ -198,7 +200,7 @@ bool ChangeHostName(std::string fn, std::string _newhostname)
|
|||||||
fn = FormatFileName(fn);
|
fn = FormatFileName(fn);
|
||||||
pFile = OpenFileAndWait(fn.c_str(), "r");
|
pFile = OpenFileAndWait(fn.c_str(), "r");
|
||||||
|
|
||||||
printf("file loaded\n");
|
ESP_LOGD(TAG, "file loaded\n");
|
||||||
|
|
||||||
if (pFile == NULL)
|
if (pFile == NULL)
|
||||||
return false;
|
return false;
|
||||||
@@ -209,7 +211,7 @@ bool ChangeHostName(std::string fn, std::string _newhostname)
|
|||||||
|
|
||||||
while ((line.size() > 0) || !(feof(pFile)))
|
while ((line.size() > 0) || !(feof(pFile)))
|
||||||
{
|
{
|
||||||
printf("%s", line.c_str());
|
ESP_LOGD(TAG, "%s", line.c_str());
|
||||||
zerlegt = ZerlegeZeileWLAN(line, "=");
|
zerlegt = ZerlegeZeileWLAN(line, "=");
|
||||||
zerlegt[0] = trim(zerlegt[0], " ");
|
zerlegt[0] = trim(zerlegt[0], " ");
|
||||||
|
|
||||||
@@ -242,13 +244,13 @@ bool ChangeHostName(std::string fn, std::string _newhostname)
|
|||||||
|
|
||||||
for (int i = 0; i < neuesfile.size(); ++i)
|
for (int i = 0; i < neuesfile.size(); ++i)
|
||||||
{
|
{
|
||||||
printf(neuesfile[i].c_str());
|
ESP_LOGD(TAG, "%s", neuesfile[i].c_str());
|
||||||
fputs(neuesfile[i].c_str(), pFile);
|
fputs(neuesfile[i].c_str(), pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
printf("*** Hostname update done ***\n");
|
ESP_LOGD(TAG, "*** Hostname update done ***");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ void task_NoSDBlink(void *pvParameter)
|
|||||||
|
|
||||||
TickType_t xDelay;
|
TickType_t xDelay;
|
||||||
xDelay = 100 / portTICK_PERIOD_MS;
|
xDelay = 100 / portTICK_PERIOD_MS;
|
||||||
printf("SD-Card could not be inialized - STOP THE PROGRAMM HERE\n");
|
ESP_LOGD(TAGMAIN, "SD-Card could not be inialized - STOP THE PROGRAMM HERE");
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@@ -146,15 +146,15 @@ extern "C" void app_main(void)
|
|||||||
string versionFormated = "Branch: '" + std::string(GIT_BRANCH) + "', Tag: '" + std::string(GIT_TAG) + \
|
string versionFormated = "Branch: '" + std::string(GIT_BRANCH) + "', Tag: '" + std::string(GIT_TAG) + \
|
||||||
"', Revision: " + std::string(GIT_REV) +", Date/Time: " + std::string(BUILD_TIME);
|
"', Revision: " + std::string(GIT_REV) +", Date/Time: " + std::string(BUILD_TIME);
|
||||||
|
|
||||||
printf("=============================================================================================\n");
|
ESP_LOGD(TAGMAIN, "=============================================================================================");
|
||||||
printf("%s\n", versionFormated.c_str());
|
ESP_LOGD(TAGMAIN, "%s", versionFormated.c_str());
|
||||||
printf("=============================================================================================\n");
|
ESP_LOGD(TAGMAIN, "=============================================================================================");
|
||||||
|
|
||||||
PowerResetCamera();
|
PowerResetCamera();
|
||||||
esp_err_t cam = Camera.InitCam();
|
esp_err_t cam = Camera.InitCam();
|
||||||
Camera.LightOnOff(false);
|
Camera.LightOnOff(false);
|
||||||
xDelay = 2000 / portTICK_PERIOD_MS;
|
xDelay = 2000 / portTICK_PERIOD_MS;
|
||||||
printf("After camera initialization: sleep for : %ldms\n", (long) xDelay);
|
ESP_LOGD(TAGMAIN, "After camera initialization: sleep for: %ldms", (long) xDelay);
|
||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
|
|
||||||
|
|
||||||
@@ -171,30 +171,30 @@ extern "C" void app_main(void)
|
|||||||
|
|
||||||
if (ssid != NULL && passwd != NULL)
|
if (ssid != NULL && passwd != NULL)
|
||||||
#ifdef __HIDE_PASSWORD
|
#ifdef __HIDE_PASSWORD
|
||||||
printf("\nWLan: %s, XXXXXX\n", ssid);
|
ESP_LOGD(TAGMAIN, "WLan: %s, XXXXXX", ssid);
|
||||||
#else
|
#else
|
||||||
printf("\nWLan: %s, %s\n", ssid, passwd);
|
ESP_LOGD(TAGMAIN, "WLan: %s, %s", ssid, passwd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
else
|
else
|
||||||
printf("No SSID and PASSWORD set!!!");
|
ESP_LOGD(TAGMAIN, "No SSID and PASSWORD set!!!");
|
||||||
|
|
||||||
if (hostname != NULL)
|
if (hostname != NULL)
|
||||||
printf("Hostename: %s\n", hostname);
|
ESP_LOGD(TAGMAIN, "Hostename: %s", hostname);
|
||||||
else
|
else
|
||||||
printf("Hostname not set.\n");
|
ESP_LOGD(TAGMAIN, "Hostname not set");
|
||||||
|
|
||||||
if (ip != NULL && gateway != NULL && netmask != NULL)
|
if (ip != NULL && gateway != NULL && netmask != NULL)
|
||||||
printf("Fixed IP: %s, Gateway %s, Netmask %s\n", ip, gateway, netmask);
|
ESP_LOGD(TAGMAIN, "Fixed IP: %s, Gateway %s, Netmask %s", ip, gateway, netmask);
|
||||||
if (dns != NULL)
|
if (dns != NULL)
|
||||||
printf("DNS IP: %s\n", dns);
|
ESP_LOGD(TAGMAIN, "DNS IP: %s", dns);
|
||||||
|
|
||||||
|
|
||||||
wifi_init_sta(ssid, passwd, hostname, ip, gateway, netmask, dns);
|
wifi_init_sta(ssid, passwd, hostname, ip, gateway, netmask, dns);
|
||||||
|
|
||||||
|
|
||||||
xDelay = 2000 / portTICK_PERIOD_MS;
|
xDelay = 2000 / portTICK_PERIOD_MS;
|
||||||
printf("main: sleep for : %ldms\n", (long) xDelay);
|
ESP_LOGD(TAGMAIN, "main: sleep for: %ldms", (long) xDelay);
|
||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
setup_time();
|
setup_time();
|
||||||
setBootTime();
|
setBootTime();
|
||||||
@@ -205,14 +205,14 @@ extern "C" void app_main(void)
|
|||||||
LogFile.SwitchOnOff(false);
|
LogFile.SwitchOnOff(false);
|
||||||
|
|
||||||
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
std::string zw = gettimestring("%Y%m%d-%H%M%S");
|
||||||
printf("time %s\n", zw.c_str());
|
ESP_LOGD(TAGMAIN, "time %s", zw.c_str());
|
||||||
|
|
||||||
size_t _hsize = getESPHeapSize();
|
size_t _hsize = getESPHeapSize();
|
||||||
if (_hsize < 4000000)
|
if (_hsize < 4000000)
|
||||||
{
|
{
|
||||||
std::string _zws = "Not enough PSRAM available. Expected 4.194.304 MByte - available: " + std::to_string(_hsize);
|
std::string _zws = "Not enough PSRAM available. Expected 4.194.304 MByte - available: " + std::to_string(_hsize);
|
||||||
_zws = _zws + "\nEither not initialzed, too small (2MByte only) or not present at all. Firmware cannot start!!";
|
_zws = _zws + "\nEither not initialzed, too small (2MByte only) or not present at all. Firmware cannot start!!";
|
||||||
printf(_zws.c_str());
|
ESP_LOGD(TAGMAIN, "%s", _zws.c_str());
|
||||||
LogFile.SwitchOnOff(true);
|
LogFile.SwitchOnOff(true);
|
||||||
LogFile.WriteToFile(_zws);
|
LogFile.WriteToFile(_zws);
|
||||||
LogFile.SwitchOnOff(false);
|
LogFile.SwitchOnOff(false);
|
||||||
@@ -243,10 +243,10 @@ extern "C" void app_main(void)
|
|||||||
|
|
||||||
|
|
||||||
xDelay = 2000 / portTICK_PERIOD_MS;
|
xDelay = 2000 / portTICK_PERIOD_MS;
|
||||||
printf("main: sleep for : %ldms\n", (long) xDelay*10);
|
ESP_LOGD(TAGMAIN, "main: sleep for: %ldms", (long) xDelay*10);
|
||||||
vTaskDelay( xDelay );
|
vTaskDelay( xDelay );
|
||||||
|
|
||||||
printf("starting server\n");
|
ESP_LOGD(TAGMAIN, "starting server");
|
||||||
|
|
||||||
server = start_webserver();
|
server = start_webserver();
|
||||||
register_server_camera_uri(server);
|
register_server_camera_uri(server);
|
||||||
@@ -256,10 +256,10 @@ extern "C" void app_main(void)
|
|||||||
|
|
||||||
gpio_handler_create(server);
|
gpio_handler_create(server);
|
||||||
|
|
||||||
printf("vor reg server main\n");
|
ESP_LOGD(TAGMAIN, "vor reg server main");
|
||||||
register_server_main_uri(server, "/sdcard");
|
register_server_main_uri(server, "/sdcard");
|
||||||
|
|
||||||
printf("vor dotautostart\n");
|
ESP_LOGD(TAGMAIN, "vor dotautostart");
|
||||||
TFliteDoAutoStart();
|
TFliteDoAutoStart();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "test_flow_postrocess_helper.h"
|
#include "test_flow_postrocess_helper.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
static const char *TAG = "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, "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, "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, "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, "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, "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, "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, "Setting decimal shift on number: %d to %f", _n, _analogdigitTransistionStart);
|
||||||
(*NUMBERS)[_n]->AnalogDigitalTransitionStart = _analogdigitTransistionStart;
|
(*NUMBERS)[_n]->AnalogDigitalTransitionStart = _analogdigitTransistionStart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user