From a8fd0bbdef59fb51a2d475f3ed3b2034039a7feb Mon Sep 17 00:00:00 2001 From: Frank Haverland Date: Wed, 12 Oct 2022 22:09:38 +0200 Subject: [PATCH 01/32] use newer actions checkout and cache --- .github/workflows/build.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a0fc41c4..806e9c53 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive @@ -20,7 +20,7 @@ jobs: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Cache PlatformIO - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.platformio key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} @@ -59,7 +59,7 @@ jobs: needs: build steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Get generated files from cache uses: actions/cache@v3 @@ -109,7 +109,7 @@ jobs: needs: build steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Get generated files from cache uses: actions/cache@v3 @@ -177,7 +177,7 @@ jobs: needs: build steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Get generated files from cache uses: actions/cache@v3 @@ -192,7 +192,7 @@ jobs: - name: Set Variables id: vars run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + echo "name=sha_short::$(git rev-parse --short HEAD)" - name: Prepare artifacts for release run: | @@ -231,7 +231,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/') steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Get generated files from cache uses: actions/cache@v3 @@ -262,7 +262,7 @@ jobs: - name: Set Variables id: vars run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + echo "name=sha_short::$(git rev-parse --short HEAD)" - name: Prepare artifacts for release From 34ea8302efa0e082154bf39376aea0a99a3278ae Mon Sep 17 00:00:00 2001 From: Frank Haverland Date: Wed, 12 Oct 2022 22:29:02 +0200 Subject: [PATCH 02/32] update action setup-python --- .github/workflows/build.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 806e9c53..a0233c50 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -26,7 +26,7 @@ jobs: key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 - name: Install PlatformIO run: | python -m pip install --upgrade pip @@ -192,7 +192,7 @@ jobs: - name: Set Variables id: vars run: | - echo "name=sha_short::$(git rev-parse --short HEAD)" + echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Prepare artifacts for release run: | @@ -262,7 +262,7 @@ jobs: - name: Set Variables id: vars run: | - echo "name=sha_short::$(git rev-parse --short HEAD)" + echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Prepare artifacts for release From 50b998353487d12377bb23f49e92cd71d61ae482 Mon Sep 17 00:00:00 2001 From: Frank Haverland Date: Wed, 12 Oct 2022 22:38:05 +0200 Subject: [PATCH 03/32] fix warning set-output --- .github/workflows/build.yaml | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a0233c50..b8c4154f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -17,7 +17,7 @@ jobs: - name: Set Variables id: vars run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Cache PlatformIO uses: actions/cache@v3 @@ -74,24 +74,23 @@ jobs: - name: Set Variables id: vars run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Rename firmware file to contain versioning (old ota) run: | mkdir -p ./dist_old_ota - cp "./code/.pio/build/esp32cam/firmware.bin" "./dist_old_ota/firmware__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }}).bin" + cp "./code/.pio/build/esp32cam/firmware.bin" "./dist_old_ota/firmware__${{ github.ref_name }}_(${{ env.sha_short }}).bin" - name: Upload Firmware artifact (old OTA concept) uses: actions/upload-artifact@v3 with: -# name: "firmware__${{ github.ref_name }}__(${{ steps.vars.outputs.sha_short }})__(extract_before_upload__only_needed_for_migration_from_11.3.1)" - name: "firmware__(extract_before_upload)__${{ github.ref_name }}__(${{ steps.vars.outputs.sha_short }})" + name: "firmware__(extract_before_upload)__${{ github.ref_name }}__(${{ env.sha_short }})" path: ./dist_old_ota/* - name: Upload Web interface artifact (old OTA concept) uses: actions/upload-artifact@v3 with: - name: "html__${{ github.ref_name }}__(${{ steps.vars.outputs.sha_short }})" + name: "html__${{ github.ref_name }}__(${{ env.sha_short }})" path: ./sd-card/html/* @@ -124,27 +123,15 @@ jobs: - name: Set Variables id: vars run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Prepare update.zip artifact run: | mkdir -p ./dist cp "./code/.pio/build/esp32cam/firmware.bin" "dist/firmware.bin" - -# - name: Upload update.zip Artifact (Firmware only) -# uses: actions/upload-artifact@v3 -# with: -# name: "update_firmware_only__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})" -# path: ./dist/* - name: Add Web UI to dist run: cp -r ./sd-card/html ./dist/ - -# - name: Upload update.zip artifact (Firmware + Web UI) -# uses: actions/upload-artifact@v3 -# with: -# name: "update_firmware+webinterface__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})" -# path: ./dist/* - name: Add CNN to dist run: | @@ -155,7 +142,7 @@ jobs: - name: Upload dist as update.zip artifact (Firmware + Web UI + CNN) uses: actions/upload-artifact@v3 with: - name: "update__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})" + name: "update__${{ github.ref_name }}_(${{ env.sha_short }})" path: ./dist/* - name: Store generated files in cache @@ -192,7 +179,7 @@ jobs: - name: Set Variables id: vars run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Prepare artifacts for release run: | @@ -209,7 +196,7 @@ jobs: - name: Upload initial_esp32_setup.zip artifact (Firmware + Bootloader + Partitions + Web UI) uses: actions/upload-artifact@v3 with: - name: "initial_esp32_setup__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})" + name: "initial_esp32_setup__${{ github.ref_name }}_(${{ env.sha_short }})" path: ./firmware - name: Store generated files in cache @@ -262,7 +249,7 @@ jobs: - name: Set Variables id: vars run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Prepare artifacts for release From 62742d92d2976f6b74b9f8d9a73945496d5b1581 Mon Sep 17 00:00:00 2001 From: Frank Haverland Date: Wed, 12 Oct 2022 22:41:41 +0200 Subject: [PATCH 04/32] set python verion because of warnings --- .github/workflows/build.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b8c4154f..71b95e3f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -27,6 +27,8 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 + with: + python-version: '3.10' - name: Install PlatformIO run: | python -m pip install --upgrade pip From e1f8ac59cbf08eb5e79ba9dbcf6b38aeef3ce288 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 13:11:11 +0200 Subject: [PATCH 05/32] Add SD Card Info to info.html --- code/components/jomjol_helper/CMakeLists.txt | 2 +- code/components/jomjol_helper/Helper.cpp | 235 ++++++++++++++++++- code/components/jomjol_helper/Helper.h | 12 +- code/main/main.cpp | 1 + code/main/server_main.cpp | 67 ++++++ sd-card/html/info.html | 78 ++++++ 6 files changed, 391 insertions(+), 4 deletions(-) diff --git a/code/components/jomjol_helper/CMakeLists.txt b/code/components/jomjol_helper/CMakeLists.txt index c57b54d3..8d9580d5 100644 --- a/code/components/jomjol_helper/CMakeLists.txt +++ b/code/components/jomjol_helper/CMakeLists.txt @@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*) idf_component_register(SRCS ${app_sources} INCLUDE_DIRS "." - REQUIRES tflite-lib jomjol_logfile) + REQUIRES tflite-lib jomjol_logfile fatfs sdmmc) diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index ab18fa11..346062bd 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/code/components/jomjol_helper/Helper.cpp @@ -20,13 +20,17 @@ extern "C" { #include "ClassLogFile.h" -//#include "ClassLogFile.h" + +#include "esp_vfs_fat.h" //#define ISWINDOWS_TRUE #define PATH_MAX_STRING_SIZE 256 using namespace std; +sdmmc_cid_t SDCardCid; +sdmmc_csd_t SDCardCsd; + ///////////////////////////////////////////////////////////////////////////////////////////// string getESPHeapInfo(){ string espInfoResultStr = ""; @@ -73,8 +77,100 @@ size_t getInternalESPHeapSize() { return aFreeInternalHeapSize; } +string getSDCardPartitionSize(){ + FATFS *fs; + uint32_t fre_clust, tot_sect; + + /* Get volume information and free clusters of drive 0 */ + f_getfree("0:", (DWORD *)&fre_clust, &fs); + tot_sect = ((fs->n_fatent - 2) * fs->csize) /1024 /(1024/SDCardCsd.sector_size); //corrected by SD Card sector size (usually 512 bytes) and convert to MB + + printf("%d MB total drive space (Sector size [bytes]: %d)\n", (int)tot_sect, (int)fs->csize*512); + + return std::to_string(tot_sect); +} + +string getSDCardFreeParitionSpace(){ + FATFS *fs; + uint32_t fre_clust, fre_sect; + + /* Get volume information and free clusters of drive 0 */ + f_getfree("0:", (DWORD *)&fre_clust, &fs); + fre_sect = (fre_clust * fs->csize) / 1024 /(1024/SDCardCsd.sector_size); //corrected by SD Card sector size (usually 512 bytes) and convert to MB + + printf("%d MB free drive space (Sector size [bytes]: %d)\n", (int)fre_sect, (int)fs->ssize); + + return std::to_string(fre_sect); +} + +string getSDCardParitionAllocationSize(){ + FATFS *fs; + uint32_t fre_clust, allocation_size; + + /* Get volume information and free clusters of drive 0 */ + f_getfree("0:", (DWORD *)&fre_clust, &fs); + allocation_size = fs->ssize; + + printf("SD Card Parition Allocation Size (bytes): %d)\n", allocation_size); + + return std::to_string(allocation_size); +} +void SaveSDCardInfo(sdmmc_card_t* card) { + SDCardCid = card->cid; + SDCardCsd = card->csd; +} + +string getSDCardManufacturer(){ + string SDCardManufacturer = SDCardParseManufacturerIDs(SDCardCid.mfg_id); + printf("SD Card Manufactuer: %s\n", SDCardManufacturer.c_str()); + + return (SDCardManufacturer + " (ID: " + std::to_string(SDCardCid.mfg_id) + ")"); +} + +string getSDCardName(){ + char *SDCardName = SDCardCid.name; + printf("SD Card Name: %s\n", SDCardName); + + return std::string(SDCardName); +} + +string getSDCardCapacity(){ + int SDCardCapacity = SDCardCsd.capacity / (1024/SDCardCsd.sector_size) / 1024; // total sectors * sector size --> Byte to MB (1024*1024) + printf("SD Card Capacity: %s\n", std::to_string(SDCardCapacity).c_str()); + + return std::to_string(SDCardCapacity); +} + +string getSDCardSectorSize(){ + int SDCardSectorSize = SDCardCsd.sector_size; + printf("SD Card Sector Size: %s\n", std::to_string(SDCardSectorSize).c_str()); + + return std::to_string(SDCardSectorSize); +} + +/* + int SDCardManu = card->cid.mfg_id; + printf("SD Manu: %s\n", std::to_string(SDCardManu).c_str()); + + printf("SD Manu (ASCII): %s\n", SDCardParseManufacturerIDs(card->cid.mfg_id).c_str()); + + int SDCardOEM = card->cid.oem_id; + printf("SD OEM: %s\n", std::to_string(SDCardOEM).c_str()); + + int SDCardRev = card->cid.revision; + printf("SD Rev: %s\n", std::to_string(SDCardRev).c_str()); + + char *SDCardName = card->cid.name; + printf("SD Name: %s\n", SDCardName); + + int SDCardCSize = card->csd.sector_size; + printf("SD C-Size: %s\n", std::to_string(SDCardCSize).c_str()); + + int SDCardCapa = card->csd.capacity / (1024/card->csd.sector_size) / 1024; // total sectors * sector size --> Byte to MB (1024*1024) + printf("SD Capa: %s\n", std::to_string(SDCardCapa).c_str()); +*/ /////////////////////////////////////////////////////////////////////////////////////////////// @@ -462,7 +558,6 @@ int removeFolder(const char* folderPath, const char* logTag) { } - std::vector HelperZerlegeZeile(std::string input, std::string _delimiter = "") { std::vector Output; @@ -487,3 +582,139 @@ std::vector HelperZerlegeZeile(std::string input, std::string _delimiter return Output; } + +/* Source: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/tree/lsmmc.c */ +/* SD Card Manufacturer Database */ +struct SDCard_Manufacturer_database { + string type; + int id; + string manufacturer; +}; + +/* Source: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/tree/lsmmc.c */ +/* SD Card Manufacturer Database */ +struct SDCard_Manufacturer_database database[] = { + { + .type = "sd", + .id = 0x01, + .manufacturer = "Panasonic", + }, + { + .type = "sd", + .id = 0x02, + .manufacturer = "Toshiba/Kingston/Viking", + }, + { + .type = "sd", + .id = 0x03, + .manufacturer = "SanDisk", + }, + { + .type = "sd", + .id = 0x08, + .manufacturer = "Silicon Power", + }, + { + .type = "sd", + .id = 0x18, + .manufacturer = "Infineon", + }, + { + .type = "sd", + .id = 0x1b, + .manufacturer = "Transcend/Samsung", + }, + { + .type = "sd", + .id = 0x1c, + .manufacturer = "Transcend", + }, + { + .type = "sd", + .id = 0x1d, + .manufacturer = "Corsair/AData", + }, + { + .type = "sd", + .id = 0x1e, + .manufacturer = "Transcend", + }, + { + .type = "sd", + .id = 0x1f, + .manufacturer = "Kingston", + }, + { + .type = "sd", + .id = 0x27, + .manufacturer = "Delkin/Phison", + }, + { + .type = "sd", + .id = 0x28, + .manufacturer = "Lexar", + }, + { + .type = "sd", + .id = 0x30, + .manufacturer = "SanDisk", + }, + { + .type = "sd", + .id = 0x31, + .manufacturer = "Silicon Power", + }, + { + .type = "sd", + .id = 0x33, + .manufacturer = "STMicroelectronics", + }, + { + .type = "sd", + .id = 0x41, + .manufacturer = "Kingston", + }, + { + .type = "sd", + .id = 0x6f, + .manufacturer = "STMicroelectronics", + }, + { + .type = "sd", + .id = 0x74, + .manufacturer = "Transcend", + }, + { + .type = "sd", + .id = 0x76, + .manufacturer = "Patriot", + }, + { + .type = "sd", + .id = 0x82, + .manufacturer = "Gobe/Sony", + }, + { + .type = "sd", + .id = 0x89, + .manufacturer = "Unknown", + } +}; + +/* Parse SD Card Manufacturer Database */ +string SDCardParseManufacturerIDs(int id) +{ + unsigned int id_cnt = sizeof(database) / sizeof(struct SDCard_Manufacturer_database); + string ret_val = ""; + + for (int i = 0; i < id_cnt; i++) { + if (database[i].id == id) { + return database[i].manufacturer; + } + else { + ret_val = "ID unknown (not in DB)"; + } + } + return ret_val; +} + diff --git a/code/components/jomjol_helper/Helper.h b/code/components/jomjol_helper/Helper.h index a84fe8d1..b530f446 100644 --- a/code/components/jomjol_helper/Helper.h +++ b/code/components/jomjol_helper/Helper.h @@ -2,7 +2,7 @@ #include #include #include - +#include "sdmmc_cmd.h" using namespace std; @@ -47,3 +47,13 @@ size_t getESPHeapSize(); string getESPHeapInfo(); ///////////////////////////// +string getSDCardPartitionSize(); +string getSDCardFreeParitionSpace(); +string getSDCardParitionAllocationSize(); + +void SaveSDCardInfo(sdmmc_card_t* card); +string SDCardParseManufacturerIDs(int); +string getSDCardManufacturer(); +string getSDCardName(); +string getSDCardCapacity(); +string getSDCardSectorSize(); diff --git a/code/main/main.cpp b/code/main/main.cpp index 40fbb43b..fd7f0611 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -112,6 +112,7 @@ bool Init_NVS_SDCard() return false; } sdmmc_card_print_info(stdout, card); + SaveSDCardInfo(card); return true; } diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 7d24f2b0..d76c0b1f 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -15,6 +15,8 @@ #include "server_tflite.h" +#include "helper.h" + //#define DEBUG_DETAIL_ON @@ -134,6 +136,71 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } + if (_task.compare("SDCardPartitionSize") == 0) + { + std::string zw; + zw = getSDCardPartitionSize(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardFreeParitionSpace") == 0) + { + std::string zw; + zw = getSDCardFreeParitionSpace(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardPartitionSectorSize") == 0) + { + std::string zw; + zw = getSDCardParitionAllocationSize(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardManufacturer") == 0) + { + std::string zw; + zw = getSDCardManufacturer(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardName") == 0) + { + std::string zw; + zw = getSDCardName(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardCapacity") == 0) + { + std::string zw; + zw = getSDCardCapacity(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardSectorSize") == 0) + { + std::string zw; + zw = getSDCardSectorSize(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + + return ESP_OK; } diff --git a/sd-card/html/info.html b/sd-card/html/info.html index 2ad7c351..ffcfad3c 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -77,6 +77,84 @@ div { + + +

SD Card Info

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ SD Card Manufacturer: + +
+ +
+
+ SD Card Name: + +
+ +
+
+ SD Card Size [MB]: + +
+ +
+
+ SD Card Sector Size [byte]: + +
+ +
+
+ Partition Size [MB]: + +
+ +
+
+ Partition Free Space [MB]: + +
+ +
+
+ Partition Allocation Size [byte]: + +
+ +
+
+ + +

Version Info

From 98bf7e5387ffc0c7672f1b351b58e7c1fd385cbb Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 13:17:02 +0200 Subject: [PATCH 06/32] Add SD Card Info to info.html --- code/components/jomjol_helper/Helper.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index 346062bd..fd50953a 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/code/components/jomjol_helper/Helper.cpp @@ -150,28 +150,6 @@ string getSDCardSectorSize(){ return std::to_string(SDCardSectorSize); } -/* - int SDCardManu = card->cid.mfg_id; - printf("SD Manu: %s\n", std::to_string(SDCardManu).c_str()); - - printf("SD Manu (ASCII): %s\n", SDCardParseManufacturerIDs(card->cid.mfg_id).c_str()); - - int SDCardOEM = card->cid.oem_id; - printf("SD OEM: %s\n", std::to_string(SDCardOEM).c_str()); - - int SDCardRev = card->cid.revision; - printf("SD Rev: %s\n", std::to_string(SDCardRev).c_str()); - - char *SDCardName = card->cid.name; - printf("SD Name: %s\n", SDCardName); - - int SDCardCSize = card->csd.sector_size; - printf("SD C-Size: %s\n", std::to_string(SDCardCSize).c_str()); - - int SDCardCapa = card->csd.capacity / (1024/card->csd.sector_size) / 1024; // total sectors * sector size --> Byte to MB (1024*1024) - printf("SD Capa: %s\n", std::to_string(SDCardCapa).c_str()); -*/ - /////////////////////////////////////////////////////////////////////////////////////////////// void memCopyGen(uint8_t* _source, uint8_t* _target, int _size) From e308a1b5d9c56a8d1b05efe66da7b78993128870 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 19:30:37 +0200 Subject: [PATCH 07/32] Name adjustment --- code/main/server_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index d76c0b1f..28e78c8c 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -154,7 +154,7 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } - if (_task.compare("SDCardPartitionSectorSize") == 0) + if (_task.compare("SDCardParitionAllocationSize") == 0) { std::string zw; zw = getSDCardParitionAllocationSize(); From f15b1e5dfc7f0fc32fdf84ed77441c756a2e4d89 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 19:35:51 +0200 Subject: [PATCH 08/32] Name adjustment --- sd-card/html/info.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sd-card/html/info.html b/sd-card/html/info.html index ffcfad3c..4beda452 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -146,7 +146,7 @@ div { Partition Allocation Size [byte]: From c2b89dd1997f99d93940e74b8ad1b4e0dc5c8c67 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 20:27:21 +0200 Subject: [PATCH 09/32] Name adjustment --- code/components/jomjol_helper/Helper.cpp | 6 +++--- code/components/jomjol_helper/Helper.h | 4 ++-- code/main/server_main.cpp | 6 +++--- sd-card/html/info.html | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index fd50953a..66d95853 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/code/components/jomjol_helper/Helper.cpp @@ -90,7 +90,7 @@ string getSDCardPartitionSize(){ return std::to_string(tot_sect); } -string getSDCardFreeParitionSpace(){ +string getSDCardFreePartitionSpace(){ FATFS *fs; uint32_t fre_clust, fre_sect; @@ -103,7 +103,7 @@ string getSDCardFreeParitionSpace(){ return std::to_string(fre_sect); } -string getSDCardParitionAllocationSize(){ +string getSDCardPartitionAllocationSize(){ FATFS *fs; uint32_t fre_clust, allocation_size; @@ -111,7 +111,7 @@ string getSDCardParitionAllocationSize(){ f_getfree("0:", (DWORD *)&fre_clust, &fs); allocation_size = fs->ssize; - printf("SD Card Parition Allocation Size (bytes): %d)\n", allocation_size); + printf("SD Card Partition Allocation Size (bytes): %d)\n", allocation_size); return std::to_string(allocation_size); } diff --git a/code/components/jomjol_helper/Helper.h b/code/components/jomjol_helper/Helper.h index b530f446..8d7c2cf0 100644 --- a/code/components/jomjol_helper/Helper.h +++ b/code/components/jomjol_helper/Helper.h @@ -48,8 +48,8 @@ string getESPHeapInfo(); ///////////////////////////// string getSDCardPartitionSize(); -string getSDCardFreeParitionSpace(); -string getSDCardParitionAllocationSize(); +string getSDCardFreePartitionSpace(); +string getSDCardPartitionAllocationSize(); void SaveSDCardInfo(sdmmc_card_t* card); string SDCardParseManufacturerIDs(int); diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 28e78c8c..3de34933 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -145,7 +145,7 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } - if (_task.compare("SDCardFreeParitionSpace") == 0) + if (_task.compare("SDCardFreePartitionSpace") == 0) { std::string zw; zw = getSDCardFreeParitionSpace(); @@ -154,10 +154,10 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } - if (_task.compare("SDCardParitionAllocationSize") == 0) + if (_task.compare("SDCardPartitionAllocationSize") == 0) { std::string zw; - zw = getSDCardParitionAllocationSize(); + zw = getSDCardPartitionAllocationSize(); httpd_resp_sendstr_chunk(req, zw.c_str()); httpd_resp_sendstr_chunk(req, NULL); return ESP_OK; diff --git a/sd-card/html/info.html b/sd-card/html/info.html index 4beda452..7dbd7ee1 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -137,7 +137,7 @@ div { From 495b5de38c9492068ff2a45099e15a0a11665d70 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 20:29:32 +0200 Subject: [PATCH 10/32] Name adjustment --- code/main/server_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 3de34933..7bdbc481 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -148,7 +148,7 @@ esp_err_t info_get_handler(httpd_req_t *req) if (_task.compare("SDCardFreePartitionSpace") == 0) { std::string zw; - zw = getSDCardFreeParitionSpace(); + zw = getSDCardFreePartitionSpace(); httpd_resp_sendstr_chunk(req, zw.c_str()); httpd_resp_sendstr_chunk(req, NULL); return ESP_OK; From e05085ddf0d5ad80304fbd6fef5c00baa38c06cc Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 20:31:17 +0200 Subject: [PATCH 11/32] Name adjustment --- sd-card/html/info.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sd-card/html/info.html b/sd-card/html/info.html index 7dbd7ee1..afd87843 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -136,7 +136,7 @@ div { Partition Free Space [MB]: From 98d35e0412098f48a759e956a61f830fb94e19e3 Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Sat, 22 Oct 2022 21:44:35 +0200 Subject: [PATCH 12/32] Revert "Merge pull request #1205 from Slider0007/Add-sdcard-info" This reverts commit 437e8e4d25185bae43ca70def24359fa1c1b2968, reversing changes made to 0a2b6b71cab68414eec8b3c8f8626e1db5c27f5e. --- code/components/jomjol_helper/CMakeLists.txt | 2 +- code/components/jomjol_helper/Helper.cpp | 213 +------------------ code/components/jomjol_helper/Helper.h | 12 +- code/main/main.cpp | 1 - code/main/server_main.cpp | 67 ------ sd-card/html/info.html | 78 ------- 6 files changed, 4 insertions(+), 369 deletions(-) diff --git a/code/components/jomjol_helper/CMakeLists.txt b/code/components/jomjol_helper/CMakeLists.txt index 8d9580d5..c57b54d3 100644 --- a/code/components/jomjol_helper/CMakeLists.txt +++ b/code/components/jomjol_helper/CMakeLists.txt @@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*) idf_component_register(SRCS ${app_sources} INCLUDE_DIRS "." - REQUIRES tflite-lib jomjol_logfile fatfs sdmmc) + REQUIRES tflite-lib jomjol_logfile) diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index cf7b4d5e..1c826430 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/code/components/jomjol_helper/Helper.cpp @@ -20,8 +20,7 @@ extern "C" { #include "ClassLogFile.h" - -#include "esp_vfs_fat.h" +//#include "ClassLogFile.h" static const char* TAG = "helper"; @@ -30,9 +29,6 @@ static const char* TAG = "helper"; using namespace std; -sdmmc_cid_t SDCardCid; -sdmmc_csd_t SDCardCsd; - ///////////////////////////////////////////////////////////////////////////////////////////// string getESPHeapInfo(){ string espInfoResultStr = ""; @@ -79,78 +75,8 @@ size_t getInternalESPHeapSize() { return aFreeInternalHeapSize; } -string getSDCardPartitionSize(){ - FATFS *fs; - uint32_t fre_clust, tot_sect; - - /* Get volume information and free clusters of drive 0 */ - f_getfree("0:", (DWORD *)&fre_clust, &fs); - tot_sect = ((fs->n_fatent - 2) * fs->csize) /1024 /(1024/SDCardCsd.sector_size); //corrected by SD Card sector size (usually 512 bytes) and convert to MB - - printf("%d MB total drive space (Sector size [bytes]: %d)\n", (int)tot_sect, (int)fs->csize*512); - - return std::to_string(tot_sect); -} - -string getSDCardFreePartitionSpace(){ - FATFS *fs; - uint32_t fre_clust, fre_sect; - - /* Get volume information and free clusters of drive 0 */ - f_getfree("0:", (DWORD *)&fre_clust, &fs); - fre_sect = (fre_clust * fs->csize) / 1024 /(1024/SDCardCsd.sector_size); //corrected by SD Card sector size (usually 512 bytes) and convert to MB - - printf("%d MB free drive space (Sector size [bytes]: %d)\n", (int)fre_sect, (int)fs->ssize); - - return std::to_string(fre_sect); -} - -string getSDCardPartitionAllocationSize(){ - FATFS *fs; - uint32_t fre_clust, allocation_size; - - /* Get volume information and free clusters of drive 0 */ - f_getfree("0:", (DWORD *)&fre_clust, &fs); - allocation_size = fs->ssize; - - printf("SD Card Partition Allocation Size (bytes): %d)\n", allocation_size); - - return std::to_string(allocation_size); -} -void SaveSDCardInfo(sdmmc_card_t* card) { - SDCardCid = card->cid; - SDCardCsd = card->csd; -} - -string getSDCardManufacturer(){ - string SDCardManufacturer = SDCardParseManufacturerIDs(SDCardCid.mfg_id); - printf("SD Card Manufactuer: %s\n", SDCardManufacturer.c_str()); - - return (SDCardManufacturer + " (ID: " + std::to_string(SDCardCid.mfg_id) + ")"); -} - -string getSDCardName(){ - char *SDCardName = SDCardCid.name; - printf("SD Card Name: %s\n", SDCardName); - - return std::string(SDCardName); -} - -string getSDCardCapacity(){ - int SDCardCapacity = SDCardCsd.capacity / (1024/SDCardCsd.sector_size) / 1024; // total sectors * sector size --> Byte to MB (1024*1024) - printf("SD Card Capacity: %s\n", std::to_string(SDCardCapacity).c_str()); - - return std::to_string(SDCardCapacity); -} - -string getSDCardSectorSize(){ - int SDCardSectorSize = SDCardCsd.sector_size; - printf("SD Card Sector Size: %s\n", std::to_string(SDCardSectorSize).c_str()); - - return std::to_string(SDCardSectorSize); -} /////////////////////////////////////////////////////////////////////////////////////////////// @@ -536,6 +462,7 @@ int removeFolder(const char* folderPath, const char* logTag) { } + std::vector HelperZerlegeZeile(std::string input, std::string _delimiter = "") { std::vector Output; @@ -560,139 +487,3 @@ std::vector HelperZerlegeZeile(std::string input, std::string _delimiter return Output; } - -/* Source: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/tree/lsmmc.c */ -/* SD Card Manufacturer Database */ -struct SDCard_Manufacturer_database { - string type; - int id; - string manufacturer; -}; - -/* Source: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/tree/lsmmc.c */ -/* SD Card Manufacturer Database */ -struct SDCard_Manufacturer_database database[] = { - { - .type = "sd", - .id = 0x01, - .manufacturer = "Panasonic", - }, - { - .type = "sd", - .id = 0x02, - .manufacturer = "Toshiba/Kingston/Viking", - }, - { - .type = "sd", - .id = 0x03, - .manufacturer = "SanDisk", - }, - { - .type = "sd", - .id = 0x08, - .manufacturer = "Silicon Power", - }, - { - .type = "sd", - .id = 0x18, - .manufacturer = "Infineon", - }, - { - .type = "sd", - .id = 0x1b, - .manufacturer = "Transcend/Samsung", - }, - { - .type = "sd", - .id = 0x1c, - .manufacturer = "Transcend", - }, - { - .type = "sd", - .id = 0x1d, - .manufacturer = "Corsair/AData", - }, - { - .type = "sd", - .id = 0x1e, - .manufacturer = "Transcend", - }, - { - .type = "sd", - .id = 0x1f, - .manufacturer = "Kingston", - }, - { - .type = "sd", - .id = 0x27, - .manufacturer = "Delkin/Phison", - }, - { - .type = "sd", - .id = 0x28, - .manufacturer = "Lexar", - }, - { - .type = "sd", - .id = 0x30, - .manufacturer = "SanDisk", - }, - { - .type = "sd", - .id = 0x31, - .manufacturer = "Silicon Power", - }, - { - .type = "sd", - .id = 0x33, - .manufacturer = "STMicroelectronics", - }, - { - .type = "sd", - .id = 0x41, - .manufacturer = "Kingston", - }, - { - .type = "sd", - .id = 0x6f, - .manufacturer = "STMicroelectronics", - }, - { - .type = "sd", - .id = 0x74, - .manufacturer = "Transcend", - }, - { - .type = "sd", - .id = 0x76, - .manufacturer = "Patriot", - }, - { - .type = "sd", - .id = 0x82, - .manufacturer = "Gobe/Sony", - }, - { - .type = "sd", - .id = 0x89, - .manufacturer = "Unknown", - } -}; - -/* Parse SD Card Manufacturer Database */ -string SDCardParseManufacturerIDs(int id) -{ - unsigned int id_cnt = sizeof(database) / sizeof(struct SDCard_Manufacturer_database); - string ret_val = ""; - - for (int i = 0; i < id_cnt; i++) { - if (database[i].id == id) { - return database[i].manufacturer; - } - else { - ret_val = "ID unknown (not in DB)"; - } - } - return ret_val; -} - diff --git a/code/components/jomjol_helper/Helper.h b/code/components/jomjol_helper/Helper.h index 8d7c2cf0..a84fe8d1 100644 --- a/code/components/jomjol_helper/Helper.h +++ b/code/components/jomjol_helper/Helper.h @@ -2,7 +2,7 @@ #include #include #include -#include "sdmmc_cmd.h" + using namespace std; @@ -47,13 +47,3 @@ size_t getESPHeapSize(); string getESPHeapInfo(); ///////////////////////////// -string getSDCardPartitionSize(); -string getSDCardFreePartitionSpace(); -string getSDCardPartitionAllocationSize(); - -void SaveSDCardInfo(sdmmc_card_t* card); -string SDCardParseManufacturerIDs(int); -string getSDCardManufacturer(); -string getSDCardName(); -string getSDCardCapacity(); -string getSDCardSectorSize(); diff --git a/code/main/main.cpp b/code/main/main.cpp index 5436c7c6..01be3146 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -112,7 +112,6 @@ bool Init_NVS_SDCard() return false; } sdmmc_card_print_info(stdout, card); - SaveSDCardInfo(card); return true; } diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 9f679a6f..d60b2aa1 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -17,8 +17,6 @@ #include "esp_log.h" -#include "helper.h" - //#define DEBUG_DETAIL_ON @@ -138,71 +136,6 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } - if (_task.compare("SDCardPartitionSize") == 0) - { - std::string zw; - zw = getSDCardPartitionSize(); - httpd_resp_sendstr_chunk(req, zw.c_str()); - httpd_resp_sendstr_chunk(req, NULL); - return ESP_OK; - } - - if (_task.compare("SDCardFreePartitionSpace") == 0) - { - std::string zw; - zw = getSDCardFreePartitionSpace(); - httpd_resp_sendstr_chunk(req, zw.c_str()); - httpd_resp_sendstr_chunk(req, NULL); - return ESP_OK; - } - - if (_task.compare("SDCardPartitionAllocationSize") == 0) - { - std::string zw; - zw = getSDCardPartitionAllocationSize(); - httpd_resp_sendstr_chunk(req, zw.c_str()); - httpd_resp_sendstr_chunk(req, NULL); - return ESP_OK; - } - - if (_task.compare("SDCardManufacturer") == 0) - { - std::string zw; - zw = getSDCardManufacturer(); - httpd_resp_sendstr_chunk(req, zw.c_str()); - httpd_resp_sendstr_chunk(req, NULL); - return ESP_OK; - } - - if (_task.compare("SDCardName") == 0) - { - std::string zw; - zw = getSDCardName(); - httpd_resp_sendstr_chunk(req, zw.c_str()); - httpd_resp_sendstr_chunk(req, NULL); - return ESP_OK; - } - - if (_task.compare("SDCardCapacity") == 0) - { - std::string zw; - zw = getSDCardCapacity(); - httpd_resp_sendstr_chunk(req, zw.c_str()); - httpd_resp_sendstr_chunk(req, NULL); - return ESP_OK; - } - - if (_task.compare("SDCardSectorSize") == 0) - { - std::string zw; - zw = getSDCardSectorSize(); - httpd_resp_sendstr_chunk(req, zw.c_str()); - httpd_resp_sendstr_chunk(req, NULL); - return ESP_OK; - } - - - return ESP_OK; } diff --git a/sd-card/html/info.html b/sd-card/html/info.html index afd87843..2ad7c351 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -77,84 +77,6 @@ div {
-
+
- +
-
+
- - -

