【问题标题】:tftpGet error from tftpLib in VxWorkstftpGet error from tftpLib in VxWorks
【发布时间】:2013-12-05 18:06:32
【问题描述】:

我正在编写一个小函数,它使用VxWorktftpLib (http://www.vxdev.com/docs/vx55man/vxworks/ref/tftpLib.html) 从 TFTP 服务器下载文件 - 现在我意识到我的 tftpGet() 命令返回错误 1 但是我不确定错误代码 1 是什么意思。在发布的网站上它说:

ERRNO
S_tftpLib_INVALID_DESCRIPTOR
S_tftpLib_INVALID_ARGUMENT
S_tftpLib_NOT_CONNECTED

但是我怎么知道1 对应的是什么? 我的代码的 get 部分如下所示:

/* Initialize and createlocal file handle */
pFile = fopen("ngfm.bin","wb");
if (pFile != NULL)
    {
    /* Get file from TFTP server and write it to the file descriptor */
    status = tftpGet (pTftpDesc, pFilename, pFile, TFTP_CLIENT);
    printf("GOT %s\n",pFilename);
    }
else
    {
    printf("Error in tftpGet()\nfailed to get %s from %s\nERRNO %d",pFilename,pHost, status);
    }

【问题讨论】:

    标签: vxworks error-code tftp


    【解决方案1】:

    试试这个代码:

    int status;
    if (OK == (status = tftpGet (pTftpDesc, pFilename, fd, TFTP_CLIENT))) {
     printf("tftpGet() successful\n");
    } else {
     printf("Error has occurred: %d\n", errno); // errno is where the error is stored
    }
    

    【讨论】:

      【解决方案2】:

      不,事实上的问题是,我没有得到一个有效的文件指针,而是 NULL,因为在 VxWorks 中没有像 Linux 中那样的“当前目录”这样的东西,但我不得不改变我的 fopen 说些什么改为pFile = fopen("flash:/ngfm.bin","wb");

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-07-24
        • 2013-06-26
        • 2022-11-04
        • 2020-03-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多