我调用函数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; }
我要赚赏金打赏帖 |
|
|---|---|
| 【FreeRtos】FreeRtos + MPU模块的配置使用被打赏¥32元 | |
| 【分享开发笔记,赚取电动螺丝刀】墨水屏文本显示器被打赏¥25元 | |
| 【STEVAL-STWINKT1B】:结合STMcubeMX软件读取HTS221温湿度被打赏¥22元 | |
| M5PAPERESP32EINKDEVKIT评测|使用MicroPython开发M5Paper被打赏¥15元 | |
| OK1126B-S开发板下以导航按键控制云台/机械臂姿态调整被打赏¥29元 | |
| 【树莓派5】便携热成像仪被打赏¥36元 | |
| 【树莓派5】环境监测仪被打赏¥35元 | |
| OK1126B-S开发板下多时段语音提示型电子时钟被打赏¥27元 | |
| OK1126B-S开发板下函数构建及步进电机驱动控制被打赏¥25元 | |
| 【S32K3XX】LPI2C 参数配置说明被打赏¥20元 | |