|

楼主 |
发表于 2017-12-15 18:34:53
|
显示全部楼层
36.6 实验例程说明(RTX)
36.6.1 STM32F407开发板实验
配套例子:
V5-1051_RL-TCPnet实验_FTP服务器(RTX)
实验目的:
1. 学习RL-TCPnet的FTP服务器实现。
实验内容:
1. 强烈推荐将网线接到路由器或者交换机上面测试,因为已经使能了DHCP,可以自动获取IP地址。
2. FTP服务器的存储器是采用的SD卡,所以测试本例子前务必准备好一个SD卡并插上。
3. 文件系统是采用的RL-FlashFS,此文件系统的文件名仅支持ASCII字符,不支持中文,特别注意!
4. FTP服务器的访问方法在本实例配套教程里面有详细讲解。可以使用FTP客户端软件访问,也可以在“我的电脑”地址栏输入ftp://armfly进行访问。
5. FTP服务器的用户名admin,密码123456。
实验操作:
详见本章节36.5小节。
配置向导文件设置(Net_Config.c):
详见本章节36.3小节。
调试文件设置(Net_Debug.c):
详见本章节36.4小节。
RTX配置:
RTX配置向导详情如下:
Task Configuration
(1)Number of concurrent running tasks
允许创建6个任务,实际创建了如下5个任务:
AppTaskUserIF任务 :按键消息处理。
AppTaskLED任务 :LED闪烁。
AppTaskMsgPro任务 :按键检测。
AppTaskTCPMain任务:RL-TCPnet测试任务。
AppTaskStart任务 :启动任务,也是最高优先级任务,这里实现RL-TCPnet的时间基准更新。
(2)Number of tasks with user-provided stack
创建的5个任务都是采用自定义堆栈方式。
(3)Run in privileged mode
设置任务运行在非特权级模式。
RTX任务调试信息:
程序设计:
任务栈大小分配:
staticuint64_t AppTaskUserIFStk[1024/8]; /* 任务栈 */
staticuint64_t AppTaskLEDStk[1024/8]; /* 任务栈 */
staticuint64_t AppTaskMsgProStk[1024/8]; /* 任务栈 */
staticuint64_t AppTaskTCPMainStk[4096/8]; /* 任务栈 */
staticuint64_t AppTaskStartStk[1024/8]; /* 任务栈 */
将任务栈定义成uint64_t类型可以保证任务栈是8字节对齐的,8字节对齐的含义就是数组的首地址对8求余等于0。如果不做8字节对齐的话,部分C语言库函数、浮点运算和uint64_t类型数据运算会出问题。
系统栈大小分配:
RTX初始化:
- /*
- *********************************************************************************************************
- * 函 数 名: main
- * 功能说明: 标准c程序入口。
- * 形 参: 无
- * 返 回 值: 无
- *********************************************************************************************************
- */
- int main (void)
- {
- /* 初始化外设 */
- bsp_Init();
-
- /* 创建启动任务 */
- os_sys_init_user (AppTaskStart, /* 任务函数 */
- 5, /* 任务优先级 */
- &AppTaskStartStk, /* 任务栈 */
- sizeof(AppTaskStartStk)); /* 任务栈大小,单位字节数 */
- while(1);
- }
复制代码 硬件外设初始化
硬件外设的初始化是在 bsp.c 文件实现:
- /*
- *********************************************************************************************************
- * 函 数 名: bsp_Init
- * 功能说明: 初始化所有的硬件设备。该函数配置CPU寄存器和外设的寄存器并初始化一些全局变量。只需要调用一次
- * 形 参:无
- * 返 回 值: 无
- *********************************************************************************************************
- */
- void bsp_Init(void)
- {
- /*
- 由于ST固件库的启动文件已经执行了CPU系统时钟的初始化,所以不必再次重复配置系统时钟。
- 启动文件配置了CPU主时钟频率、内部Flash访问速度和可选的外部SRAM FSMC初始化。
-
- 系统时钟缺省配置为168MHz,如果需要更改,可以修改 system_stm32f4xx.c 文件
- */
- /* 优先级分组设置为4,可配置0-15级抢占式优先级,0级子优先级,即不存在子优先级。*/
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
-
- bsp_InitDWT(); /* 初始化DWT */
- bsp_InitUart(); /* 初始化串口 */
- bsp_InitKey(); /* 初始化按键变量(必须在 bsp_InitTimer() 之前调用) */
- bsp_InitLed(); /* 初始LED指示灯端口 */
-
- MountSD(); /* 挂载SD卡 */
- }
复制代码 RTX任务创建:
- /*
- *********************************************************************************************************
- * 函 数 名: AppTaskCreate
- * 功能说明: 创建应用任务
- * 形 参: 无
- * 返 回 值: 无
- *********************************************************************************************************
- */
- static void AppTaskCreate (void)
- {
- HandleTaskUserIF = os_tsk_create_user(AppTaskUserIF, /* 任务函数 */
- 1, /* 任务优先级 */
- &AppTaskUserIFStk, /* 任务栈 */
- sizeof(AppTaskUserIFStk)); /* 任务栈大小,单位字节数 */
-
- HandleTaskLED = os_tsk_create_user(AppTaskLED, /* 任务函数 */
- 2, /* 任务优先级 */
- &AppTaskLEDStk, /* 任务栈 */
- sizeof(AppTaskLEDStk)); /* 任务栈大小,单位字节数 */
-
- HandleTaskMsgPro = os_tsk_create_user(AppTaskMsgPro, /* 任务函数 */
- 3, /* 任务优先级 */
- &AppTaskMsgProStk, /* 任务栈 */
- sizeof(AppTaskMsgProStk)); /* 任务栈大小,单位字节数 */
-
- HandleTaskTCPMain = os_tsk_create_user(AppTaskTCPMain, /* 任务函数 */
- 4, /* 任务优先级 */
- &AppTaskTCPMainStk, /* 任务栈 */
- sizeof(AppTaskTCPMainStk)); /* 任务栈大小,单位字节数 */
- }
复制代码 五个RTX任务的实现:
RL-TCPnet功能测试
这里专门创建了一个app_tcpnet_lib.c文件用于RL-TCPnet功能的测试,此文件主要实现网络主函数main_TcpNet的调用。
- #include "includes.h"
-
-
-
- /*
- *********************************************************************************************************
- * 函 数 名: TCPnetTest
- * 功能说明: TCPent测试函数。
- * 形 参: 无
- * 返 回 值: 无
- *********************************************************************************************************
- */
- void TCPnetTest(void)
- {
-
- while (1)
- {
- os_evt_wait_or(0x0001, 0xFFFF);
-
- /* RL-TCPnet主处理函数 */
- while (main_TcpNet() == __TRUE);
- }
- }
复制代码 FTP用户接口文件的实现
KEIL官网有提供FTP的接口文件,名为FTP_uif.c文件。我们就是在这个文件上修改。具体修改后的代码如下:
- #include <Net_Config.h>
- #include <File_Config.h>
- #include <stdio.h>
-
- /*----------------------------------------------------------------------------
- * FTP Server File Access Functions
- *---------------------------------------------------------------------------*/
-
- /*--------------------------- ftp_fopen -------------------------------------*/
-
- void *ftp_fopen (U8 *fname, U8 *mode) {
- /* Open file 'fname' for reading or writing. Return file handle. */
- return (fopen ((const char *)fname, (const char *)mode));
- }
-
-
- /*--------------------------- ftp_fclose ------------------------------------*/
-
- void ftp_fclose (void *file) {
- /* Close the file opened for reading or writing. */
- fclose (file);
- }
-
-
- /*--------------------------- ftp_fread -------------------------------------*/
-
- U16 ftp_fread (void *file, U8 *buf, U16 len) {
- /* Read 'len' bytes from file to buffer 'buf'. The file will be closed, */
- /* when the number of bytes read is less than 'len'. */
- return (fread (buf, 1, len, file));
- }
-
-
- /*--------------------------- ftp_fwrite ------------------------------------*/
-
- U16 ftp_fwrite (void *file, U8 *buf, U16 len) {
- /* Write 'len' bytes from buffer 'buf' to a file. */
- return (fwrite (buf, 1, len, file));
- }
-
-
- /*--------------------------- ftp_fdelete -----------------------------------*/
-
- BOOL ftp_fdelete (U8 *fname) {
- /* Delete a file, return __TRUE on success. */
- if (fdelete((char *)fname) == 0) {
- return (__TRUE);
- }
- return (__FALSE);
- }
-
-
- /*--------------------------- ftp_frename -----------------------------------*/
-
- BOOL ftp_frename (U8 *fname, U8 *newn) {
- /* Rename a file, return __TRUE on success. */
- if (frename((char *)fname, (char *)newn) == 0) {
- return (__TRUE);
- }
- return (__FALSE);
- }
-
-
- /*--------------------------- ftp_ffind -------------------------------------*/
-
- U16 ftp_ffind (U8 code, U8 *buf, U8 *mask, U16 buflen) {
- /* This function is called by the FTP server to find file names and other */
- /* file information. The output data is stored in ascii format to output */
- /* buffer 'buf' Parameter 'code' specifies requested file information. */
- /* Values for 'code': */
- /* 0 - read file size */
- /* 1 - read last-modified time of a file */
- /* 2 - list file names only (first call) */
- /* 3 - list file directory in extended format (first call) */
- /* 4 - list file names only (repeated call) */
- /* 5 - list file directory in extended format (repeated call) */
- static FINFO info;
- U32 rlen,v;
- U8 *tp;
-
- if (code < 4) {
- /* First call to ffind, initialize the info. */
- info.fileID = 0;
- }
-
- rlen = 0;
- next:
- if (ffind ((char *)mask, &info) == 0) {
- /* File found, print file information. */
- if (info.name[0] == '.') {
- if ((info.name[1] == 0) || (info.name[1] == '.' && info.name[2] == 0)) {
- /* Ignore the '.' and '..' folders. */
- goto next;
- }
- }
- switch (code) {
- case 0:
- /* Return file size as decimal number. */
- rlen = sprintf ((char *)buf,"%d\\r\\n", info.size);
- break;
-
- case 1:
- /* Return last-modified time in format "YYYYMMDDhhmmss". */
- rlen = sprintf ((char *)buf,"%04d%02d%02d",
- info.time.year, info.time.mon, info.time.day);
- rlen += sprintf ((char *)&buf[rlen],"%02d%02d%02d\\r\\n",
- info.time.hr, info.time.min, info.time.sec);
- break;
-
- case 2:
- case 4:
- /* List file names only. */
- rlen = sprintf ((char *)buf,"%s\\r\\n", info.name);
- break;
-
- case 3:
- case 5:
- /* List directory in extended format. */
- rlen = sprintf ((char *)buf,"%02d-%02d-%02d",
- info.time.mon, info.time.day, info.time.year%100);
- /* Convert time to "AM/PM" format. */
- v = info.time.hr % 12;
- if (v == 0) v = 12;
- if (info.time.hr < 12) tp = "AM";
- else tp = "PM";
- rlen += sprintf ((char *)&buf[rlen]," %02d:%02d%s",v,info.time.min,tp);
- if (info.attrib & ATTR_DIRECTORY) {
- rlen += sprintf ((char *)&buf[rlen],"%-21s"," <DIR>");
- }
- else {
- rlen += sprintf ((char *)&buf[rlen],"%21d", info.size);
- }
- rlen += sprintf ((char *)&buf[rlen]," %s\\r\\n", info.name);
- break;
- }
- }
- return (rlen);
- }
-
-
- /*--------------------------- ftp_accept_host -------------------------------*/
- #if 0
- BOOL ftp_accept_host (U8 *rem_ip, U16 rem_port) {
- /* This function checks if a connection from remote host is accepted or */
- /* not. If this function is missing, all remote hosts are accepted. */
-
- if (rem_ip[0] == 192 &&
- rem_ip[1] == 168 &&
- rem_ip[2] == 1 &&
- rem_ip[3] == 1) {
- /* Accept a connection. */
- return (__TRUE);
- }
- /* Deny a connection. */
- return (__FALSE);
- }
- #endif
-
-
- /*--------------------------- ftp_evt_notify --------------------------------*/
- #if 0
- void ftp_evt_notify (U8 evt) {
- /* This function notifies the user application about events in FTP server.*/
-
- switch (evt) {
- case FTP_EVT_LOGIN:
- /* User logged in, FTP session is busy. */
- break;
-
- case FTP_EVT_LOGOUT;
- /* User logged out, session is idle. */
- break;
-
- case FTP_EVT_LOGFAIL:
- /* User login failed (invalid credentials). */
- break;
-
- case FTP_EVT_DOWNLOAD:
- /* File download ended. */
- break;
-
- case FTP_EVT_UPLOAD:
- /* File upload ended. */
- break;
-
- case FTP_EVT_DELETE:
- /* File deleted. */
- break;
-
- case FTP_EVT_RENAME:
- /* File or directory renamed. */
- break;
-
- case FTP_EVT_MKDIR:
- /* Directory created. */
- break;
-
- case FTP_EVT_RMDIR:
- /* Directory removed. */
- break;
-
- case FTP_EVT_ERRLOCAL:
- /* Local file operation error. */
- break;
-
- case FTP_EVT_DENIED:
- /* Requested file operation denied. */
- break;
-
- case FTP_EVT_ERROR:
- /* Generic file operation or protocol error. */
- break;
- }
- }
- #endif
-
- /*----------------------------------------------------------------------------
- * end of file
- *---------------------------------------------------------------------------*/
复制代码
36.6.2 STM32F429开发板实验
配套例子:
V6-1051_RL-TCPnet实验_FTP服务器(RTX)
实验目的:
1. 学习RL-TCPnet的FTP服务器实现。
实验内容:
1. 强烈推荐将网线接到路由器或者交换机上面测试,因为已经使能了DHCP,可以自动获取IP地址。
2. FTP服务器的存储器是采用的SD卡,所以测试本例子前务必准备好一个SD卡并插上。
3. 文件系统是采用的RL-FlashFS,此文件系统的文件名仅支持ASCII字符,不支持中文,特别注意!
4. FTP服务器的访问方法在本实例配套教程里面有详细讲解。可以使用FTP客户端软件访问,也可以在“我的电脑”地址栏输入ftp://armfly进行访问。
5. FTP服务器的用户名admin,密码123456。
实验操作:
详见本章节36.5小节。
配置向导文件设置(Net_Config.c):
详见本章节36.3小节。
调试文件设置(Net_Debug.c):
详见本章节36.4小节。
RTX配置:
RTX配置向导详情如下:
Task Configuration
(1)Number of concurrent running tasks
允许创建6个任务,实际创建了如下5个任务:
AppTaskUserIF任务 :按键消息处理。
AppTaskLED任务 :LED闪烁。
AppTaskMsgPro任务 :按键检测。
AppTaskTCPMain任务:RL-TCPnet测试任务。
AppTaskStart任务 :启动任务,也是最高优先级任务,这里实现RL-TCPnet的时间基准更新。
(2)Number of tasks with user-provided stack
创建的5个任务都是采用自定义堆栈方式。
(3)Run in privileged mode
设置任务运行在非特权级模式。
RTX任务调试信息:
程序设计:
任务栈大小分配:
staticuint64_t AppTaskUserIFStk[1024/8]; /* 任务栈 */
staticuint64_t AppTaskLEDStk[1024/8]; /* 任务栈 */
staticuint64_t AppTaskMsgProStk[1024/8]; /* 任务栈 */
staticuint64_t AppTaskTCPMainStk[4096/8]; /* 任务栈 */
staticuint64_t AppTaskStartStk[1024/8]; /* 任务栈 */
将任务栈定义成uint64_t类型可以保证任务栈是8字节对齐的,8字节对齐的含义就是数组的首地址对8求余等于0。如果不做8字节对齐的话,部分C语言库函数、浮点运算和uint64_t类型数据运算会出问题。
系统栈大小分配:
RTX初始化:
- /*
- *********************************************************************************************************
- * 函 数 名: main
- * 功能说明: 标准c程序入口。
- * 形 参: 无
- * 返 回 值: 无
- *********************************************************************************************************
- */
- int main (void)
- {
- /* 初始化外设 */
- bsp_Init();
-
- /* 创建启动任务 */
- os_sys_init_user (AppTaskStart, /* 任务函数 */
- 5, /* 任务优先级 */
- &AppTaskStartStk, /* 任务栈 */
- sizeof(AppTaskStartStk)); /* 任务栈大小,单位字节数 */
- while(1);
- }
复制代码 硬件外设初始化
硬件外设的初始化是在 bsp.c 文件实现:
- /*
- *********************************************************************************************************
- * 函 数 名: bsp_Init
- * 功能说明: 初始化所有的硬件设备。该函数配置CPU寄存器和外设的寄存器并初始化一些全局变量。只需要调用一次
- * 形 参:无
- * 返 回 值: 无
- *********************************************************************************************************
- */
- void bsp_Init(void)
- {
- /*
- 由于ST固件库的启动文件已经执行了CPU系统时钟的初始化,所以不必再次重复配置系统时钟。
- 启动文件配置了CPU主时钟频率、内部Flash访问速度和可选的外部SRAM FSMC初始化。
-
- 系统时钟缺省配置为168MHz,如果需要更改,可以修改 system_stm32f4xx.c 文件
- */
- /* 优先级分组设置为4,可配置0-15级抢占式优先级,0级子优先级,即不存在子优先级。*/
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
-
- SystemCoreClockUpdate(); /* 根据PLL配置更新系统时钟频率变量 SystemCoreClock */
-
- bsp_InitDWT(); /* 初始化DWT */
- bsp_InitUart(); /* 初始化串口 */
- bsp_InitKey(); /* 初始化按键变量(必须在 bsp_InitTimer() 之前调用) */
-
- bsp_InitExtIO(); /* FMC总线上扩展了32位输出IO, 操作LED等外设必须初始化 */
- bsp_InitLed(); /* 初始LED指示灯端口 */
-
- MountSD(); /* 挂载SD卡 */
- }
复制代码 RTX任务创建:
- /*
- *********************************************************************************************************
- * 函 数 名: AppTaskCreate
- * 功能说明: 创建应用任务
- * 形 参: 无
- * 返 回 值: 无
- *********************************************************************************************************
- */
- static void AppTaskCreate (void)
- {
- HandleTaskUserIF = os_tsk_create_user(AppTaskUserIF, /* 任务函数 */
- 1, /* 任务优先级 */
- &AppTaskUserIFStk, /* 任务栈 */
- sizeof(AppTaskUserIFStk)); /* 任务栈大小,单位字节数 */
-
- HandleTaskLED = os_tsk_create_user(AppTaskLED, /* 任务函数 */
- 2, /* 任务优先级 */
- &AppTaskLEDStk, /* 任务栈 */
- sizeof(AppTaskLEDStk)); /* 任务栈大小,单位字节数 */
-
- HandleTaskMsgPro = os_tsk_create_user(AppTaskMsgPro, /* 任务函数 */
- 3, /* 任务优先级 */
- &AppTaskMsgProStk, /* 任务栈 */
- sizeof(AppTaskMsgProStk)); /* 任务栈大小,单位字节数 */
-
- HandleTaskTCPMain = os_tsk_create_user(AppTaskTCPMain, /* 任务函数 */
- 4, /* 任务优先级 */
- &AppTaskTCPMainStk, /* 任务栈 */
- sizeof(AppTaskTCPMainStk)); /* 任务栈大小,单位字节数 */
- }
复制代码 五个RTX任务的实现:
RL-TCPnet功能测试
这里专门创建了一个app_tcpnet_lib.c文件用于RL-TCPnet功能的测试,此文件主要实现网络主函数main_TcpNet的调用。
- #include "includes.h"
-
-
-
- /*
- *********************************************************************************************************
- * 函 数 名: TCPnetTest
- * 功能说明: TCPent测试函数。
- * 形 参: 无
- * 返 回 值: 无
- *********************************************************************************************************
- */
- void TCPnetTest(void)
- {
-
- while (1)
- {
- os_evt_wait_or(0x0001, 0xFFFF);
-
- /* RL-TCPnet主处理函数 */
- while (main_TcpNet() == __TRUE);
- }
- }
复制代码 FTP用户接口文件的实现
KEIL官网有提供FTP的接口文件,名为FTP_uif.c文件。我们就是在这个文件上修改。具体修改后的代码如下:
- #include <Net_Config.h>
- #include <File_Config.h>
- #include <stdio.h>
-
- /*----------------------------------------------------------------------------
- * FTP Server File Access Functions
- *---------------------------------------------------------------------------*/
-
- /*--------------------------- ftp_fopen -------------------------------------*/
-
- void *ftp_fopen (U8 *fname, U8 *mode) {
- /* Open file 'fname' for reading or writing. Return file handle. */
- return (fopen ((const char *)fname, (const char *)mode));
- }
-
-
- /*--------------------------- ftp_fclose ------------------------------------*/
-
- void ftp_fclose (void *file) {
- /* Close the file opened for reading or writing. */
- fclose (file);
- }
-
-
- /*--------------------------- ftp_fread -------------------------------------*/
-
- U16 ftp_fread (void *file, U8 *buf, U16 len) {
- /* Read 'len' bytes from file to buffer 'buf'. The file will be closed, */
- /* when the number of bytes read is less than 'len'. */
- return (fread (buf, 1, len, file));
- }
-
-
- /*--------------------------- ftp_fwrite ------------------------------------*/
-
- U16 ftp_fwrite (void *file, U8 *buf, U16 len) {
- /* Write 'len' bytes from buffer 'buf' to a file. */
- return (fwrite (buf, 1, len, file));
- }
-
-
- /*--------------------------- ftp_fdelete -----------------------------------*/
-
- BOOL ftp_fdelete (U8 *fname) {
- /* Delete a file, return __TRUE on success. */
- if (fdelete((char *)fname) == 0) {
- return (__TRUE);
- }
- return (__FALSE);
- }
-
-
- /*--------------------------- ftp_frename -----------------------------------*/
-
- BOOL ftp_frename (U8 *fname, U8 *newn) {
- /* Rename a file, return __TRUE on success. */
- if (frename((char *)fname, (char *)newn) == 0) {
- return (__TRUE);
- }
- return (__FALSE);
- }
-
-
- /*--------------------------- ftp_ffind -------------------------------------*/
-
- U16 ftp_ffind (U8 code, U8 *buf, U8 *mask, U16 buflen) {
- /* This function is called by the FTP server to find file names and other */
- /* file information. The output data is stored in ascii format to output */
- /* buffer 'buf' Parameter 'code' specifies requested file information. */
- /* Values for 'code': */
- /* 0 - read file size */
- /* 1 - read last-modified time of a file */
- /* 2 - list file names only (first call) */
- /* 3 - list file directory in extended format (first call) */
- /* 4 - list file names only (repeated call) */
- /* 5 - list file directory in extended format (repeated call) */
- static FINFO info;
- U32 rlen,v;
- U8 *tp;
-
- if (code < 4) {
- /* First call to ffind, initialize the info. */
- info.fileID = 0;
- }
-
- rlen = 0;
- next:
- if (ffind ((char *)mask, &info) == 0) {
- /* File found, print file information. */
- if (info.name[0] == '.') {
- if ((info.name[1] == 0) || (info.name[1] == '.' && info.name[2] == 0)) {
- /* Ignore the '.' and '..' folders. */
- goto next;
- }
- }
- switch (code) {
- case 0:
- /* Return file size as decimal number. */
- rlen = sprintf ((char *)buf,"%d\\r\\n", info.size);
- break;
-
- case 1:
- /* Return last-modified time in format "YYYYMMDDhhmmss". */
- rlen = sprintf ((char *)buf,"%04d%02d%02d",
- info.time.year, info.time.mon, info.time.day);
- rlen += sprintf ((char *)&buf[rlen],"%02d%02d%02d\\r\\n",
- info.time.hr, info.time.min, info.time.sec);
- break;
-
- case 2:
- case 4:
- /* List file names only. */
- rlen = sprintf ((char *)buf,"%s\\r\\n", info.name);
- break;
-
- case 3:
- case 5:
- /* List directory in extended format. */
- rlen = sprintf ((char *)buf,"%02d-%02d-%02d",
- info.time.mon, info.time.day, info.time.year%100);
- /* Convert time to "AM/PM" format. */
- v = info.time.hr % 12;
- if (v == 0) v = 12;
- if (info.time.hr < 12) tp = "AM";
- else tp = "PM";
- rlen += sprintf ((char *)&buf[rlen]," %02d:%02d%s",v,info.time.min,tp);
- if (info.attrib & ATTR_DIRECTORY) {
- rlen += sprintf ((char *)&buf[rlen],"%-21s"," <DIR>");
- }
- else {
- rlen += sprintf ((char *)&buf[rlen],"%21d", info.size);
- }
- rlen += sprintf ((char *)&buf[rlen]," %s\\r\\n", info.name);
- break;
- }
- }
- return (rlen);
- }
-
-
- /*--------------------------- ftp_accept_host -------------------------------*/
- #if 0
- BOOL ftp_accept_host (U8 *rem_ip, U16 rem_port) {
- /* This function checks if a connection from remote host is accepted or */
- /* not. If this function is missing, all remote hosts are accepted. */
-
- if (rem_ip[0] == 192 &&
- rem_ip[1] == 168 &&
- rem_ip[2] == 1 &&
- rem_ip[3] == 1) {
- /* Accept a connection. */
- return (__TRUE);
- }
- /* Deny a connection. */
- return (__FALSE);
- }
- #endif
-
-
- /*--------------------------- ftp_evt_notify --------------------------------*/
- #if 0
- void ftp_evt_notify (U8 evt) {
- /* This function notifies the user application about events in FTP server.*/
-
- switch (evt) {
- case FTP_EVT_LOGIN:
- /* User logged in, FTP session is busy. */
- break;
-
- case FTP_EVT_LOGOUT;
- /* User logged out, session is idle. */
- break;
-
- case FTP_EVT_LOGFAIL:
- /* User login failed (invalid credentials). */
- break;
-
- case FTP_EVT_DOWNLOAD:
- /* File download ended. */
- break;
-
- case FTP_EVT_UPLOAD:
- /* File upload ended. */
- break;
-
- case FTP_EVT_DELETE:
- /* File deleted. */
- break;
-
- case FTP_EVT_RENAME:
- /* File or directory renamed. */
- break;
-
- case FTP_EVT_MKDIR:
- /* Directory created. */
- break;
-
- case FTP_EVT_RMDIR:
- /* Directory removed. */
- break;
-
- case FTP_EVT_ERRLOCAL:
- /* Local file operation error. */
- break;
-
- case FTP_EVT_DENIED:
- /* Requested file operation denied. */
- break;
-
- case FTP_EVT_ERROR:
- /* Generic file operation or protocol error. */
- break;
- }
- }
- #endif
-
- /*----------------------------------------------------------------------------
- * end of file
- *---------------------------------------------------------------------------*/
复制代码 |
|