This commit is contained in:
jomjol
2020-09-26 19:29:39 +02:00
parent d428abc12f
commit 5a98b3d0bb
20 changed files with 312 additions and 161 deletions

View File

@@ -27,7 +27,9 @@ A 3d-printable housing can be found here: https://www.thingiverse.com/thing:4571
##### Rolling - (2020-09-25) ##### Rolling - (2020-09-26)
* Integration of version info (menu: SYSTEM --> INFO)
* based on v2.1.0 (2020-09-25) * based on v2.1.0 (2020-09-25)

View File

@@ -4,5 +4,12 @@ list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/proto
set(PROJECT_VER "0.0.9.3") set(PROJECT_VER "0.0.9.3")
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
${CMAKE_CURRENT_BINARY_DIR}/_version.cpp
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_SOURCE_DIR}/version.cmake)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(esp32cam-server-only) project(esp32cam-server-only)

View File

@@ -258,7 +258,7 @@ static esp_err_t download_get_handler(httpd_req_t *req)
return ESP_FAIL; return ESP_FAIL;
} }
esp_err_t res = httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*");
ESP_LOGI(TAG, "Sending file : %s (%ld bytes)...", filename, file_stat.st_size); ESP_LOGI(TAG, "Sending file : %s (%ld bytes)...", filename, file_stat.st_size);
set_content_type_from_file(req, filename); set_content_type_from_file(req, filename);
@@ -437,7 +437,6 @@ static esp_err_t delete_post_handler(httpd_req_t *req)
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
char _query[200]; char _query[200];
char _filename[30];
char _valuechar[30]; char _valuechar[30];
std::string fn = "/sdcard/firmware/"; std::string fn = "/sdcard/firmware/";
std::string _task; std::string _task;
@@ -576,8 +575,6 @@ void unzip(std::string _in_zip_file, std::string _target_directory){
size_t uncomp_size; size_t uncomp_size;
mz_zip_archive zip_archive; mz_zip_archive zip_archive;
void* p; void* p;
const int N = 50;
char data[2048];
char archive_filename[64]; char archive_filename[64];
std::string zw; std::string zw;
// static const char* s_Test_archive_filename = "testhtml.zip"; // static const char* s_Test_archive_filename = "testhtml.zip";

View File

@@ -171,8 +171,14 @@ bool ClassFlowAnalog::doAlignAndCut(string time)
return false; return false;
} }
if (input_roi.length() > 0) if (input_roi.length() > 0){
img_roi = new CImageBasis(input_roi); img_roi = new CImageBasis(input_roi);
if (!img_roi->ImageOkay()){
LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut ImageRoi not okay!");
delete img_roi;
return false;
}
}
for (int i = 0; i < ROI.size(); ++i) for (int i = 0; i < ROI.size(); ++i)
{ {

View File

@@ -6,7 +6,6 @@
#include "server_ota.h" #include "server_ota.h"
std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
bool found = false;
std::string _classname = ""; std::string _classname = "";
std::string result = ""; std::string result = "";
if (_stepname.compare("[MakeImage]") == 0){ if (_stepname.compare("[MakeImage]") == 0){
@@ -29,7 +28,6 @@ std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _
// printf(FlowControll[i]->name().c_str()); printf("\n"); // printf(FlowControll[i]->name().c_str()); printf("\n");
FlowControll[i]->doFlow(""); FlowControll[i]->doFlow("");
result = FlowControll[i]->getHTMLSingleStep(_host); result = FlowControll[i]->getHTMLSingleStep(_host);
found = true;
} }
return result; return result;

View File

@@ -149,8 +149,15 @@ bool ClassFlowDigit::doAlignAndCut(string time)
return false; return false;
} }
if (input_roi.length() > 0) if (input_roi.length() > 0){
img_roi = new CImageBasis(input_roi); img_roi = new CImageBasis(input_roi);
if (!img_roi->ImageOkay()){
LogFile.WriteToFile("ClassFlowAnalog::doAlignAndCut ImageRoi not okay!");
delete img_roi;
return false;
}
}
for (int i = 0; i < ROI.size(); ++i) for (int i = 0; i < ROI.size(); ++i)

View File

