mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-13 15:06:53 +03:00
gpio handler works again
remove memory leak in FlowDigit
This commit is contained in:
@@ -14,13 +14,14 @@
|
||||
#include <vector>
|
||||
//#include <regex>
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
#include "server_GPIO.h"
|
||||
|
||||
#include "ClassLogFile.h"
|
||||
#include "configFile.h"
|
||||
#include "Helper.h"
|
||||
#include "interface_mqtt.h"
|
||||
#include "ClassFlowMQTT.h"
|
||||
|
||||
static const char *TAG_SERVERGPIO = "server_GPIO";
|
||||
QueueHandle_t gpio_queue_handle = NULL;
|
||||
@@ -481,3 +482,37 @@ gpio_int_type_t GpioHandler::resolveIntType(std::string input)
|
||||
|
||||
return GPIO_INTR_DISABLE;
|
||||
}
|
||||
|
||||
static GpioHandler *gpioHandler = NULL;
|
||||
|
||||
void gpio_handler_create(httpd_handle_t server)
|
||||
{
|
||||
if (gpioHandler == NULL)
|
||||
gpioHandler = new GpioHandler(CONFIG_FILE, server);
|
||||
}
|
||||
|
||||
void gpio_handler_init()
|
||||
{
|
||||
if (gpioHandler != NULL) {
|
||||
gpioHandler->init();
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_handler_deinit() {
|
||||
if (gpioHandler != NULL) {
|
||||
gpioHandler->deinit();
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_handler_destroy()
|
||||
{
|
||||
if (gpioHandler != NULL) {
|
||||
delete gpioHandler;
|
||||
gpioHandler = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GpioHandler* gpio_handler_get()
|
||||
{
|
||||
return gpioHandler;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,12 @@ private:
|
||||
gpio_int_type_t resolveIntType(std::string input);
|
||||
};
|
||||
|
||||
void GpioHandlerStart();
|
||||
void gpio_handler_create(httpd_handle_t server);
|
||||
void gpio_handler_init();
|
||||
void gpio_handler_deinit();
|
||||
void gpio_handler_destroy();
|
||||
GpioHandler* gpio_handler_get();
|
||||
|
||||
|
||||
|
||||
#endif //SERVER_GPIO_H
|
||||
@@ -284,7 +284,11 @@ bool ClassFlowAnalog::doNeuralNetwork(string time)
|
||||
string zwcnn = "/sdcard" + cnnmodelfile;
|
||||
zwcnn = FormatFileName(zwcnn);
|
||||
printf(zwcnn.c_str());printf("\n");
|
||||
tflite->LoadModel(zwcnn);
|
||||
if (!tflite->LoadModel(zwcnn)) {
|
||||
printf("Can't read model file /sdcard%s\n", cnnmodelfile.c_str());
|
||||
delete tflite;
|
||||
return false;
|
||||
}
|
||||
tflite->MakeAllocate();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ bool ClassFlowControll::doFlow(string time)
|
||||
int repeat = 0;
|
||||
|
||||
#ifdef DEBUG_DETAIL_ON
|
||||
LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow - Start");
|
||||
LogFile.WriteHeapInfo("ClassFlowControll::doFlow - Start");
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < FlowControll.size(); ++i)
|
||||
@@ -238,7 +238,7 @@ bool ClassFlowControll::doFlow(string time)
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DETAIL_ON
|
||||
LogFile.WriteHeapInfo("ClassFlowAnalog::doFlow");
|
||||
LogFile.WriteHeapInfo("ClassFlowControll::doFlow");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -243,6 +243,7 @@ bool ClassFlowDigit::doNeuralNetwork(string time)
|
||||
printf(zwcnn.c_str());printf("\n");
|
||||
if (!tflite->LoadModel(zwcnn)) {
|
||||
printf("Can't read model file /sdcard%s\n", cnnmodelfile.c_str());
|
||||
delete tflite;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ ClassLogFile LogFile("/sdcard/log/message", "log_%Y-%m-%d.txt");
|
||||
|
||||
void ClassLogFile::WriteHeapInfo(std::string _id)
|
||||
{
|
||||
std::string _zw = "\t" + _id;
|
||||
std::string _zw = "\t" + _id;
|
||||
if (loglevel > 0)
|
||||
_zw = _zw + "\t" + getESPHeapInfo();
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
|
||||
|
||||
idf_component_register(SRCS ${app_sources}
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES main jomjol_image_proc jomjol_logfile esp_http_server esp32-camera-master jomjol_controlcamera jomjol_flowcontroll jomjol_helper)
|
||||
REQUIRES jomjol_image_proc jomjol_logfile esp_http_server esp32-camera-master jomjol_controlcamera jomjol_flowcontroll jomjol_helper)
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "ClassFlowControll.h"
|
||||
|
||||
#include "ClassLogFile.h"
|
||||
#include "server_main.h"
|
||||
#include "server_GPIO.h"
|
||||
|
||||
#define DEBUG_DETAIL_ON
|
||||
|
||||
|
||||
@@ -137,9 +137,7 @@ void task_NoSDBlink(void *pvParameter)
|
||||
|
||||
esp_err_t handler_gpio(httpd_req_t *req)
|
||||
{
|
||||
printf("freemem -3-: %u\n", esp_get_free_heap_size());
|
||||
gpio_handler_init();
|
||||
printf("freemem -4-: %u\n", esp_get_free_heap_size());
|
||||
|
||||
char resp_str [30];
|
||||
sprintf(resp_str, "OK. freemem %u", esp_get_free_heap_size());
|
||||
@@ -219,7 +217,7 @@ extern "C" void app_main(void)
|
||||
camuri.user_ctx = (void*)server;
|
||||
httpd_register_uri_handler(server, &camuri);
|
||||
|
||||
gpio_handler_create();
|
||||
gpio_handler_create(server);
|
||||
|
||||
printf("vor reg server main\n");
|
||||
register_server_main_uri(server, "/sdcard");
|
||||
|
||||
@@ -25,9 +25,6 @@ std::string starttime = "";
|
||||
|
||||
static const char *TAG_SERVERMAIN = "server-main";
|
||||
|
||||
static GpioHandler *gpioHandler = NULL;
|
||||
|
||||
|
||||
/* An HTTP GET handler */
|
||||
esp_err_t info_get_handler(httpd_req_t *req)
|
||||
{
|
||||
@@ -454,35 +451,3 @@ void connect_handler(void* arg, esp_event_base_t event_base,
|
||||
*server = start_webserver();
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_handler_create()
|
||||
{
|
||||
if (gpioHandler == NULL)
|
||||
gpioHandler = new GpioHandler(CONFIG_FILE, server);
|
||||
}
|
||||
|
||||
void gpio_handler_init()
|
||||
{
|
||||
if (gpioHandler != NULL) {
|
||||
gpioHandler->init();
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_handler_deinit() {
|
||||
if (gpioHandler != NULL) {
|
||||
gpioHandler->deinit();
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_handler_destroy()
|
||||
{
|
||||
if (gpioHandler != NULL) {
|
||||
delete gpioHandler;
|
||||
gpioHandler = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GpioHandler* gpio_handler_get()
|
||||
{
|
||||
return gpioHandler;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,6 @@
|
||||
|
||||
extern httpd_handle_t server;
|
||||
|
||||
void gpio_handler_create();
|
||||
void gpio_handler_init();
|
||||
void gpio_handler_deinit();
|
||||
void gpio_handler_destroy();
|
||||
GpioHandler* gpio_handler_get();
|
||||
|
||||
httpd_handle_t start_webserver(void);
|
||||
|
||||
void register_server_main_uri(httpd_handle_t server, const char *base_path);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const char* GIT_REV="7b8f10a";
|
||||
const char* GIT_REV="b205326";
|
||||
const char* GIT_TAG="";
|
||||
const char* GIT_BRANCH="gpio-handler";
|
||||
const char* BUILD_TIME="2021-07-03 00:47";
|
||||
const char* BUILD_TIME="2021-07-05 23:02";
|
||||
@@ -1,4 +1,4 @@
|
||||
const char* GIT_REV="7b8f10a";
|
||||
const char* GIT_REV="b205326";
|
||||
const char* GIT_TAG="";
|
||||
const char* GIT_BRANCH="gpio-handler";
|
||||
const char* BUILD_TIME="2021-07-03 00:46";
|
||||
const char* BUILD_TIME="2021-07-05 23:02";
|
||||
Reference in New Issue
Block a user