8 years, 4 months ago.

How to speed up data file transfer rate in WIZnet FTP?

Hello, I would like to transfer 2MB files to a FTP server from my SD card. The files are readings from a sensor in a text file. Currently the transfer rate is about 4.9KB/s. Initially it was only 1.3KB/s as buffer size is 256. Increased buffer size makes the speed up to 4.9BB/s.

Below is the piece of code from my program which is responsible for the file transfer.

#define MAX_SS              1024

case s_put:
                    pc.printf("put waiting...\r\n");
                    sprintf(ftpfilename, "/sd/FTPClient/%s", gMsgBuf);
                    ftpfile = fopen(ftpfilename, "r");  
                    fseek(ftpfile, 0, SEEK_END);            // seek to end of file
                    remain_filesize = ftell(ftpfile);       // get current file pointer
                    fseek(ftpfile, 0, SEEK_SET);            // seek back to beginning of file                
                    while(remain_filesize!=0)
                    {
                        memset(buf, 0, sizeof(buf));
                        if(remain_filesize > MAX_SS)
                            send_byte = MAX_SS;
                        else
                            send_byte = remain_filesize;
                        fread (buf, 1, send_byte, ftpfile);
                        FTP_DATA_SOCK.send(buf, send_byte);
                        remain_filesize -= send_byte;
                        pc.printf("#");
                    }
                    fclose(ftpfile);
                    gDataPutGetStart = false; 
                    FTPCommand.Second = s_nocmd;     
                    FTP_DATA_SOCK.close(); 
                    break;   

After increasing buffer size makes my program to hang. Which way we can achieve the speeds uptp MB/s.

Be the first to answer this question.