⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.txt

📁 世纪民生公司的cs6209的开发ftp服务器的演示源程序。
💻 TXT
字号:
About this DEMO
	This is a sample FTP client demo program , it receive file name list from
FTP server and print in RS232 , then transmit a file named "cs00.jpg" from code
memory .

	Please change FTP server IP address	and user name , password in main function.


HOW TO USE FTP CLIENT API

1.Normal mode(Ftp data socket is connect from FTP server to FTP client) :
	a.Include "ftp.h" head file in main.c and libif.c
	
	b.write callback function for FTP client like :
		//be call when error occure
		char ftp_on_error(st_ftp *ftp)
		{
			//return 0 to force close FTP client ,1 to ignore
		}
		
		//be call when FTP is ready to send data to FTP server
		char ftp_on_data_send(TSOCK *ts,char start_of_send_flag)
		{
			//the start_of_send_flag is set when first time call this function
			//if there are no more data to send return 0 
			//if there are more data to send return 1 
		}
		//be call when FTP receive data from FTP server
		char ftp_on_data_receive(TSOCK *ts,char end_of_data_flag)
		{
			//the end_of_data_flag is set when this is the last data receive from
			//FTP server
			//Return value is ignore
		}

	c.Initialize st_ftp structure(fill user name ,password ,FTP server IP ,
	  set on_error callback function and set a socket in cs620X for FTP client 
	  command_socket).
	  
	d.Add code in server_action in libif.c like
		if (port==ftp_data_port){	
		extern st_ftp myftp;
		ts->app=&myftp;
		myftp.Data_socket=ts;
		return (ftp_data_upcall(ts,conn));
	
	  In which myftp is a structure of st_ftp.
	  
	e.Open FTP client and enqueue command like
	  if (ftp_open(ftp,0)==FTP_SUCCESS)
	  {
		en_queue_command(ftp,"NLST",FTP_GET_FILE,ftp_on_data_receive);
		en_queue_command(ftp,"TYPE I",FTP_NO_DATA,0);
		en_queue_command(ftp,"STOR CS00.jpg",FTP_SEND_FILE,ftp_on_data_send);
		en_queue_command(ftp,"quit",FTP_QUIT,0);
	  }  
	  
2.Passive mode(Ftp data socket is connect from FTP client to FTP server):

	a.Include "ftp.h" head file in main.c and libif.c
	
	b.write callback function for FTP client like :
		//be call when error occure
		char ftp_on_error(st_ftp *ftp)
		{
			//return 0 to force close FTP client ,1 to ignore
		}
		
		//be call when FTP is ready to send data to FTP server
		char ftp_on_data_send(TSOCK *ts,char start_of_send_flag)
		{
			//the start_of_send_flag is set when first time call this function
			//if there are no more data to send return 0 
			//if there are more data to send return 1 
		}
		//be call when FTP receive data from FTP server
		char ftp_on_data_receive(TSOCK *ts,char end_of_data_flag)
		{
			//the end_of_data_flag is set when this is the last data receive from
			//FTP server
			//Return value is ignore
		}

	c.Initialize st_ftp structure(fill user name ,password ,FTP server IP ,
	  set on_error callback function and set two socket in cs620X for FTP client 
	  command_socket and data_socket).
	  
	d.Open FTP client and enqueue command like
	  if (ftp_open(ftp,0)==FTP_SUCCESS)
	  {
		en_queue_command(ftp,"NLST",FTP_GET_FILE,ftp_on_data_receive);
		en_queue_command(ftp,"TYPE I",FTP_NO_DATA,0);
		en_queue_command(ftp,"STOR CS00.jpg",FTP_SEND_FILE,ftp_on_data_send);
		en_queue_command(ftp,"quit",FTP_QUIT,0);
	  }  
	  
	  In which ftp is a point to st_ftp.
	
3.OVERLAY option for Keil C	

?PR?_SERVER_ACTION?LIBIF		   !	?PR?_FTP_RECEIVE_FUNCTION?FTPAPI,
?PR?_SERVER_ACTION?LIBIF		   !	?PR?_FTP_SEND_FUNCTION?FTPAPI,
?PR?_CLIENT_ACTION?LIBIF		   !	?PR?_FTP_RECEIVE_FUNCTION?FTPAPI,
?PR?_CLIENT_ACTION?LIBIF		   !	?PR?_FTP_SEND_FUNCTION?FTPAPI,
?PR?_FTP_RECEIVE_FUNCTION?FTPAPI   !    ?PR?_FTP_ON_DATA_RECEIVE?FTP_CALLBACK,
?PR?_FTP_SEND_FUNCTION?FTPAPI      !    ?PR?_FTP_ON_DATA_SEND?FTP_CALLBACK,
?PR?_FTP_CLIENT_FUNCTION?FTPAPI    !    ?PR?_FTP_ON_ERROR?FTP_CALLBACK,

	You can add it to your project in OVERLAP memo(Option->ML51misc).

4.Some FTP Command(Please refer to RFC959
	a.type FTP_NO_DATA
		"TYPE I" :Set file transmit as Binary.
		"TYPE A" :Set file transmit as ASCII.
		"CWD"	 :change work direction (ex:"CWD upload")
		"CDUP"	 :change work direction to parent direction.
		"NOOP"	 :no action.
		"DELE"	 :delete a file in ftp server.
		"MKD"	 :Make a new direction.
	
	b.type FTP_GET_FILE		
		"NLST"	:Get file name list from FTP server.
		"RETR"	:Get a file from FTP server.
		"LIST"	:Get file list from FTP server.
		
	c.type FTP_SEND_FILE
		"STOR"	:Upload a file to FTP server
	
	d.type FTP_QUIT	
		"QUIT"	:Close FTP section.
		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -