我调用函数ftpXfer()一切OK!
可是当我调用函数tftpXfer()时出错,我在代码中添加了头文件#include "tftpLib.h",然后调用tftpXfer(),编译时没有问题,而在download时却显示tftpXfer出错,这是为什么?
/*************************************************************** char* hostName: 主机ip地址 char* fileName:放于PC机上的配置文件名 fuctiojn:从某台PC机上下载配置文件到本网关 ****************************************************************/
STATUS DBGetConfig(char*hostName,char* fileName) { int fd,total = 0; int dataFd; int errorFd; int nBytes; char buf[BUFFERSIZE+1]; if(chdir("/tffs0/sys")) { printf("change dir error!\n"); return (ERROR); }
remove("config.txt"); fd = open("config.txt",0x202,0); if(fd == ERROR) { printf("Can not open the destination file\r\n"); return (ERROR); } if (tftpXfer (hostName, 0, fileName, "get", "binary", &dataFd, &errorFd) == ERROR) { printf("Can not establish link to host %s\r\n",hostName); return (ERROR); }
printf("hostName = %s,filename=%s,errFd=0x%x,fd=0x%x\n", hostName,fileName,&errorFd,&fd);
while((nBytes = read(dataFd,buf,512)) > 0) { total += nBytes; write(fd,buf,nBytes); } close(fd); close (dataFd); if( total >0 ) printf("File Transfered Successfully!\r\n "); else printf("File Transfered Failed!\r\n ");
close (errorFd); return OK; }
打赏帖 | |
---|---|
【功率监测与控制系统DIY活动成果贴】DIY功率计与LabVIEW数据采集被打赏100分 | |
【Freertos】任务管理被打赏10分 | |
分享博世的两种不同的喷射系统模式被打赏5分 | |
汽车+开路实验与短路实验被打赏10分 | |
多点式电子控制汽油喷射系统知识分享被打赏10分 | |
分享机械控制式汽油喷射系统被打赏5分 | |
汽车显示屏——第2部分:TFTLCD、OLED和micro-LED显示屏电源技术被打赏50分 | |
汽车+汽车电路板的走线规则被打赏20分 | |
五一劳动节快乐被打赏5分 | |
【分享开发笔记,赚取电动螺丝刀】s32k146适配zephyr(六)使用Ozone调试镜像被打赏29分 |