tftpGet error from tftpLib in VxWorks

493 views Asked by At

I'm writing a little function that downloads a file from a TFTP server using VxWork's tftpLib (http://www.vxdev.com/docs/vx55man/vxworks/ref/tftpLib.html) - now I realized that my tftpGet() command is returning an error 1 but I'm not sure what errorcode 1 means. On the posted website it says:

ERRNO
S_tftpLib_INVALID_DESCRIPTOR
S_tftpLib_INVALID_ARGUMENT
S_tftpLib_NOT_CONNECTED

But how do I know what 1 corresponds with? The get portion of my code looks like this:

/* 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);
    }
2

There are 2 answers

0
stdcerr On BEST ANSWER

No,The problem in fact was, that I didn';t get a valid file pointer but NULL because there's no such thing as a "current directory" like in Linux in VxWorks but I had to change my fopen to say something like pFile = fopen("flash:/ngfm.bin","wb"); instead.

0
Noam Rathaus On

Try this code:

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
}