I am using code from the EFFS-FTP example to provide drag-and-drop access to the SD card via an ftp window that's open on a pc. The example works nicely as long as the number of files and directories on the SD card is small. However, as the number of files increase, things bog down unacceptably for most file operations. I think this is because somewhere in functions like FTPD_ListFile() and FTPD_ListSubdirectories() the filename and date/time info is getting echoed to stdio. This takes forever for large directories! I am presuming that there's a printf() somewhere that's doing this, and if so, I'd like to comment it out. Unfortunately, I can't quite understand where this is happening or perhaps how the FTP callback functions like FTPDCallBackReportFunct() work.
Any suggestions greatly appreciated.
Stop StdIO output for ftp file actions in EFFS-FTP Example?
-
- Posts: 513
- Joined: Sat Apr 26, 2008 7:14 am
Re: Stop StdIO output for ftp file actions in EFFS-FTP Examp
FTP works by callbacks. There should never be any printfs in system files. The ones you are looking for are probably in the example code .cpp files, such as FileSystemUtils.cpp. As an example, the printfs are probably there to illustrate how things work.
-
- Posts: 513
- Joined: Sat Apr 26, 2008 7:14 am
Re: Stop StdIO output for ftp file actions in EFFS-FTP Examp
I agree that the printfs should not be there, but, at least in the example files, if you open a directory on the sd card as an ftp folder on a pc then the contents of the directory are streamed to stdio. I've looked at the FileSystemsUtils.cpp, and I don't think that's where the stdio output is coming from. Instead it looks like it's the calls like FTPD_ListFile() and FTPD_ListSubdirectories() from ftp_f.cpp (which are also in the example code). More specifically, on a remote pc, if you open a folder on the sd card that's visible via ftp, the FTPD_ListSubDirectories() function runs. When it runs, it makes the directory visible on the remote pc, but also streams a verbose listing of all the files to stdio. In small directories, this is not a problem, but for directories with hundreds of files it's a big problem
For example, here's a partial steam to stdio after refreshing the ftp directory on the remote pc:
Displaying directory info from function FTPD_ListSubDirectories()
Displaying time/date information from function FTPD_Listfile()
20120712_114521.g.log |12:00:00 |07/12/2012 | 29746 Bytes
20120712_120002.g.log |12:09:52 |07/12/2012 | 7478 Bytes
20120712_121005.g.log |12:50:20 |07/12/2012 | 50077 Bytes
20120712_125031.g.log |13:00:02 |07/12/2012 | 54799 Bytes
20120712_130002.g.log |13:10:52 |07/12/2012 | 61301 Bytes
20120712_131103.g.log |13:11:40 |07/12/2012 | 0 Bytes
20120712_131149.g.log |16:01:06 |07/12/2012 | 0 Bytes
20120712_160108.g.log |16:02:18 |07/12/2012 | 1560 Bytes
20120712_160227.g.log |16:07:52 |07/12/2012 | 6034 Bytes
20120712_160802.g.log |16:16:06 |07/12/2012 | 9308 Bytes
20120712_161619.g.log |16:24:12 |07/12/2012 | 9126 Bytes
20120712_162424.g.log |16:26:22 |07/12/2012 | 1753 Bytes
20120712_162631.g.log |16:51:14 |07/12/2012 | 41395 Bytes
And here's the code --- FTPD_ListSubDirectories() --- that seems to be called. However, I don't see the printfs. Any idea where they might be?
For example, here's a partial steam to stdio after refreshing the ftp directory on the remote pc:
Displaying directory info from function FTPD_ListSubDirectories()
Displaying time/date information from function FTPD_Listfile()
20120712_114521.g.log |12:00:00 |07/12/2012 | 29746 Bytes
20120712_120002.g.log |12:09:52 |07/12/2012 | 7478 Bytes
20120712_121005.g.log |12:50:20 |07/12/2012 | 50077 Bytes
20120712_125031.g.log |13:00:02 |07/12/2012 | 54799 Bytes
20120712_130002.g.log |13:10:52 |07/12/2012 | 61301 Bytes
20120712_131103.g.log |13:11:40 |07/12/2012 | 0 Bytes
20120712_131149.g.log |16:01:06 |07/12/2012 | 0 Bytes
20120712_160108.g.log |16:02:18 |07/12/2012 | 1560 Bytes
20120712_160227.g.log |16:07:52 |07/12/2012 | 6034 Bytes
20120712_160802.g.log |16:16:06 |07/12/2012 | 9308 Bytes
20120712_161619.g.log |16:24:12 |07/12/2012 | 9126 Bytes
20120712_162424.g.log |16:26:22 |07/12/2012 | 1753 Bytes
20120712_162631.g.log |16:51:14 |07/12/2012 | 41395 Bytes
And here's the code --- FTPD_ListSubDirectories() --- that seems to be called. However, I don't see the printfs. Any idea where they might be?
Code: Select all
////////////////////////////////////////////////////////////////////////////////
// FTPD_ListSubDirectories() - List directories.
//
int FTPD_ListSubDirectories( const char *current_directory, void *pSession,
FTPDCallBackReportFunct *pFunc, int socket )
{
F_FIND find;
long rc;
char s[256];
f_chdir( "/" );
if ( *current_directory )
{
if ( f_chdir( ( char * ) current_directory ) )
{
return( FTPD_FAIL );
}
}
rc = f_findfirst( "*.*", &find );
if ( !rc )
{
//Added comment and slight edit to line below to add function name.
iprintf("\r\nDisplaying directory info from function FTPD_ListSubDirectories()\r\n");
do
{
if ( find.attr & F_ATTR_DIR )
{
//Commenting the 2 lines below in an effort to eliminate chars to stdio
// stops the stdio output, but it also stops the ftp folder from being visible on a remote PC
getdirstring( &find, s );
pFunc( socket, s );
}
}
while ( !f_findnext( &find ) );
}
return( FTPD_OK );
}
Re: Stop StdIO output for ftp file actions in EFFS-FTP Examp
I did a search in the example code for "Displaying time/date information" and can see it calls gettimedate( &find ), which has the iprintfs in it. I think that is what you are seeing. Comment out that call from the example code and I think that will take care of it.
-
- Posts: 513
- Joined: Sat Apr 26, 2008 7:14 am
Re: Stop StdIO output for ftp file actions in EFFS-FTP Examp
Rnixon: Thanks! It's hard to believe I missed that... Duh!
Re: Stop StdIO output for ftp file actions in EFFS-FTP Examp
Happy to help. I miss plenty of stuff myself when I look at the same piece of code too long.