Hi,
Can anyone point me in the right direction ?
I designed a complicated project for my company consisting of an STM32H743 webserver using C, FreeRTOS,SSI,CGI and LWIP based on STM32cubeide compiler. I need technical help on the upload from browser straight to serial port on STM32 via the STM32. It is partially working, but there are problems with intermittent corruption of the binary file during upload.
Basically I have SSI CGI etc working OK but the binary file upload for large files sent from the browser has never worked consistently.
In desperation, I used an STM32F746 Nucleo board without RTOS/SSi/CGI etc. - just a simple cubeide project using LWIP configured only for HTTPD.
Exactly the same problem.
I realise that I could strip out the content-disposition /type fields etc., but why are there no examples around that give a fault free performance without corruption, especially during large binary or text file transfers?
Any ideas? Anyone?
Thanks
Chris
I use this index.shtml:
<form action ="/index.s html" enctype="multipart/form-data" method="post">
<p>Simple upload. Please specify a file:
<input type="file" name="datafilemnu" size="40">
<input type="submit" value="Upload ppf">
</br>
The reception of file data is as follows: (probably hacked about a bit now)
#define ser // for serial port on usart3
err_t httpd_post_begin(void *connection, const char *uri, const char *http_request,
uint16_t http_request_len, int content_len, char *response_uri,
uint16_t response_uri_len, uint8_t *post_auto_wnd)
{
return ERR_OK;
}
err_t httpd_post_receive_data(void *connection, struct pbuf *p)
{ //multipart/form-data is used
int32_t i,len=0;
uint32_t DataOffset, FilenameOffset;
char *data, *ptr, filename[20];
char readval[4800];
DataOffset =0;
data = p->payload;
len = p->tot_len;
// HAL_UART_Transmit(&huart3,data,len , 0xFFFFFF);
if (DataFlag ==0) //has not entered before - must be first pbuf
{ m1++;
/* parse packet for Content-length field */
// size = Parse_Content_Length(data, (uint32_t)(p->tot_len));
// parse packet for the octet-stream field
for (i=0;i<len;i++)
{
if (strncmp ((char*)(data+i), octet_stream, 13)==0)
{
DataOffset = i+16;
DataFlag++;
break;
}
}
// case of MSIE8 : we do not receive data in the POST packet
if (DataOffset==0)
{
DataFlag++;
BrowserFlag = 1;
pbuf_free(p);
return ERR_OK; // returns here but this is firefox
}
// case of Mozilla Firefox v3.6 : we receive data in the POST packet
for (i=0;i<len;i++)
{
if (strncmp ((char*)(data+i), "filename=", 9)==0)
{
FilenameOffset = i+10;
break;
}
}
i =0;
if (FilenameOffset)
{
while((*(data+FilenameOffset + i)!=0x22 )&&(i<20))
{
filename
= *(data+FilenameOffset + i);
i++;
}
filename = 0x0;
}
if (i==0)
{
pbuf_free(p);
DataFlag=0; // RESET HERE
return ERR_OK;
}
ptr = (char*)(data + DataOffset);
len-= DataOffset;
// memcpy(str, p -> payload, p -> len);//added
m2++;
#ifdef ser
HAL_UART_Transmit(&huart3, ptr,len , 0xFFFFFF);
#endif
pbuf_free(p);
return ERR_OK;
}//if dataflag==0
else
{
// if last packet need to remove the http boundary tag
// parse packet for "\r\n--" starting from end of data
i=0; //??? 4?
while ((strncmp ((char*)(data+ i),http_crnl_2 , 4))&&
(strncmp ((char*)(data+ i),http_crnl_3 , 4)) && (i<len))
{
i++;
}
// char *ip;
// ip=p->payload;
// removeSubstr(ip, "dndata=");
// memcpy(str, p -> payload, p -> len);//added
m3++;
#ifdef ser
HAL_UART_Transmit(&huart3, p->payload,i , 0xFFFFFF);
#endif
if(i!=len)
DataFlag =0;
}
// not last data packet
pbuf_free(p);
return ERR_OK;
}
void httpd_post_finished(void *connection, char *response_uri, u16_t response_uri_len)
{
connection = NULL;
}