@@ -331,7 +331,13 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
zw = ErsetzteN(ReturnRawValue); zw = ErsetzteN(ReturnRawValue);
Value = std::stof(zw); Value = std::stof(zw);
if (checkDigitIncreaseConsistency)
{
// Value = checkDigitConsistency(Value, DecimalShift, isanalog);
}
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift); zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
if ((!AllowNegativeRates) && (Value < PreValue)) if ((!AllowNegativeRates) && (Value < PreValue))
@@ -413,39 +419,40 @@ string ClassFlowPostProcessing::ErsetzteN(string input)
return input; return input;
} }
string ClassFlowPostProcessing::checkDigitConsistency(string input, int _decilamshift, int lastvalueanalog){ float ClassFlowPostProcessing::checkDigitConsistency(float input, int _decilamshift, bool _isanalog){
/* int aktdigit, olddigit;
if (checkDigitIncreaseConsistency && lastvalueanalog > -1) int aktdigit_before, olddigit_before;
int pot, pot_max;
float zw;
pot = _decilamshift;
if (!_isanalog) // falls es keine analogwerte gibt, kann die letzte nicht bewerte werden
{ {
int zifferIST; pot++;
// int substrakt = 0;
bool lastcorrected = false;
for (int i = input.length() - 1; i >= 0; --i)
{
zifferIST = input[i] - 48; //std::stoi(std::string(input[i]));
if (lastcorrected)
{
zifferIST--;
input[i] = zifferIST + 48;
lastcorrected = false;
}
pot = posPunkt - i - 1;
zw = PreValue / pow(10, pot);
ziffer = ((int) zw) % 10;
if (zifferIST < ziffer)
{
if (lastvalueanalog >= 7)
{
input[i] = ziffer + 48;
lastvalueanalog = ziffer;
lastcorrected = true;
}
}
}
} }
*/ pot_max = ((int) log10(input)) + 1;
while (pot <= pot_max)
{
zw = input / pow(10, pot-1);
aktdigit_before = ((int) zw) % 10;
zw = PreValue / pow(10, pot-1);
olddigit_before = ((int) zw) % 10;
zw = input / pow(10, pot);
aktdigit = ((int) zw) % 10;
zw = PreValue / pow(10, pot);
olddigit = ((int) zw) % 10;
if (aktdigit != olddigit) {
if (olddigit_before >= aktdigit_before) // stelle vorher hat noch keinen Nulldurchgang --> nachfolgestelle sollte sich nicht verändern
{
input = input + ((float) (olddigit - aktdigit)) * pow(10, pot); // Neue Digit wird durch alte Digit ersetzt;
}
}
pot++;
}
return input; return input;
} }

View File

@@ -29,7 +29,7 @@ protected:
string ShiftDecimal(string in, int _decShift); string ShiftDecimal(string in, int _decShift);
string ErsetzteN(string); string ErsetzteN(string);
string checkDigitConsistency(string, int _decilamshift, int lastvalueanalog = -1); float checkDigitConsistency(float input, int _decilamshift, bool _isanalog);
string RundeOutput(float _in, int _anzNachkomma); string RundeOutput(float _in, int _anzNachkomma);
public: public:

View File

@@ -528,8 +528,6 @@ void CAlignAndCutImage::CutAndSave(std::string _template1, int x1, int y1, int d
int memsize = dx * dy * this->channels; int memsize = dx * dy * this->channels;
uint8_t* odata = (unsigned char*)GET_MEMORY(memsize); uint8_t* odata = (unsigned char*)GET_MEMORY(memsize);
int x_source, y_source;
stbi_uc* p_target; stbi_uc* p_target;
stbi_uc* p_source; stbi_uc* p_source;

View File

@@ -1,6 +1,56 @@
# This file was automatically generated for projects # This file was automatically generated for projects
# without default 'CMakeLists.txt' file. # without default 'CMakeLists.txt' file.
##################################################################
##################################################################
execute_process(COMMAND git log --pretty=format:'%h' -n 1
OUTPUT_VARIABLE GIT_REV
ERROR_QUIET)
string(TIMESTAMP BUILD_TIME "%Y-%m-%d %H:%M")
# Check whether we got any revision (which isn't
# always the case, e.g. when someone downloaded a zip
# file from Github instead of a checkout)
if ("${GIT_REV}" STREQUAL "")
set(GIT_REV "N/A")
set(GIT_DIFF "")
set(GIT_TAG "N/A")
set(GIT_BRANCH "N/A")
else()
execute_process(
COMMAND bash -c "git diff --quiet --exit-code || echo +"
OUTPUT_VARIABLE GIT_DIFF)
execute_process(
COMMAND git describe --exact-match --tags
OUTPUT_VARIABLE GIT_TAG ERROR_QUIET)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE GIT_BRANCH)
string(STRIP "${GIT_REV}" GIT_REV)
string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV)
string(STRIP "${GIT_DIFF}" GIT_DIFF)
string(STRIP "${GIT_TAG}" GIT_TAG)
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
endif()
set(VERSION "const char* GIT_REV=\"${GIT_REV}${GIT_DIFF}\";
const char* GIT_TAG=\"${GIT_TAG}\";
const char* GIT_BRANCH=\"${GIT_BRANCH}\";
const char* BUILD_TIME=\"${BUILD_TIME}\";")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp VERSION_)
else()
set(VERSION_ "")
endif()
if (NOT "${VERSION}" STREQUAL "${VERSION_}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp "${VERSION}")
endif()
#######################################################################
#######################################################################
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*) FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)

