Hello,
It was a problem with too many requests to TCP/IP thread, to prevent
this situation you need to check that the previous "chunk" was already
sended.
My solution:
#define BUFFER_OUT 64000
static BYTE archDownBuffer[BUFFER_OUT] __attribute__ ((section(".sdram")));
static BYTE respond[110];
UINT archDownCounter, sentCounter;
FIL arch_file;
void archive_download(struct netconn *conn, const char* filepath)
{
FRESULT res;
archDownCounter = 0;
sentCounter = 0;
size_t written;
int cx;
err_t test;
res = f_open(&arch_file, filepath, FA_READ);
if (res == FR_OK)
{
cx = snprintf(archDownBuffer, BUFFER_OUT,
"HTTP/1.1 200 OK \r\nContent-Type:
file/csv\r\nContent-Length: %lu\r\n\r\n", arch_file.fsize);
netconn_write(conn, (const char* )(archDownBuffer), (size_t
)cx, NETCONN_NOCOPY);
for (;;)
{
if(conn->state == NETCONN_NONE) // check the state
{
res = f_read(&arch_file, archDownBuffer, sizeof
archDownBuffer, &archDownCounter); /* Read a chunk of source file */
if (res || archDownCounter == 0) break; /* error or eof */
test = netconn_write_partly(conn, (const char*)
(archDownBuffer), (size_t) archDownCounter, NETCONN_MORE, &written);
if (test != ERR_OK) break; /* error or disk full */
if (written != archDownCounter) break;
vTaskDelay(150); //time for other tasks
}
}
f_close(&arch_file);
}
}
Regards,
Michał Gołębiowski
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users