tfTftpGet
Table of Contents >> Application Reference >> TFTP Client API
#include <trsocket.h> |
ttUser32Bit tfTftpGet | ( |
char * filename, | |
struct sockaddr * remoteAddrPtr, | |
char * tftpbuf, | |
ttUser32Bit bufsize, | |
unsigned short mode, | |
int blocking | |
); |
Function Description
This function retrieves a file from a TFTP server.
Blocking Mode
In blocking mode, tfTftpGet() should be called from a task. tfTftpGet() will block until the file transfer is completed or an error is returned. The TFTP client code is executed in the context of the calling task. Choose blocking mode if you are using an RTOS/Kernel.
Non-Blocking Mode
In non-blocking mode, tfTftpGet() will return immediately. It is the user's responsibility to then call tfTftpUserExecute() periodically to execute the TFTP server code. Choose non-blocking mode if you do not have an RTOS/Kernel.
Parameters
- filename
- A null-terminated string containing the file name to retreive from the server.
- remoteAddrPtr
- A pointer to the structure representing the address of the server. The type (AF_INET), address, and port (for TFTP usually 69) must be filled in.
- tftpbuf
- A pointer to the buffer to store the file into.
- bufsize
- The size, in bytes, of the buffer.
- mode
- TM_TYPE_ASCII for ASCII transfers or TM_TYPE_BINARY for binary transfers.
- blocking
- One of the following:
- TM_BLOCKING_ON for blocking mode.
- TM_BLOCKING_OFF for non-blocking mode.
Returns
- TM_ENOERROR
- Non Blocking Mode only: Command accepted with no error. Call tfTftpUserExecute() periodically
- >= 0
- Blocking Mode only: Size of the file received.
- TM_TFTP_EXECUT
- A session is already in progress. Only one session may be in progress at a time.
- TM_TFTP_EINVAL
- One of the following:
- 'mode' is neither TM_TYPE_ASCII nor TM_TYPE_BINARY.
- 'blocking' is neither TM_BLOCKING_ON nor TM_BLOCKING_OFF.
- 'blocking' is TM_BLOCKING_ON and blocking-mode is not enabled for the stack.
- TM_TFTP_ESOCK
- An error occurred with one or more of the socket calls within the function.
- TM_TFTP_EBUF
- The buffer is not large enough to hold the received file.
- TM_TFTP_UNDEF
- The TFTP server returned an "Undefined error code" message in the error packet.
- TM_TFTP_NOTFOUND
- The TFTP server returned a "File not found" message in the error packet.
- TM_TFTP_NOUSER
- The TFTP server returned a "No such user" message in the error packet.
- TM_TFTP_BADOP
- The TFTP server returned an "Illegal TFTP operation" message in the error packet.
- TM_TFTP_BADID
- The TFTP server returned an "Unknown transfer ID" message in the error packet.
- TM_TFTP_ACCESS
- The TFTP server returned an "Access violation" message in the error packet.
- TM_TFTP_NOSPACE
- The TFTP server returned a "Disk full/alloc exceeded" message in the error packet.
- TM_TFTP_FILEEXISTS
- The TFTP server returned a "File already exists" message in the error packet.
Table of Contents >> Application Reference >> TFTP Client API