Technical Support
On-Line Manuals
RL-ARM User's Guide (MDK v4)
#include <rtl.h>
BOOL ftpc_connect (
U8* ipadr, /* IP address of the FTP server. */
U16 port, /* Port number of FTP server. */
U8 command, /* FTP command to perform on connect. */
void (*cbfunc)(U8 event) ); /* Function to call when the session ends. */
The ftpc_connect function starts the FTP client on the
TCPnet system. This causes the FTP client to then start a FTP session
by connecting to a FTP server on the TCP port specified in the
function argument. If the port is not specified, that is the
argument port has a value of 0, the system uses a standard FTP
server port to connect to.
The argument ipadr points to an array of 4 bytes containing
the dotted-decimal notation of the IP address of the FTP server to
connect to.
The argument command spedifies a command to preform, when
FTP client connects to FTP server. The following commands are
supported:
The argument cbfunc points to a function that the FTP
client running on TCPnet calls when the FTP session ends. The
cbfunc is an event callback function that uses the
event argument of the cbfunc function to signal one of
the following FTP events:
The ftpc_connect function is in the RL-TCPnet library. The
prototype is defined in rtl.h.
note
The ftpc_connect function returns __TRUE if the FTP client
has been successfully started. Otherwise it returns __FALSE.
ftpc_cbfunc
static void ftpc_notify (U8 event);
void file_transfer (void) {
U8 srvip[4] = {192,168,2,253};
if (ftpc_connect (srvip, 0, FTPC_CMD_GET, ftpc_notify) == 0) {
printf("Connect failed, the client is busy.\n");
}
else {
printf("FTP client started.\n");
}
}
static void ftpc_notify (U8 event) {
switch (event) {
case FTPC_EVT_SUCCESS:
printf ("Command successful\n");
break;
case FTPC_EVT_TIMEOUT:
printf ("Failed, timeout expired\n");
break;
case FTPC_EVT_LOGINFAIL:
printf ("Failed, username/password invalid\n");
break;
case FTPC_EVT_NOACCESS:
printf ("Failed, operation not allowed\n");
break;
case FTPC_EVT_NOTFOUND:
printf ("Failed, file or path not found\n");
break;
case FTPC_EVT_NOPATH:
printf ("Failed, working directory not found\n");
break;
case FTPC_EVT_ERRLOCAL:
printf ("Failed, local file open/write error\n");
break;
case FTPC_EVT_ERROR:
printf ("Failed, unspecified protocol error.