SD Card Info

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- SD Card Manufacturer: - -
- -
-
- SD Card Name: - -
- -
-
- SD Card Size [MB]: - -
- -
-
- SD Card Sector Size [byte]: - -
- -
-
- Partition Size [MB]: - -
- -
-
- Partition Free Space [MB]: - -
- -
-
- Partition Allocation Size [byte]: - -
- -
-
- - -

Version Info

From 803e8f2bff1515918de6ec3ae46bd7c7e1e04e9a Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 13:11:11 +0200 Subject: [PATCH 13/32] Add SD Card Info to info.html --- code/components/jomjol_helper/CMakeLists.txt | 2 +- code/components/jomjol_helper/Helper.cpp | 235 ++++++++++++++++++- code/components/jomjol_helper/Helper.h | 12 +- code/main/main.cpp | 1 + code/main/server_main.cpp | 67 ++++++ sd-card/html/info.html | 78 ++++++ 6 files changed, 391 insertions(+), 4 deletions(-) diff --git a/code/components/jomjol_helper/CMakeLists.txt b/code/components/jomjol_helper/CMakeLists.txt index c57b54d3..8d9580d5 100644 --- a/code/components/jomjol_helper/CMakeLists.txt +++ b/code/components/jomjol_helper/CMakeLists.txt @@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*) idf_component_register(SRCS ${app_sources} INCLUDE_DIRS "." - REQUIRES tflite-lib jomjol_logfile) + REQUIRES tflite-lib jomjol_logfile fatfs sdmmc) diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index 1c826430..57f97950 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/code/components/jomjol_helper/Helper.cpp @@ -20,7 +20,8 @@ extern "C" { #include "ClassLogFile.h" -//#include "ClassLogFile.h" + +#include "esp_vfs_fat.h" static const char* TAG = "helper"; @@ -29,6 +30,9 @@ static const char* TAG = "helper"; using namespace std; +sdmmc_cid_t SDCardCid; +sdmmc_csd_t SDCardCsd; + ///////////////////////////////////////////////////////////////////////////////////////////// string getESPHeapInfo(){ string espInfoResultStr = ""; @@ -75,8 +79,100 @@ size_t getInternalESPHeapSize() { return aFreeInternalHeapSize; } +string getSDCardPartitionSize(){ + FATFS *fs; + uint32_t fre_clust, tot_sect; + + /* Get volume information and free clusters of drive 0 */ + f_getfree("0:", (DWORD *)&fre_clust, &fs); + tot_sect = ((fs->n_fatent - 2) * fs->csize) /1024 /(1024/SDCardCsd.sector_size); //corrected by SD Card sector size (usually 512 bytes) and convert to MB + + printf("%d MB total drive space (Sector size [bytes]: %d)\n", (int)tot_sect, (int)fs->csize*512); + + return std::to_string(tot_sect); +} + +string getSDCardFreeParitionSpace(){ + FATFS *fs; + uint32_t fre_clust, fre_sect; + + /* Get volume information and free clusters of drive 0 */ + f_getfree("0:", (DWORD *)&fre_clust, &fs); + fre_sect = (fre_clust * fs->csize) / 1024 /(1024/SDCardCsd.sector_size); //corrected by SD Card sector size (usually 512 bytes) and convert to MB + + printf("%d MB free drive space (Sector size [bytes]: %d)\n", (int)fre_sect, (int)fs->ssize); + + return std::to_string(fre_sect); +} + +string getSDCardParitionAllocationSize(){ + FATFS *fs; + uint32_t fre_clust, allocation_size; + + /* Get volume information and free clusters of drive 0 */ + f_getfree("0:", (DWORD *)&fre_clust, &fs); + allocation_size = fs->ssize; + + printf("SD Card Parition Allocation Size (bytes): %d)\n", allocation_size); + + return std::to_string(allocation_size); +} +void SaveSDCardInfo(sdmmc_card_t* card) { + SDCardCid = card->cid; + SDCardCsd = card->csd; +} + +string getSDCardManufacturer(){ + string SDCardManufacturer = SDCardParseManufacturerIDs(SDCardCid.mfg_id); + printf("SD Card Manufactuer: %s\n", SDCardManufacturer.c_str()); + + return (SDCardManufacturer + " (ID: " + std::to_string(SDCardCid.mfg_id) + ")"); +} + +string getSDCardName(){ + char *SDCardName = SDCardCid.name; + printf("SD Card Name: %s\n", SDCardName); + + return std::string(SDCardName); +} + +string getSDCardCapacity(){ + int SDCardCapacity = SDCardCsd.capacity / (1024/SDCardCsd.sector_size) / 1024; // total sectors * sector size --> Byte to MB (1024*1024) + printf("SD Card Capacity: %s\n", std::to_string(SDCardCapacity).c_str()); + + return std::to_string(SDCardCapacity); +} + +string getSDCardSectorSize(){ + int SDCardSectorSize = SDCardCsd.sector_size; + printf("SD Card Sector Size: %s\n", std::to_string(SDCardSectorSize).c_str()); + + return std::to_string(SDCardSectorSize); +} + +/* + int SDCardManu = card->cid.mfg_id; + printf("SD Manu: %s\n", std::to_string(SDCardManu).c_str()); + + printf("SD Manu (ASCII): %s\n", SDCardParseManufacturerIDs(card->cid.mfg_id).c_str()); + + int SDCardOEM = card->cid.oem_id; + printf("SD OEM: %s\n", std::to_string(SDCardOEM).c_str()); + + int SDCardRev = card->cid.revision; + printf("SD Rev: %s\n", std::to_string(SDCardRev).c_str()); + + char *SDCardName = card->cid.name; + printf("SD Name: %s\n", SDCardName); + + int SDCardCSize = card->csd.sector_size; + printf("SD C-Size: %s\n", std::to_string(SDCardCSize).c_str()); + + int SDCardCapa = card->csd.capacity / (1024/card->csd.sector_size) / 1024; // total sectors * sector size --> Byte to MB (1024*1024) + printf("SD Capa: %s\n", std::to_string(SDCardCapa).c_str()); +*/ /////////////////////////////////////////////////////////////////////////////////////////////// @@ -462,7 +558,6 @@ int removeFolder(const char* folderPath, const char* logTag) { } - std::vector HelperZerlegeZeile(std::string input, std::string _delimiter = "") { std::vector Output; @@ -487,3 +582,139 @@ std::vector HelperZerlegeZeile(std::string input, std::string _delimiter return Output; } + +/* Source: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/tree/lsmmc.c */ +/* SD Card Manufacturer Database */ +struct SDCard_Manufacturer_database { + string type; + int id; + string manufacturer; +}; + +/* Source: https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git/tree/lsmmc.c */ +/* SD Card Manufacturer Database */ +struct SDCard_Manufacturer_database database[] = { + { + .type = "sd", + .id = 0x01, + .manufacturer = "Panasonic", + }, + { + .type = "sd", + .id = 0x02, + .manufacturer = "Toshiba/Kingston/Viking", + }, + { + .type = "sd", + .id = 0x03, + .manufacturer = "SanDisk", + }, + { + .type = "sd", + .id = 0x08, + .manufacturer = "Silicon Power", + }, + { + .type = "sd", + .id = 0x18, + .manufacturer = "Infineon", + }, + { + .type = "sd", + .id = 0x1b, + .manufacturer = "Transcend/Samsung", + }, + { + .type = "sd", + .id = 0x1c, + .manufacturer = "Transcend", + }, + { + .type = "sd", + .id = 0x1d, + .manufacturer = "Corsair/AData", + }, + { + .type = "sd", + .id = 0x1e, + .manufacturer = "Transcend", + }, + { + .type = "sd", + .id = 0x1f, + .manufacturer = "Kingston", + }, + { + .type = "sd", + .id = 0x27, + .manufacturer = "Delkin/Phison", + }, + { + .type = "sd", + .id = 0x28, + .manufacturer = "Lexar", + }, + { + .type = "sd", + .id = 0x30, + .manufacturer = "SanDisk", + }, + { + .type = "sd", + .id = 0x31, + .manufacturer = "Silicon Power", + }, + { + .type = "sd", + .id = 0x33, + .manufacturer = "STMicroelectronics", + }, + { + .type = "sd", + .id = 0x41, + .manufacturer = "Kingston", + }, + { + .type = "sd", + .id = 0x6f, + .manufacturer = "STMicroelectronics", + }, + { + .type = "sd", + .id = 0x74, + .manufacturer = "Transcend", + }, + { + .type = "sd", + .id = 0x76, + .manufacturer = "Patriot", + }, + { + .type = "sd", + .id = 0x82, + .manufacturer = "Gobe/Sony", + }, + { + .type = "sd", + .id = 0x89, + .manufacturer = "Unknown", + } +}; + +/* Parse SD Card Manufacturer Database */ +string SDCardParseManufacturerIDs(int id) +{ + unsigned int id_cnt = sizeof(database) / sizeof(struct SDCard_Manufacturer_database); + string ret_val = ""; + + for (int i = 0; i < id_cnt; i++) { + if (database[i].id == id) { + return database[i].manufacturer; + } + else { + ret_val = "ID unknown (not in DB)"; + } + } + return ret_val; +} + diff --git a/code/components/jomjol_helper/Helper.h b/code/components/jomjol_helper/Helper.h index a84fe8d1..b530f446 100644 --- a/code/components/jomjol_helper/Helper.h +++ b/code/components/jomjol_helper/Helper.h @@ -2,7 +2,7 @@ #include #include #include - +#include "sdmmc_cmd.h" using namespace std; @@ -47,3 +47,13 @@ size_t getESPHeapSize(); string getESPHeapInfo(); ///////////////////////////// +string getSDCardPartitionSize(); +string getSDCardFreeParitionSpace(); +string getSDCardParitionAllocationSize(); + +void SaveSDCardInfo(sdmmc_card_t* card); +string SDCardParseManufacturerIDs(int); +string getSDCardManufacturer(); +string getSDCardName(); +string getSDCardCapacity(); +string getSDCardSectorSize(); diff --git a/code/main/main.cpp b/code/main/main.cpp index 01be3146..5436c7c6 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -112,6 +112,7 @@ bool Init_NVS_SDCard() return false; } sdmmc_card_print_info(stdout, card); + SaveSDCardInfo(card); return true; } diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index d60b2aa1..555089ee 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -17,6 +17,8 @@ #include "esp_log.h" +#include "helper.h" + //#define DEBUG_DETAIL_ON @@ -136,6 +138,71 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } + if (_task.compare("SDCardPartitionSize") == 0) + { + std::string zw; + zw = getSDCardPartitionSize(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardFreeParitionSpace") == 0) + { + std::string zw; + zw = getSDCardFreeParitionSpace(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardPartitionSectorSize") == 0) + { + std::string zw; + zw = getSDCardParitionAllocationSize(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardManufacturer") == 0) + { + std::string zw; + zw = getSDCardManufacturer(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardName") == 0) + { + std::string zw; + zw = getSDCardName(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardCapacity") == 0) + { + std::string zw; + zw = getSDCardCapacity(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + if (_task.compare("SDCardSectorSize") == 0) + { + std::string zw; + zw = getSDCardSectorSize(); + httpd_resp_sendstr_chunk(req, zw.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; + } + + + return ESP_OK; } diff --git a/sd-card/html/info.html b/sd-card/html/info.html index 2ad7c351..ffcfad3c 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -77,6 +77,84 @@ div {
+ + +

SD Card Info

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ SD Card Manufacturer: + +
+ +
+
+ SD Card Name: + +
+ +
+
+ SD Card Size [MB]: + +
+ +
+
+ SD Card Sector Size [byte]: + +
+ +
+
+ Partition Size [MB]: + +
+ +
+
+ Partition Free Space [MB]: + +
+ +
+
+ Partition Allocation Size [byte]: + +
+ +
+
+ + +

Version Info

From 4150c31b984c71d5de99f2edcf98c7cfe403b425 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 13:17:02 +0200 Subject: [PATCH 14/32] Add SD Card Info to info.html --- code/components/jomjol_helper/Helper.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index 57f97950..334444dd 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/code/components/jomjol_helper/Helper.cpp @@ -152,28 +152,6 @@ string getSDCardSectorSize(){ return std::to_string(SDCardSectorSize); } -/* - int SDCardManu = card->cid.mfg_id; - printf("SD Manu: %s\n", std::to_string(SDCardManu).c_str()); - - printf("SD Manu (ASCII): %s\n", SDCardParseManufacturerIDs(card->cid.mfg_id).c_str()); - - int SDCardOEM = card->cid.oem_id; - printf("SD OEM: %s\n", std::to_string(SDCardOEM).c_str()); - - int SDCardRev = card->cid.revision; - printf("SD Rev: %s\n", std::to_string(SDCardRev).c_str()); - - char *SDCardName = card->cid.name; - printf("SD Name: %s\n", SDCardName); - - int SDCardCSize = card->csd.sector_size; - printf("SD C-Size: %s\n", std::to_string(SDCardCSize).c_str()); - - int SDCardCapa = card->csd.capacity / (1024/card->csd.sector_size) / 1024; // total sectors * sector size --> Byte to MB (1024*1024) - printf("SD Capa: %s\n", std::to_string(SDCardCapa).c_str()); -*/ - /////////////////////////////////////////////////////////////////////////////////////////////// void memCopyGen(uint8_t* _source, uint8_t* _target, int _size) From 2a54d9b8891d39db7d477c4708cb99f989a6dd7a Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 19:30:37 +0200 Subject: [PATCH 15/32] Name adjustment --- code/main/server_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 555089ee..abb8626d 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -156,7 +156,7 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } - if (_task.compare("SDCardPartitionSectorSize") == 0) + if (_task.compare("SDCardParitionAllocationSize") == 0) { std::string zw; zw = getSDCardParitionAllocationSize(); From 0adfc45d36e300a054ef22a0eb5e5590b38cd3e3 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 19:35:51 +0200 Subject: [PATCH 16/32] Name adjustment --- sd-card/html/info.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sd-card/html/info.html b/sd-card/html/info.html index ffcfad3c..4beda452 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -146,7 +146,7 @@ div { Partition Allocation Size [byte]: From 2b810ca32d77d07e8f1af66c33f497aabb311c57 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 20:27:21 +0200 Subject: [PATCH 17/32] Name adjustment --- code/components/jomjol_helper/Helper.cpp | 6 +++--- code/components/jomjol_helper/Helper.h | 4 ++-- code/main/server_main.cpp | 6 +++--- sd-card/html/info.html | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index 334444dd..cf7b4d5e 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/code/components/jomjol_helper/Helper.cpp @@ -92,7 +92,7 @@ string getSDCardPartitionSize(){ return std::to_string(tot_sect); } -string getSDCardFreeParitionSpace(){ +string getSDCardFreePartitionSpace(){ FATFS *fs; uint32_t fre_clust, fre_sect; @@ -105,7 +105,7 @@ string getSDCardFreeParitionSpace(){ return std::to_string(fre_sect); } -string getSDCardParitionAllocationSize(){ +string getSDCardPartitionAllocationSize(){ FATFS *fs; uint32_t fre_clust, allocation_size; @@ -113,7 +113,7 @@ string getSDCardParitionAllocationSize(){ f_getfree("0:", (DWORD *)&fre_clust, &fs); allocation_size = fs->ssize; - printf("SD Card Parition Allocation Size (bytes): %d)\n", allocation_size); + printf("SD Card Partition Allocation Size (bytes): %d)\n", allocation_size); return std::to_string(allocation_size); } diff --git a/code/components/jomjol_helper/Helper.h b/code/components/jomjol_helper/Helper.h index b530f446..8d7c2cf0 100644 --- a/code/components/jomjol_helper/Helper.h +++ b/code/components/jomjol_helper/Helper.h @@ -48,8 +48,8 @@ string getESPHeapInfo(); ///////////////////////////// string getSDCardPartitionSize(); -string getSDCardFreeParitionSpace(); -string getSDCardParitionAllocationSize(); +string getSDCardFreePartitionSpace(); +string getSDCardPartitionAllocationSize(); void SaveSDCardInfo(sdmmc_card_t* card); string SDCardParseManufacturerIDs(int); diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index abb8626d..bb519093 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -147,7 +147,7 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } - if (_task.compare("SDCardFreeParitionSpace") == 0) + if (_task.compare("SDCardFreePartitionSpace") == 0) { std::string zw; zw = getSDCardFreeParitionSpace(); @@ -156,10 +156,10 @@ esp_err_t info_get_handler(httpd_req_t *req) return ESP_OK; } - if (_task.compare("SDCardParitionAllocationSize") == 0) + if (_task.compare("SDCardPartitionAllocationSize") == 0) { std::string zw; - zw = getSDCardParitionAllocationSize(); + zw = getSDCardPartitionAllocationSize(); httpd_resp_sendstr_chunk(req, zw.c_str()); httpd_resp_sendstr_chunk(req, NULL); return ESP_OK; diff --git a/sd-card/html/info.html b/sd-card/html/info.html index 4beda452..7dbd7ee1 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -137,7 +137,7 @@ div { From dbf8e634d9a4a1242082edeff0f1c198395ec47c Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 20:29:32 +0200 Subject: [PATCH 18/32] Name adjustment --- code/main/server_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index bb519093..9f679a6f 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -150,7 +150,7 @@ esp_err_t info_get_handler(httpd_req_t *req) if (_task.compare("SDCardFreePartitionSpace") == 0) { std::string zw; - zw = getSDCardFreeParitionSpace(); + zw = getSDCardFreePartitionSpace(); httpd_resp_sendstr_chunk(req, zw.c_str()); httpd_resp_sendstr_chunk(req, NULL); return ESP_OK; From d3e195df9fa590d4d08ad4a356c8e5bbc5222e90 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 20:31:17 +0200 Subject: [PATCH 19/32] Name adjustment --- sd-card/html/info.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sd-card/html/info.html b/sd-card/html/info.html index 7dbd7ee1..afd87843 100644 --- a/sd-card/html/info.html +++ b/sd-card/html/info.html @@ -136,7 +136,7 @@ div { Partition Free Space [MB]: From 3a999358b90e3e497f61552950bee5e130e03c0d Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 23:14:44 +0200 Subject: [PATCH 20/32] correct case sensitivity of include --- code/main/server_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 9f679a6f..64a82e65 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -17,7 +17,7 @@ #include "esp_log.h" -#include "helper.h" +#include "Helper.h" //#define DEBUG_DETAIL_ON From f65b2850a22cc19ac075e389dd4f6387ab51f7c5 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Sat, 22 Oct 2022 23:14:44 +0200 Subject: [PATCH 21/32] correct case sensitivity of include --- code/main/server_main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/code/main/server_main.cpp b/code/main/server_main.cpp index 64a82e65..b2a38307 100644 --- a/code/main/server_main.cpp +++ b/code/main/server_main.cpp @@ -16,7 +16,6 @@ #include "server_tflite.h" #include "esp_log.h" - #include "Helper.h" //#define DEBUG_DETAIL_ON From 63f28097bdb1595ad2887ac14893317f829889b8 Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Sun, 23 Oct 2022 09:39:16 +0200 Subject: [PATCH 22/32] Update Changelog.md --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index 349247e8..fcc445ac 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ - added `/graph.html` to fetch measurements from the debug log and display them as a graph. Activate debug logging for this feature to work. - Added PreValue to `/json` ([#1154](https://github.com/jomjol/AI-on-the-edge-device/issues/1154)) - Show graph of values direct in the user interface (thanks to [@rdmueller](https://github.com/rdmueller)) +- SD card info into the "Info" Menue (thanks to [@Slider007]( https://github.com/Slider0007)) ### Changed From 3743ac18f58e88a1d9a784b79d0123121eab4aca Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Sun, 23 Oct 2022 12:36:09 +0200 Subject: [PATCH 23/32] Implement direct data logging --- Changelog.md | 5 +++++ code/components/jomjol_helper/Helper.cpp | 7 +++---- .../components/jomjol_logfile/ClassLogFile.cpp | 18 ++++++++++++------ code/components/jomjol_logfile/ClassLogFile.h | 2 ++ code/main/main.cpp | 13 ++++++++++++- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Changelog.md b/Changelog.md index fcc445ac..691cbfbd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,11 @@ - Added PreValue to `/json` ([#1154](https://github.com/jomjol/AI-on-the-edge-device/issues/1154)) - Show graph of values direct in the user interface (thanks to [@rdmueller](https://github.com/rdmueller)) - SD card info into the "Info" Menue (thanks to [@Slider007]( https://github.com/Slider0007)) +- Added a logging of the values in a text table in `/log/data` - each measurement is one line + - Format: tabulator separated + - Content: time, raw-value, return-value, pre-value, error-text, cnn-digital, cnn-analog + - ATTENTION: format not fully fixed yet! + ### Changed diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index cf7b4d5e..69ef3e1d 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/code/components/jomjol_helper/Helper.cpp @@ -230,10 +230,9 @@ void FindReplace(std::string& line, std::string& oldString, std::string& newStri void MakeDir(std::string _what) { -// chdir(_where.c_str()); - - if (mkdir(_what.c_str(), S_IRWXU|S_IRWXG|S_IROTH)) - ESP_LOGD(TAG, "Problem with MakeDir: %s", _what.c_str()); +int mk_ret = mkdir(_what.c_str(), 0775); +if (mk_ret) + ESP_LOGD(TAG, "error with mkdir %s ret %d", _what.c_str(), mk_ret); } diff --git a/code/components/jomjol_logfile/ClassLogFile.cpp b/code/components/jomjol_logfile/ClassLogFile.cpp index 4dd6882f..0d3e2b96 100644 --- a/code/components/jomjol_logfile/ClassLogFile.cpp +++ b/code/components/jomjol_logfile/ClassLogFile.cpp @@ -95,7 +95,7 @@ void ClassLogFile::WriteToData(std::string _ReturnRawValue, std::string _ReturnV strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo); - zwtime = std::string(buffer) + ":\t"; + zwtime = std::string(buffer) + "\t"; fputs(zwtime.c_str(), pFile); fputs(_ReturnRawValue.c_str(), pFile); fputs("\t", pFile); @@ -104,11 +104,8 @@ void ClassLogFile::WriteToData(std::string _ReturnRawValue, std::string _ReturnV fputs(_ReturnPreValue.c_str(), pFile); fputs("\t", pFile); fputs(_ErrorMessageText.c_str(), pFile); - fputs("\t", pFile); fputs(_digital.c_str(), pFile); - fputs("\t", pFile); fputs(_analog.c_str(), pFile); - fputs("\t", pFile); fputs("\n", pFile); fclose(pFile); @@ -284,6 +281,17 @@ void ClassLogFile::RemoveOld() closedir(dir); } +void ClassLogFile::CreateLogDirectories() +{ + MakeDir("/sdcard/log"); + MakeDir("/sdcard/log/data"); + MakeDir("/sdcard/log/analog"); + MakeDir("/sdcard/log/digit"); + MakeDir("/sdcard/log/message"); + MakeDir("/sdcard/log/source"); +} + + ClassLogFile::ClassLogFile(std::string _logroot, std::string _logfile, std::string _logdatapath, std::string _datafile) { logroot = _logroot; @@ -294,6 +302,4 @@ ClassLogFile::ClassLogFile(std::string _logroot, std::string _logfile, std::stri retentionInDays = 10; loglevel = 0; MakeDir("/sdcard/log/data"); - MakeDir("/sdcard/test"); - MakeDir("/test"); } diff --git a/code/components/jomjol_logfile/ClassLogFile.h b/code/components/jomjol_logfile/ClassLogFile.h index c04978a2..76426db5 100644 --- a/code/components/jomjol_logfile/ClassLogFile.h +++ b/code/components/jomjol_logfile/ClassLogFile.h @@ -24,6 +24,8 @@ public: void SwitchOnOff(bool _doLogFile); void SetRetention(unsigned short _retentionInDays); + void CreateLogDirectories(); + void WriteToFile(std::string info, bool _time = true); void WriteToDedicatedFile(std::string _fn, std::string info, bool _time = true); void RemoveOld(); diff --git a/code/main/main.cpp b/code/main/main.cpp index 5436c7c6..f0a37ff8 100644 --- a/code/main/main.cpp +++ b/code/main/main.cpp @@ -111,9 +111,9 @@ bool Init_NVS_SDCard() } return false; } + sdmmc_card_print_info(stdout, card); SaveSDCardInfo(card); - return true; } @@ -167,6 +167,17 @@ extern "C" void app_main(void) CheckOTAUpdate(); + LogFile.CreateLogDirectories(); +/* + int mk_ret = mkdir("/sdcard/new_fd_mkdir", 0775); + ESP_LOGI(TAGMAIN, "mkdir ret %d", mk_ret); + mk_ret = mkdir("/sdcard/new_fd_mkdir/test", 0775); + ESP_LOGI(TAGMAIN, "mkdir ret %d", mk_ret); + MakeDir("/sdcard/test2"); + MakeDir("/sdcard/test2/intern"); +*/ + + char *ssid = NULL, *passwd = NULL, *hostname = NULL, *ip = NULL, *gateway = NULL, *netmask = NULL, *dns = NULL; LoadWlanFromFile("/sdcard/wlan.ini", ssid, passwd, hostname, ip, gateway, netmask, dns); From 6986f2186c592bd9eba8e4ac189691f525e5272c Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Sun, 23 Oct 2022 13:50:02 +0200 Subject: [PATCH 24/32] Extented data logging --- Changelog.md | 2 +- .../ClassFlowPostProcessing.cpp | 21 +++++++++++++------ .../ClassFlowPostProcessing.h | 2 +- .../jomjol_logfile/ClassLogFile.cpp | 21 ++++++++----------- code/components/jomjol_logfile/ClassLogFile.h | 3 ++- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/Changelog.md b/Changelog.md index 691cbfbd..735ac1e7 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,7 +10,7 @@ - SD card info into the "Info" Menue (thanks to [@Slider007]( https://github.com/Slider0007)) - Added a logging of the values in a text table in `/log/data` - each measurement is one line - Format: tabulator separated - - Content: time, raw-value, return-value, pre-value, error-text, cnn-digital, cnn-analog + - Content: time, name-of-number, raw-value, return-value, pre-value, change-rate, change-absolute, error-text, cnn-digital, cnn-analog - ATTENTION: format not fully fixed yet! diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index 100f8895..319ca661 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -848,17 +848,26 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) return true; } -void ClassFlowPostProcessing::WriteDataLog(int _analog) +void ClassFlowPostProcessing::WriteDataLog(int _index) { string analog = ""; string digital = ""; + string timezw = ""; + char buffer[80]; + struct tm* timeinfo = localtime(&NUMBERS[_index]->lastvalue); + strftime(buffer, 80, PREVALUE_TIME_FORMAT_OUTPUT, timeinfo); + timezw = std::string(buffer); + if (flowAnalog) - analog = flowAnalog->getReadoutRawString(_analog); + analog = flowAnalog->getReadoutRawString(_index); if (flowDigit) - digital = flowDigit->getReadoutRawString(_analog); -// LogFile.WriteToFile(analog); - LogFile.WriteToData(NUMBERS[_analog]->ReturnRawValue, NUMBERS[_analog]->ReturnValue, NUMBERS[_analog]->ReturnPreValue, NUMBERS[_analog]->ErrorMessageText, digital, analog); - 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()); + digital = flowDigit->getReadoutRawString(_index); + LogFile.WriteToData(timezw, NUMBERS[_index]->name, + NUMBERS[_index]->ReturnRawValue, NUMBERS[_index]->ReturnValue, NUMBERS[_index]->ReturnPreValue, + NUMBERS[_index]->ReturnRateValue, NUMBERS[_index]->ReturnChangeAbsolute, + NUMBERS[_index]->ErrorMessageText, + digital, analog); + ESP_LOGD(TAG, "WriteDataLog: %s, %s, %s, %s, %s", NUMBERS[_index]->ReturnRawValue.c_str(), NUMBERS[_index]->ReturnValue.c_str(), NUMBERS[_index]->ErrorMessageText.c_str(), digital.c_str(), analog.c_str()); } diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h index 79075d01..f707f170 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h @@ -44,7 +44,7 @@ protected: void handleAnalogDigitalTransitionStart(string _decsep, string _value); std::string GetStringReadouts(general); - void WriteDataLog(int _analog); + void WriteDataLog(int _index); diff --git a/code/components/jomjol_logfile/ClassLogFile.cpp b/code/components/jomjol_logfile/ClassLogFile.cpp index 0d3e2b96..82723067 100644 --- a/code/components/jomjol_logfile/ClassLogFile.cpp +++ b/code/components/jomjol_logfile/ClassLogFile.cpp @@ -62,7 +62,7 @@ std::string ClassLogFile::getESPHeapInfo(){ return espInfoResultStr; } -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 _timestamp, std::string _name, std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ReturnRateValue, std::string _ReturnChangeAbsolute, std::string _ErrorMessageText, std::string _digital, std::string _analog) { ESP_LOGD(TAG, "Start WriteToData\n"); time_t rawtime; @@ -86,23 +86,20 @@ void ClassLogFile::WriteToData(std::string _ReturnRawValue, std::string _ReturnV pFile = fopen(logpath.c_str(), "a+"); if (pFile!=NULL) { - time_t rawtime; - struct tm* timeinfo; - char buffer[80]; - - time(&rawtime); - timeinfo = localtime(&rawtime); - - strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo); - - zwtime = std::string(buffer) + "\t"; - fputs(zwtime.c_str(), pFile); + fputs(_timestamp.c_str(), pFile); + fputs("\t", pFile); + fputs(_name.c_str(), pFile); + fputs("\t", pFile); fputs(_ReturnRawValue.c_str(), pFile); fputs("\t", pFile); fputs(_ReturnValue.c_str(), pFile); fputs("\t", pFile); fputs(_ReturnPreValue.c_str(), pFile); fputs("\t", pFile); + fputs(_ReturnRateValue.c_str(), pFile); + fputs("\t", pFile); + fputs(_ReturnChangeAbsolute.c_str(), pFile); + fputs("\t", pFile); fputs(_ErrorMessageText.c_str(), pFile); fputs(_digital.c_str(), pFile); fputs(_analog.c_str(), pFile); diff --git a/code/components/jomjol_logfile/ClassLogFile.h b/code/components/jomjol_logfile/ClassLogFile.h index 76426db5..da33557f 100644 --- a/code/components/jomjol_logfile/ClassLogFile.h +++ b/code/components/jomjol_logfile/ClassLogFile.h @@ -30,7 +30,8 @@ public: void WriteToDedicatedFile(std::string _fn, std::string info, bool _time = true); void RemoveOld(); - void WriteToData(std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ErrorMessageText, std::string _digital, std::string _analog); +// void WriteToData(std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ErrorMessageText, std::string _digital, std::string _analog); + void WriteToData(std::string _timestamp, std::string _name, std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ReturnRateValue, std::string _ReturnChangeAbsolute, std::string _ErrorMessageText, std::string _digital, std::string _analog); std::string GetCurrentFileName(); From b78929745bec650b87baf1712c9c48d35b47e5b9 Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Sun, 23 Oct 2022 16:12:34 +0200 Subject: [PATCH 25/32] Improve data logging --- .../ClassFlowCNNGeneral.cpp | 9 ++++-- .../ClassFlowPostProcessing.cpp | 3 ++ .../ClassFlowPostProcessing.h | 1 - code/components/jomjol_helper/Helper.cpp | 28 +++++++++++++++++++ code/components/jomjol_helper/Helper.h | 2 ++ 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp index 82869a1c..e46078bb 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp @@ -980,17 +980,20 @@ string ClassFlowCNNGeneral::getReadoutRawString(int _analog) { if (CNNType == Analogue || CNNType == Analogue100) { - rt = rt + "\t" + std::to_string(GENERAL[_analog]->ROI[i]->result_float); + rt = rt + "\t" + RundeOutput(GENERAL[_analog]->ROI[i]->result_float, 1); } if (CNNType == Digital) { - rt = rt + "\t" + std::to_string(GENERAL[_analog]->ROI[i]->result_klasse); + if (GENERAL[_analog]->ROI[i]->result_klasse == 10) + rt = rt + "\tN"; + else + rt = rt + "\t" + RundeOutput(GENERAL[_analog]->ROI[i]->result_klasse, 0); } if ((CNNType == DoubleHyprid10) || (CNNType == Digital100)) { - rt = rt + "\t" + std::to_string(GENERAL[_analog]->ROI[i]->result_float); + rt = rt + "\t" + RundeOutput(GENERAL[_analog]->ROI[i]->result_float, 1); } } return rt; diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index 319ca661..afe21a16 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -927,6 +927,8 @@ string ClassFlowPostProcessing::getReadoutParam(bool _rawValue, bool _noerror, i return NUMBERS[_number]->ReturnValue; } +/* Jetzt als globale Funktion in Helper.h + string ClassFlowPostProcessing::RundeOutput(double _in, int _anzNachkomma){ std::stringstream stream; int _zw = _in; @@ -949,6 +951,7 @@ string ClassFlowPostProcessing::RundeOutput(double _in, int _anzNachkomma){ return stream.str(); } +*/ string ClassFlowPostProcessing::ErsetzteN(string input, double _prevalue) diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h index f707f170..3c53bb82 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h @@ -34,7 +34,6 @@ protected: string ErsetzteN(string, double _prevalue); float checkDigitConsistency(double input, int _decilamshift, bool _isanalog, double _preValue); - string RundeOutput(double _in, int _anzNachkomma); void InitNUMBERS(); void handleDecimalSeparator(string _decsep, string _value); diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index 69ef3e1d..130cf69c 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/code/components/jomjol_helper/Helper.cpp @@ -7,6 +7,9 @@ #include #include +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -695,3 +698,28 @@ string SDCardParseManufacturerIDs(int id) return ret_val; } + +string RundeOutput(double _in, int _anzNachkomma) +{ + std::stringstream stream; + int _zw = _in; +// ESP_LOGD(TAG, "AnzNachkomma: %d", _anzNachkomma); + + if (_anzNachkomma < 0) { + _anzNachkomma = 0; + } + + if (_anzNachkomma > 0) + { + stream << std::fixed << std::setprecision(_anzNachkomma) << _in; + return stream.str(); + } + else + { + stream << _zw; + } + + + return stream.str(); +} + diff --git a/code/components/jomjol_helper/Helper.h b/code/components/jomjol_helper/Helper.h index 8d7c2cf0..9dcd333d 100644 --- a/code/components/jomjol_helper/Helper.h +++ b/code/components/jomjol_helper/Helper.h @@ -15,6 +15,8 @@ void RenameFile(string from, string to); void MakeDir(std::string _what); +string RundeOutput(double _in, int _anzNachkomma); + FILE* OpenFileAndWait(const char* nm, const char* _mode, int _waitsec = 1); From 8e22bd06e9a0c696689c199e4d1805e796e70e44 Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Sun, 23 Oct 2022 18:09:05 +0200 Subject: [PATCH 26/32] Update ClassFlowCNNGeneral.cpp --- code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp index e46078bb..b1a2a559 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp @@ -976,7 +976,7 @@ string ClassFlowCNNGeneral::getReadoutRawString(int _analog) if (GENERAL[_analog]->ROI.size() == 0) return rt; - for (int i = GENERAL[_analog]->ROI.size() - 1; i >= 0; --i) + for (int i = 0; i < GENERAL[_analog]->ROI.size(); ++i) { if (CNNType == Analogue || CNNType == Analogue100) { From 716c23fed31beeed3aadbbef97a27cef726af633 Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Sun, 23 Oct 2022 18:59:55 +0200 Subject: [PATCH 27/32] Update graph.html to data --- sd-card/html/graph.html | 18 ++++---- sd-card/html/graph_data.html | 82 ++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 9 deletions(-) create mode 100644 sd-card/html/graph_data.html diff --git a/sd-card/html/graph.html b/sd-card/html/graph.html index c790b31a..d3e15026 100644 --- a/sd-card/html/graph.html +++ b/sd-card/html/graph.html @@ -26,21 +26,21 @@ console.log (hash); var d = new Date(); var options=""; for (var i=0; i<27; i++) { - var currentDate = new Date(d-i*60*60*24*1000); - var option = currentDate.getFullYear()+"-"+(currentDate.getMonth()+1)+"-"+currentDate.getDate() - options += "\n"; + var currentDate = new Date(d-i*60*60*24*1000); + var option = currentDate.getFullYear()+"-"+(currentDate.getMonth()+1)+"-"+currentDate.getDate() + options += "\n"; } document.getElementById("selector").innerHTML = options; var dateString = d.getFullYear() + "-" + (d.getMonth()+1) + "-" + d.getDate(); if (hash!="") { - dateString = hash.substring(1); + dateString = hash.substring(1); } -fetch('/fileserver/log/message/log_'+dateString+'.txt') +fetch('/fileserver/log/data/data_'+dateString+'.txt') .then(response => { // handle the response if (response.status == 404) { - alert("no log data available for "+dateString); + alert("no log data available for "+dateString); } response.text() .then( result => { @@ -53,10 +53,10 @@ fetch('/fileserver/log/message/log_'+dateString+'.txt') var timex = 1; for (let line of lines) { - if (line.includes("PostProcessing - Raw")) { + { console.log(line); - var value = line.split(" ")[6]; - var time = line.split(" ")[0]; + var value = line.split("\t")[3]; + var time = line.split("\t")[0]; console.log("> "+time+" "+value+"\n"); if (value<1000) { trace.x.push(timex); diff --git a/sd-card/html/graph_data.html b/sd-card/html/graph_data.html new file mode 100644 index 00000000..c790b31a --- /dev/null +++ b/sd-card/html/graph_data.html @@ -0,0 +1,82 @@ + + + + + + + + +
+ + + + + + \ No newline at end of file From e0ae9b8e4f8f8a610246e09ea47d01320438b6a4 Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Mon, 24 Oct 2022 21:20:46 +0200 Subject: [PATCH 28/32] Extend Graph.html --- .../jomjol_fileserver_ota/server_file.cpp | 66 ++++++++++- .../jomjol_fileserver_ota/server_file.h | 3 + .../jomjol_flowcontroll/ClassFlowControll.cpp | 6 + .../jomjol_flowcontroll/ClassFlowControll.h | 1 + .../ClassFlowPostProcessing.cpp | 16 +++ .../ClassFlowPostProcessing.h | 1 + .../jomjol_tfliteclass/server_tflite.cpp | 12 ++ .../jomjol_tfliteclass/server_tflite.h | 3 + sd-card/html/edit_config_param.html | 32 ------ sd-card/html/graph.html | 103 ++++++++++++++---- sd-card/html/graph_data.html | 82 -------------- sd-card/html/readconfigparam.js | 62 +++++++++++ 12 files changed, 245 insertions(+), 142 deletions(-) delete mode 100644 sd-card/html/graph_data.html diff --git a/code/components/jomjol_fileserver_ota/server_file.cpp b/code/components/jomjol_fileserver_ota/server_file.cpp index 22e1b064..f6a992b3 100644 --- a/code/components/jomjol_fileserver_ota/server_file.cpp +++ b/code/components/jomjol_fileserver_ota/server_file.cpp @@ -36,6 +36,8 @@ extern "C" { #include "defines.h" #include "ClassLogFile.h" +#include "server_tflite.h"" + #include "server_help.h" #include "interface_mqtt.h" #include "server_GPIO.h" @@ -78,13 +80,69 @@ using namespace std; string SUFFIX_ZW = "_0xge"; +esp_err_t get_numbers_file_handler(httpd_req_t *req) +{ + std::string ret = tfliteflow.getNumbersName(); + +// ESP_LOGI(TAG, "Result get_numbers_file_handler: %s", ret.c_str()); + + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); + httpd_resp_set_type(req, "text/plain"); + + httpd_resp_sendstr_chunk(req, ret.c_str()); + httpd_resp_sendstr_chunk(req, NULL); + + return ESP_OK; +} + + +esp_err_t get_data_file_handler(httpd_req_t *req) +{ + struct dirent *entry; + + std::string _filename, _fileext; + size_t pos = 0; + + const char verz_name[] = "/sdcard/log/data"; + ESP_LOGD(TAG, "Suche TFLITE in /sdcard/log/data"); + + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); + httpd_resp_set_type(req, "text/plain"); + + DIR *dir = opendir(verz_name); + while ((entry = readdir(dir)) != NULL) + { + _filename = std::string(entry->d_name); + ESP_LOGD(TAG, "File: %s", _filename.c_str()); + + // ignore all files with starting dot (hidden files) + if (_filename.rfind(".", 0) == 0) { + continue; + } + + _fileext = _filename; + pos = _fileext.find_last_of("."); + if (pos != std::string::npos) + _fileext = _fileext.erase(0, pos + 1); + + ESP_LOGD(TAG, " Extension: %s", _fileext.c_str()); + + if (_fileext == "txt") + { + _filename = _filename + "\t"; + httpd_resp_sendstr_chunk(req, _filename.c_str()); + } + } + closedir(dir); + + httpd_resp_sendstr_chunk(req, NULL); + return ESP_OK; +} + + esp_err_t get_tflite_file_handler(httpd_req_t *req) { -// DIR *verzeichnis; -// struct dirent *files; struct dirent *entry; -// struct stat entry_stat; - std::string _filename, _fileext; size_t pos = 0; diff --git a/code/components/jomjol_fileserver_ota/server_file.h b/code/components/jomjol_fileserver_ota/server_file.h index 9dbcc88f..1e2764c9 100644 --- a/code/components/jomjol_fileserver_ota/server_file.h +++ b/code/components/jomjol_fileserver_ota/server_file.h @@ -10,3 +10,6 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st void delete_all_in_directory(std::string _directory); esp_err_t get_tflite_file_handler(httpd_req_t *req); +esp_err_t get_data_file_handler(httpd_req_t *req); +esp_err_t get_numbers_file_handler(httpd_req_t *req); + diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 9c900844..545d591c 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -647,6 +647,12 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req) return result; } + +string ClassFlowControll::getNumbersName() +{ + return flowpostprocessing->getNumbersName(); +} + string ClassFlowControll::getJSON(std::string _id, std::string _mac) { return flowpostprocessing->GetJSON(_id, _mac); diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.h b/code/components/jomjol_flowcontroll/ClassFlowControll.h index a8f92dc3..5fd3b08a 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.h +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.h @@ -51,6 +51,7 @@ public: string GetPrevalue(std::string _number = ""); bool ReadParameter(FILE* pfile, string& aktparamgraph); string getJSON(std::string _id = "", std::string _mac = ""); + string getNumbersName(); string TranslateAktstatus(std::string _input); diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index afe21a16..74bcb913 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -21,6 +21,22 @@ static const char* TAG = "class_flow_postproc"; #define PREVALUE_TIME_FORMAT_INPUT "%d-%d-%dT%d:%d:%d" +std::string ClassFlowPostProcessing::getNumbersName() +{ + std::string ret=""; + + for (int i = 0; i < NUMBERS.size(); ++i) + { + ret += NUMBERS[i]->name; + if (i < NUMBERS.size()-1) + ret = ret + "\t"; + } + +// ESP_LOGI(TAG, "Result ClassFlowPostProcessing::getNumbersName: %s", ret.c_str()); + + return ret; +} + std::string ClassFlowPostProcessing::GetJSON(std::string _id, std::string _mac, std::string _lineend) { std::string json="{" + _lineend; diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h index 3c53bb82..27a26d53 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h @@ -65,6 +65,7 @@ public: void SetPreValue(double zw, string _numbers, bool _extern = false); std::string GetJSON(std::string _id = "", std::string _mac = "", std::string _lineend = "\n"); + std::string getNumbersName(); void UpdateNachkommaDecimalShift(); diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index 9064d138..dde06571 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_tfliteclass/server_tflite.cpp @@ -397,6 +397,18 @@ esp_err_t handler_editflow(httpd_req_t *req) } } + if (_task.compare("namenumbers") == 0) + { + ESP_LOGI(TAGTFLITE, "Get NUMBER list"); + return get_numbers_file_handler(req); + } + + if (_task.compare("data") == 0) + { + ESP_LOGI(TAGTFLITE, "Get data list"); + return get_data_file_handler(req); + } + if (_task.compare("tflite") == 0) { ESP_LOGD(TAGTFLITE, "Get tflite list"); diff --git a/code/components/jomjol_tfliteclass/server_tflite.h b/code/components/jomjol_tfliteclass/server_tflite.h index 6a1d3564..ee39fe3d 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.h +++ b/code/components/jomjol_tfliteclass/server_tflite.h @@ -3,6 +3,7 @@ #include #include "CImageBasis.h" +#include "ClassFlowControll.h" //#include "ClassControllCamera.h" @@ -19,3 +20,5 @@ std::string GetMQTTMainTopic(); esp_err_t GetJPG(std::string _filename, httpd_req_t *req); esp_err_t GetRawJPG(httpd_req_t *req); + +extern ClassFlowControll tfliteflow; diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index edc6c947..8dbd750f 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -328,21 +328,6 @@ textarea { Time to keep the separated digit images (in days, resp. "0" = forever)
- - - @@ -1727,11 +1699,9 @@ function UpdateInput() { WriteParameter(param, category, "Digits", "CNNGoodThreshold", true); WriteParameter(param, category, "Digits", "LogImageLocation", true); WriteParameter(param, category, "Digits", "LogfileRetentionInDays", true); -// WriteParameter(param, category, "Digits", "ModelInputSize", false); WriteParameter(param, category, "Analog", "LogImageLocation", true); WriteParameter(param, category, "Analog", "LogfileRetentionInDays", true); -// WriteParameter(param, category, "Analog", "ModelInputSize", false); WriteParameter(param, category, "PostProcessing", "PreValueUse", true); WriteParameter(param, category, "PostProcessing", "PreValueAgeStartup", true); @@ -1844,12 +1814,10 @@ function ReadParameterAll() ReadParameter(param, "Digits", "CNNGoodThreshold", true); ReadParameter(param, "Digits", "LogImageLocation", true); ReadParameter(param, "Digits", "LogfileRetentionInDays", true); -// ReadParameter(param, "Digits", "ModelInputSize", false); ReadParameter(param, "Analog", "Model", false); ReadParameter(param, "Analog", "LogImageLocation", true); ReadParameter(param, "Analog", "LogfileRetentionInDays", true); -// ReadParameter(param, "Analog", "ModelInputSize", false); ReadParameter(param, "PostProcessing", "PreValueUse", true); ReadParameter(param, "PostProcessing", "PreValueAgeStartup", true); diff --git a/sd-card/html/graph.html b/sd-card/html/graph.html index d3e15026..0c990b19 100644 --- a/sd-card/html/graph.html +++ b/sd-card/html/graph.html @@ -2,6 +2,11 @@ + + + + + - - - -
- - - - - - \ No newline at end of file diff --git a/sd-card/html/readconfigparam.js b/sd-card/html/readconfigparam.js index 9e7eb8b7..ffacacf8 100644 --- a/sd-card/html/readconfigparam.js +++ b/sd-card/html/readconfigparam.js @@ -11,6 +11,68 @@ var NUMBERS = new Array(0); var REFERENCES = new Array(0); +function getNUMBERSList() { + _basepath = getbasepath(); + var datalist = ""; + + var xhttp = new XMLHttpRequest(); + xhttp.addEventListener('load', function(event) { + if (xhttp.status >= 200 && xhttp.status < 300) { + datalist = xhttp.responseText; + } else { + console.warn(request.statusText, request.responseText); + } + }); + + try { + url = _basepath + '/editflow.html?task=namenumbers'; + xhttp.open("GET", url, false); + xhttp.send(); + + } + catch (error) + { + alert("Loading Hostname failed"); + } + + datalist = datalist.split("\t"); +// datalist.pop(); + + return datalist; + } + + +function getDATAList() { + _basepath = getbasepath(); + tflitelist = ""; + + var xhttp = new XMLHttpRequest(); + xhttp.addEventListener('load', function(event) { + if (xhttp.status >= 200 && xhttp.status < 300) { + tflitelist = xhttp.responseText; + } else { + console.warn(request.statusText, request.responseText); + } + }); + + try { + url = _basepath + '/editflow.html?task=data'; + xhttp.open("GET", url, false); + xhttp.send(); + + } + catch (error) + { +// alert("Loading Hostname failed"); + } + + tflitelist = tflitelist.split("\t"); + tflitelist.pop(); + + return tflitelist; + } + + function getTFLITEList() { _basepath = getbasepath(); tflitelist = ""; From c1369ca0ffd2d148dfec8f9b447a1e9fe6a0840d Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Mon, 24 Oct 2022 22:32:26 +0200 Subject: [PATCH 29/32] Update build.yaml (#1216) --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 66b5c3af..306e09fc 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,6 @@ name: Build and Pack -on: [push] +on: [push, pull_request] jobs: ######################################################################################### From 3f687a72339aff9e69a5a30f33bb605785725f29 Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Mon, 24 Oct 2022 22:42:44 +0200 Subject: [PATCH 30/32] Update edit_config_param.html --- sd-card/html/edit_config_param.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index 8dbd750f..d2f3caee 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -721,7 +721,7 @@ textarea { From 550d9e1c87ceb2e97498770809749b009c744264 Mon Sep 17 00:00:00 2001 From: CaCO3 Date: Mon, 24 Oct 2022 22:45:36 +0200 Subject: [PATCH 31/32] typos --- sd-card/html/edit_config_param.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index d2f3caee..ac6b5a46 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -499,7 +499,7 @@ textarea { @@ -715,13 +715,13 @@ textarea { From 9c2de84ee459ca243bead2305d297edce5545933 Mon Sep 17 00:00:00 2001 From: Frank Haverland Date: Tue, 25 Oct 2022 06:18:43 +0200 Subject: [PATCH 32/32] fix slashes in github.ref_name --- .github/workflows/build.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 66b5c3af..c87c9c81 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -77,23 +77,24 @@ jobs: id: vars run: | echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "branch=$(echo ${{ github.ref_name }} | tr / .)" >> $GITHUB_OUTPUT - name: Rename firmware file to contain versioning (old ota) run: | mkdir -p ./dist_old_ota - cp "./code/.pio/build/esp32cam/firmware.bin" "./dist_old_ota/firmware__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }}).bin" + cp "./code/.pio/build/esp32cam/firmware.bin" "./dist_old_ota/firmware__${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }}).bin" - name: Upload Firmware artifact (old OTA concept) uses: actions/upload-artifact@v3 with: # name: "firmware__${{ github.ref_name }}__(${{ steps.vars.outputs.sha_short }})__(extract_before_upload__only_needed_for_migration_from_11.3.1)" - name: "firmware__(extract_before_upload)__${{ github.ref_name }}__(${{ steps.vars.outputs.sha_short }})" + name: "firmware__(extract_before_upload)__${{ steps.vars.outputs.branch }}__(${{ steps.vars.outputs.sha_short }})" path: ./dist_old_ota/* - name: Upload Web interface artifact (old OTA concept) uses: actions/upload-artifact@v3 with: - name: "html__${{ github.ref_name }}__(${{ steps.vars.outputs.sha_short }})" + name: "html__${{ steps.vars.outputs.branch }}__(${{ steps.vars.outputs.sha_short }})" path: ./sd-card/html/* @@ -127,6 +128,7 @@ jobs: id: vars run: | echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "branch=$(echo ${{ github.ref_name }} | tr / .)" >> $GITHUB_OUTPUT - name: Prepare update.zip artifact run: | @@ -157,7 +159,7 @@ jobs: - name: Upload dist as update.zip artifact (Firmware + Web UI + CNN) uses: actions/upload-artifact@v3 with: - name: "update__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})" + name: "update__${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})" path: ./dist/* - name: Store generated files in cache @@ -165,7 +167,7 @@ jobs: with: path: | ./dist - key: ${{ github.run_number }}-pack-for-OTA-v2 + key: ${{ steps.vars.outputs.branch }}-pack-for-OTA-v2 @@ -195,6 +197,7 @@ jobs: id: vars run: | echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "branch=$(echo ${{ github.ref_name }} | tr / .)" >> $GITHUB_OUTPUT - name: Prepare artifacts for release run: | @@ -211,7 +214,7 @@ jobs: - name: Upload initial_esp32_setup.zip artifact (Firmware + Bootloader + Partitions + Web UI) uses: actions/upload-artifact@v3 with: - name: "initial_esp32_setup__${{ github.ref_name }}_(${{ steps.vars.outputs.sha_short }})" + name: "initial_esp32_setup__${{ steps.vars.outputs.branch }}_(${{ steps.vars.outputs.sha_short }})" path: ./firmware - name: Store generated files in cache
-
+
- +
-
+
@@ -377,19 +362,6 @@ textarea { Time to keep the separated digit images (in days, resp. "0" = forever)

PostProcessing

- Intervall in which the counter is read (in minutes). Number must be greater than 3 minutes. + Intervall in which the number(s) are read (in minutes). If a run takes longer than this interval, the next run gets postponed until the current run completes.
- Defines if the change rate compared to the previous value is calculated as absolute change (AbsoluteChange) or as rate normalized to the intervall (RateChange = change/minute). + Defines if the change rate compared to the previous value is calculated as absolute change (AbsoluteChange) or as rate normalized to the interval (RateChange = change/minute).
- Intervall + Interval - Intervall in which the number(s) are read (in minutes). If a run takes longer than this interval, the next run gets postponed until the current run completes. + Interval in which the number(s) are read (in minutes). If a run takes longer than this interval, the next run gets postponed until the current run completes.