我调用函数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; }
有奖活动 | |
---|---|
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【我踩过的那些坑】电感选型错误导致的处理器连接不上被打赏50分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 | |
【我踩过的那些坑】DRC使用位置错误导致的问题被打赏100分 | |
我踩过的那些坑之混合OTL功放与落地音箱被打赏50分 | |
汽车电子中巡航控制系统的使用被打赏10分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏100分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 | |
分享电子控制安全气囊计算机知识点被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【OZONE】使用方法总结被打赏20分 |