View File

@@ -3,9 +3,12 @@
#include <string> #include <string>
#include "server_help.h" #include "server_help.h"
#include "ClassLogFile.h"
#include "time_sntp.h" #include "time_sntp.h"
#include "version.h"
httpd_handle_t server = NULL; httpd_handle_t server = NULL;
@@ -14,80 +17,73 @@ std::string starttime = "";
/* An HTTP GET handler */ /* An HTTP GET handler */
esp_err_t hello_get_handler(httpd_req_t *req) esp_err_t info_get_handler(httpd_req_t *req)
{ {
char* buf; LogFile.WriteToFile("info_get_handler");
size_t buf_len; char _query[200];
printf("req uri:\n"); char _valuechar[30];
printf(req->uri); std::string _task;
printf("\n");
/* Get header value string length and allocate memory for length + 1, if (httpd_req_get_url_query_str(req, _query, 200) == ESP_OK)
* extra byte for null termination */ {
buf_len = httpd_req_get_hdr_value_len(req, "Host") + 1; printf("Query: "); printf(_query); printf("\n");
if (buf_len > 1) {
buf = (char*) malloc(buf_len); if (httpd_query_key_value(_query, "type", _valuechar, 30) == ESP_OK)
/* Copy null terminated value string into buffer */ {
if (httpd_req_get_hdr_value_str(req, "Host", buf, buf_len) == ESP_OK) { printf("type is found"); printf(_valuechar); printf("\n");
ESP_LOGI(TAG, "Found header => Host: %s", buf); _task = std::string(_valuechar);
} }
free(buf); };
if (_task.compare("GitBranch") == 0)
{
std::string zw;
zw = std::string(libfive_git_branch());
httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
} }
buf_len = httpd_req_get_hdr_value_len(req, "Test-Header-2") + 1;
if (buf_len > 1) { if (_task.compare("GitTag") == 0)
buf = (char*) malloc(buf_len); {
if (httpd_req_get_hdr_value_str(req, "Test-Header-2", buf, buf_len) == ESP_OK) { std::string zw;
ESP_LOGI(TAG, "Found header => Test-Header-2: %s", buf); zw = std::string(libfive_git_version());
} httpd_resp_sendstr_chunk(req, zw.c_str());
free(buf); httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
} }
buf_len = httpd_req_get_hdr_value_len(req, "Test-Header-1") + 1;
if (buf_len > 1) {
buf = (char*) malloc(buf_len); if (_task.compare("GitRevision") == 0)
if (httpd_req_get_hdr_value_str(req, "Test-Header-1", buf, buf_len) == ESP_OK) { {
ESP_LOGI(TAG, "Found header => Test-Header-1: %s", buf); std::string zw;
} zw = std::string(libfive_git_revision());
free(buf); httpd_resp_sendstr_chunk(req, zw.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
} }
/* Read URL query string length and allocate memory for length + 1, if (_task.compare("BuildTime") == 0)
* extra byte for null termination */ {
buf_len = httpd_req_get_url_query_len(req) + 1; std::string zw;
if (buf_len > 1) { zw = std::string(build_time());
buf = (char*) malloc(buf_len); httpd_resp_sendstr_chunk(req, zw.c_str());
if (httpd_req_get_url_query_str(req, buf, buf_len) == ESP_OK) { httpd_resp_sendstr_chunk(req, NULL);
ESP_LOGI(TAG, "Found URL query => %s", buf); return ESP_OK;
char param[32];
/* Get value of expected key from query string */
if (httpd_query_key_value(buf, "query1", param, sizeof(param)) == ESP_OK) {
ESP_LOGI(TAG, "Found URL query parameter => query1=%s", param);
}
if (httpd_query_key_value(buf, "query3", param, sizeof(param)) == ESP_OK) {
ESP_LOGI(TAG, "Found URL query parameter => query3=%s", param);
}
if (httpd_query_key_value(buf, "query2", param, sizeof(param)) == ESP_OK) {
ESP_LOGI(TAG, "Found URL query parameter => query2=%s", param);
}
}
free(buf);
} }
/* Set some custom headers */ if (_task.compare("GitBaseBranch") == 0)
httpd_resp_set_hdr(req, "Custom-Header-1", "Custom-Value-1"); {
httpd_resp_set_hdr(req, "Custom-Header-2", "Custom-Value-2"); std::string zw;
zw = std::string(git_base_branch());
/* Send response with custom headers and body set as the httpd_resp_sendstr_chunk(req, zw.c_str());
* string passed in user context*/ httpd_resp_sendstr_chunk(req, NULL);
const char* resp_str = (const char*) req->user_ctx; return ESP_OK;
httpd_resp_send(req, resp_str, strlen(resp_str));
/* After sending the HTTP response the old HTTP request
* headers are lost. Check if HTTP request headers can be read now. */
if (httpd_req_get_hdr_value_len(req, "Host") == 0) {
ESP_LOGI(TAG, "Request headers lost");
} }
return ESP_OK; return ESP_OK;
} }
@@ -205,6 +201,15 @@ esp_err_t img_tmp_handler(httpd_req_t *req)
void register_server_main_uri(httpd_handle_t server, const char *base_path) void register_server_main_uri(httpd_handle_t server, const char *base_path)
{ {
httpd_uri_t info_get_handle = {
.uri = "/version", // Match all URIs of type /path/to/file
.method = HTTP_GET,
.handler = info_get_handler,
.user_ctx = (void*) base_path // Pass server data as context
};
httpd_register_uri_handler(server, &info_get_handle);
httpd_uri_t starttime_tmp_handle = { httpd_uri_t starttime_tmp_handle = {
.uri = "/starttime", // Match all URIs of type /path/to/file .uri = "/starttime", // Match all URIs of type /path/to/file
.method = HTTP_GET, .method = HTTP_GET,
@@ -260,14 +265,6 @@ httpd_handle_t start_webserver(void)
// config.uri_match_fn = NULL; // config.uri_match_fn = NULL;
config.uri_match_fn = httpd_uri_match_wildcard; config.uri_match_fn = httpd_uri_match_wildcard;
httpd_uri_t hll = {};
hll.uri = "/hello";
hll.method = HTTP_GET;
hll.handler = hello_get_handler;
hll.user_ctx = (void*) "Hello World!";
starttime = gettimestring("%Y%m%d-%H%M%S"); starttime = gettimestring("%Y%m%d-%H%M%S");
// Start the httpd server // Start the httpd server
@@ -275,7 +272,6 @@ httpd_handle_t start_webserver(void)
if (httpd_start(&server, &config) == ESP_OK) { if (httpd_start(&server, &config) == ESP_OK) {
// Set URI handlers // Set URI handlers
ESP_LOGI(TAG, "Registering URI handlers"); ESP_LOGI(TAG, "Registering URI handlers");
httpd_register_uri_handler(server, &hll);
return server; return server;
} }

View File

@@ -1,43 +0,0 @@
execute_process(COMMAND git log --pretty=format:'%h' -n 1
OUTPUT_VARIABLE GIT_REV
ERROR_QUIET)
# Check whether we got any revision (which isn't
# always the case, e.g. when someone downloaded a zip
# file from Github instead of a checkout)
if ("${GIT_REV}" STREQUAL "")
set(GIT_REV "N/A")
set(GIT_DIFF "")
set(GIT_TAG "N/A")
set(GIT_BRANCH "N/A")
else()
execute_process(
COMMAND bash -c "git diff --quiet --exit-code || echo +"
OUTPUT_VARIABLE GIT_DIFF)
execute_process(
COMMAND git describe --exact-match --tags
OUTPUT_VARIABLE GIT_TAG ERROR_QUIET)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE GIT_BRANCH)
string(STRIP "${GIT_REV}" GIT_REV)
string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV)
string(STRIP "${GIT_DIFF}" GIT_DIFF)
string(STRIP "${GIT_TAG}" GIT_TAG)
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
endif()
set(VERSION "const char* GIT_REV=\"${GIT_REV}${GIT_DIFF}\";
const char* GIT_TAG=\"${GIT_TAG}\";
const char* GIT_BRANCH=\"${GIT_BRANCH}\";")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp VERSION_)
else()
set(VERSION_ "")
endif()
if (NOT "${VERSION}" STREQUAL "${VERSION_}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp "${VERSION}")
endif()

4
code/src/version.cpp Normal file
View File

@@ -0,0 +1,4 @@
const char* GIT_REV="d428abc";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2020-09-26 18:56";

38
code/src/version.h Normal file
View File

@@ -0,0 +1,38 @@
// These variables are autogenerated and compiled
// into the library by the version.cmake script
extern "C"
{
extern const char* GIT_TAG;
extern const char* GIT_REV;
extern const char* GIT_BRANCH;
extern const char* BUILD_TIME;
}
const char* GIT_BASE_BRANCH = "master - v2.1.0 - 2020-09-25";
const char* git_base_branch(void)
{
return GIT_BASE_BRANCH;
}
const char* build_time(void)
{
return BUILD_TIME;
}
const char* libfive_git_version(void)
{
return GIT_TAG;
}
const char* libfive_git_revision(void)
{
return GIT_REV;
}
const char* libfive_git_branch(void)
{
return GIT_BRANCH;
}

4
code/version.cpp Normal file
View File

@@ -0,0 +1,4 @@
const char* GIT_REV="d428abc";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2020-09-26 18:56";

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -93,6 +93,7 @@ li.dropdown {
<a href="#"onclick="document.getElementById('maincontent').src = '/ota_page.html';">OTA Update</a> <a href="#"onclick="document.getElementById('maincontent').src = '/ota_page.html';">OTA Update</a>
<a href="#"onclick="document.getElementById('maincontent').src = '/fileserver/log.txt';">Log Viewer</a> <a href="#"onclick="document.getElementById('maincontent').src = '/fileserver/log.txt';">Log Viewer</a>
<a href="#"onclick="document.getElementById('maincontent').src = '/reboot_page.html';">Reboot</a> <a href="#"onclick="document.getElementById('maincontent').src = '/reboot_page.html';">Reboot</a>
<a href="#"onclick="document.getElementById('maincontent').src = '/info.html';">Info</a>
</div> </div>
</ul> </ul>
<p> <p>

79
sd-card/html/info.html Normal file
View File

@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html>
<head>
<title>Set PreValue</title>
<meta charset="utf-8">
<style>
h1 {font-size: 2em;}
h2 {font-size: 1.5em;}
h3 {font-size: 1.2em;}
p {font-size: 1em;}
div {
width: 250px;
padding: 10px 5px;
border: 1px solid #ccc;
font-family: arial;
font-size: 16px;
max-height: 35px;
}
</style>
</head>
<body style="font-family: arial; padding: 0px 10px;">
<h3>Version Info</h3>
<table style="font-family: arial">
<tr>
<td>
Git-Branch:
</td>
<td>
<div id="gitbranch">
<object data="/version?type=GitBranch"></object>
</div>
</td>
</tr>
<tr>
<td>
Git-Base-Branch:
</td>
<td>
<div>
<object data="/version?type=GitBaseBranch"></object>
</div>
</td>
</tr>
<tr>
<td>
Git-Version:
</td>
<td>
<div>
<object data="/version?type=GitVersion"></object>
</div>
</td>
</tr>
<tr>
<td>
Build Time:
</td>
<td>
<div>
<object data="/version?type=BuildTime"></object>
</div>
</td>
</tr>
</table>
</body>
</html>