Browse Source

Adding some infos/debugging-stuff for webtransfer-write

master
Torsten Stauder 4 years ago
parent
commit
e2fb876a22
  1. 23
      src/Web.cpp
  2. 2
      src/revision.h

23
src/Web.cpp

@ -568,11 +568,9 @@ void onWebsocketEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsE
void explorerHandleFileUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) { void explorerHandleFileUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
System_UpdateActivityTimer(); System_UpdateActivityTimer();
static uint32_t transferStartTimestamp = 0;
// New File // New File
if (!index) { if (!index) {
transferStartTimestamp = millis();
String utf8FilePath; String utf8FilePath;
static char filePath[MAX_FILEPATH_LENTGH]; static char filePath[MAX_FILEPATH_LENTGH];
if (request->hasParam("path")) { if (request->hasParam("path")) {
@ -623,8 +621,6 @@ void explorerHandleFileUpload(AsyncWebServerRequest *request, String filename, s
// delete task // delete task
vTaskDelete(fileStorageTaskHandle); vTaskDelete(fileStorageTaskHandle);
snprintf(Log_Buffer, Log_BufferLength, "%s: %s => %zu bytes in %lu ms (%lu kB/s)\n", (char *)FPSTR (fileWritten), filename.c_str(), index+len, (millis() - transferStartTimestamp), (index+len)/(millis() - transferStartTimestamp));
Log_Println(Log_Buffer, LOGLEVEL_INFO);
} }
} }
@ -632,6 +628,9 @@ void explorerHandleFileStorageTask(void *parameter) {
File uploadFile; File uploadFile;
size_t item_size; size_t item_size;
size_t bytesOk = 0;
size_t bytesNok = 0;
uint32_t transferStartTimestamp = millis();
uint8_t *item; uint8_t *item;
uint8_t value = 0; uint8_t value = 0;
@ -645,19 +644,31 @@ void explorerHandleFileStorageTask(void *parameter) {
item = (uint8_t *)xRingbufferReceive(explorerFileUploadRingBuffer, &item_size, portTICK_PERIOD_MS * 100); item = (uint8_t *)xRingbufferReceive(explorerFileUploadRingBuffer, &item_size, portTICK_PERIOD_MS * 100);
if (item != NULL) { if (item != NULL) {
uploadFile.write(item, item_size);
if (!uploadFile.write(item, item_size)) {
bytesNok += item_size;
} else {
bytesOk += item_size;
}
vRingbufferReturnItem(explorerFileUploadRingBuffer, (void *)item); vRingbufferReturnItem(explorerFileUploadRingBuffer, (void *)item);
} else { } else {
// No data in the buffer, check if all data arrived for the file // No data in the buffer, check if all data arrived for the file
uploadFileNotification = xTaskNotifyWait(0, 0, &uploadFileNotificationValue, 0); uploadFileNotification = xTaskNotifyWait(0, 0, &uploadFileNotificationValue, 0);
if (uploadFileNotification == pdPASS) { if (uploadFileNotification == pdPASS) {
uploadFile.close(); uploadFile.close();
snprintf(Log_Buffer, Log_BufferLength, "%s: %s => %zu bytes in %lu ms (%lu kB/s)", (char *)FPSTR (fileWritten), (char *)parameter, bytesNok+bytesOk, (millis() - transferStartTimestamp), (bytesNok+bytesOk)/(millis() - transferStartTimestamp));
Log_Println(Log_Buffer, LOGLEVEL_INFO);
snprintf(Log_Buffer, Log_BufferLength, "Bytes [ok] %zu / [not ok] %zu\n", bytesOk, bytesNok);
Log_Println(Log_Buffer, LOGLEVEL_DEBUG);
// done exit loop to terminate // done exit loop to terminate
break; break;
} }
vTaskDelay(portTICK_PERIOD_MS * 100); vTaskDelay(portTICK_PERIOD_MS * 100);
} }
vTaskDelay(portTICK_PERIOD_MS * 1);
#ifdef SD_MMC_1BIT_MODE
vTaskDelay(portTICK_PERIOD_MS * 1);
#else
vTaskDelay(portTICK_PERIOD_MS * 6);
#endif
} }
// send signal to upload function to terminate // send signal to upload function to terminate
xQueueSend(explorerFileUploadStatusQueue, &value, 0); xQueueSend(explorerFileUploadStatusQueue, &value, 0);

2
src/revision.h

@ -1,4 +1,4 @@
#ifndef __REVISION_H__ #ifndef __REVISION_H__
#define __REVISION_H__ #define __REVISION_H__
constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20210715-1";
constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20210716-1";
#endif #endif
Loading…
Cancel
Save