ftp client: transferred files are empty

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

ftp client: transferred files are empty

跳至解决方案
1,636 次查看
Curro
Contributor III

I'm working on custom board, mqx 3.8 and K60.

I need to transfer files from board SD card to a PC via ftp. My board is FTP client and pc is FTP server.

Everything seems to work fine but transferred files are empty (I mean that file is 0Kb and if I open it with notepad nothing is contained).

Any idea?

Many thanks,

Corrado

This is my test code:

------------------------------

  response = FTP_open(&ftphandle, IPADDR(192,168,0,2), stdout);

  if (response == -1)

  {

     ...error...

  }

  response = FTP_command(ftphandle, "USER g801\r\n", stdout);

  if ((response >= 300) && (response < 400))

  {

    response = FTP_command(ftphandle, "PASS password\r\n", stdout);

  }

  if ((response >= 200) && (response < 300))

  {

    if(ioctl(filesystem_handle,IO_IOCTL_CHANGE_CURRENT_DIR,"a:/sys")==MFS_NO_ERROR)

    {

      response = FTP_command_data(ftphandle, "STOR CALIB.TXT\r\n", stdout, filesystem_handle, FTPMODE_PORT | FTPDIR_SEND);

      response = FTP_command_data(ftphandle, "STOR DT0001.CSV\r\n", stdout, filesystem_handle, FTPMODE_PORT | FTPDIR_SEND);

    }

  }

  FTP_close(ftphandle, stdout);

}

And this is FTP server log:

--------------------------------------

(000001)19/02/2014 13:25:49 - (not logged in) (192.168.0.30)> Connected, sending welcome message...

(000001)19/02/2014 13:25:49 - (not logged in) (192.168.0.30)> 220 Server Gei per test

(000001)19/02/2014 13:25:49 - (not logged in) (192.168.0.30)> USER g801

(000001)19/02/2014 13:25:49 - (not logged in) (192.168.0.30)> 331 Password required for g801

(000001)19/02/2014 13:25:49 - (not logged in) (192.168.0.30)> PASS *********

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> 230 Logged on

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> PORT 192,168,0,30,19,135

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> 200 Port command successful

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> STOR CALIB.TXT

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> 150 Opening data channel for file upload to server of "/CALIB.TXT"

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> 226 Successfully transferred "/CALIB.TXT"

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> PORT 192,168,0,30,19,134

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> 200 Port command successful

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> STOR DT0001.CSV

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> 150 Opening data channel for file upload to server of "/DT0001.CSV"

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> 226 Successfully transferred "/DT0001.CSV"

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> QUIT

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> 221 Goodbye

(000001)19/02/2014 13:25:49 - g801 (192.168.0.30)> disconnected.

0 项奖励
回复
1 解答
1,195 次查看
Curro
Contributor III

I changed MQX_FILE_PTR in FTP_command_data and now it works.

This is new code:

  if ((response >= 200) && (response < 300))

  {

      response = FTP_command_data(ftphandle, "MODE S\r\n", stdout, stdout, FTPMODE_PORT | FTPDIR_SEND);

      fp=fopen("a:/sys/CALIB.TXT","r");

      if(fp!=NULL)

      {

        response = FTP_command_data(ftphandle, "STOR CALIB.TXT\r\n", stdout, fp, FTPMODE_PORT | FTPDIR_SEND);

        fclose(fp);

      }

      fp=fopen("a:/sys/DT0001.CSV","r");

      if(fp!=NULL)

      {

        response = FTP_command_data(ftphandle, "STOR DT0001.CSV\r\n", stdout, fp, FTPMODE_PORT | FTPDIR_SEND);

        fclose(fp);

      }

  }

  FTP_close(ftphandle, stdout);

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,196 次查看
Curro
Contributor III

I changed MQX_FILE_PTR in FTP_command_data and now it works.

This is new code:

  if ((response >= 200) && (response < 300))

  {

      response = FTP_command_data(ftphandle, "MODE S\r\n", stdout, stdout, FTPMODE_PORT | FTPDIR_SEND);

      fp=fopen("a:/sys/CALIB.TXT","r");

      if(fp!=NULL)

      {

        response = FTP_command_data(ftphandle, "STOR CALIB.TXT\r\n", stdout, fp, FTPMODE_PORT | FTPDIR_SEND);

        fclose(fp);

      }

      fp=fopen("a:/sys/DT0001.CSV","r");

      if(fp!=NULL)

      {

        response = FTP_command_data(ftphandle, "STOR DT0001.CSV\r\n", stdout, fp, FTPMODE_PORT | FTPDIR_SEND);

        fclose(fp);

      }

  }

  FTP_close(ftphandle, stdout);

0 项奖励
回复
1,195 次查看
hirentailor
Contributor I

hi

I need to transfer files from board SD card to a PC via ftp. My board is FTP client and pc is FTP server.

i put same test code as you but my program does not come out from FTP_open function it stuck in this line

/// Get a control socket

  ctrl_sock = socket(PF_INET, SOCK_STREAM, 0);

   if (ctrl_sock == RTCS_SOCKET_ERROR) {

    return RTCS_ERROR;

   }

I increse my  ENET_FRAMESIZE_MAXDATA also in ethernet.h file.

0 项奖励
回复