我调用函数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; }
| 有奖活动 | |
|---|---|
| 2026年“我要开发板活动”第三季,开始了! | |
| 硬核工程师专属补给计划——填盲盒 | |
| “我踩过的那些坑”主题活动——第002期 | |
| 【EEPW电子工程师创研计划】技术变现通道已开启~ | |
| 发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
| 【EEPW在线】E起听工程师的声音! | |
| 高校联络员开始招募啦!有惊喜!! | |
| 【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
我要赚赏金打赏帖 |
|
|---|---|
| 【分享开发笔记,赚取电动螺丝刀】在音频测试中顺序的调整可改变功效被打赏¥18元 | |
| 【分享开发笔记,赚取电动螺丝刀】点阵显示模块及其应用-----献给新年的小礼物被打赏¥22元 | |
| 基于地奇星开发板的数码管模块显示技术被打赏¥23元 | |
| window下生成compilecommands.json的的方法被打赏¥22元 | |
| 【S32K3XX】GPIO中断配置被打赏¥26元 | |
| 【分享开发笔记,赚取电动螺丝刀】WS2812B的RGB灯介绍以及驱动方法被打赏¥25元 | |
| PTC与NTC功能常规对比被打赏¥14元 | |
| 【S32K3XX】核间通信MU使用被打赏¥27元 | |
| 【分享开发笔记,赚取电动螺丝刀】关于3pin锂电池接口的介绍/使用被打赏¥16元 | |
| 以启明云端ESP32P4开发板实现TF卡读写功能被打赏¥28元 | |