Network Component  
MDK Middleware for IPv4 and IPv6 Networking
 
Loading...
Searching...
No Matches
File System Interface

TFTP server functions that work with a File System. More...

Functions

void * netTFTPs_fopen (const char *fname, const char *mode)
 Open a file for reading or writing on the TFTP server. [interface].
 
void netTFTPs_fclose (void *file)
 Close a file previously open on the TFTP server. [interface].
 
uint32_t netTFTPs_fread (void *file, uint8_t *buf, uint32_t len)
 Read block of data from a file on the TFTP server. [interface].
 
uint32_t netTFTPs_fwrite (void *file, const uint8_t *buf, uint32_t len)
 Write block of data to a file on the TFTP server. [interface].
 

Description

TFTP server functions that work with a File System.

All functions of the File System Interface are located in TFTP_Server_FS.c, which is automatically added to the Network folder of your project. The file is preconfigured for the , so no changes are required. If you want to use a different type of file system, you must add a similar file to your project and implement the interface functions yourself.

The following functions are implemented in this module:

Function Documentation

◆ netTFTPs_fclose()

void netTFTPs_fclose ( void *  file)

Close a file previously open on the TFTP server. [interface].

Parameters
[in]filepointer to the file to close.

The function netTFTPs_fclose closes the file identified by the file stream pointer in the function argument.

The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the TFTP_Server_FS.c module.

◆ netTFTPs_fopen()

void * netTFTPs_fopen ( const char *  fname,
const char *  mode 
)

Open a file for reading or writing on the TFTP server. [interface].

Parameters
[in]fnamename of the file to open.
[in]modetype of access:
  • "rb" = opens a file for reading.
  • "wb" = opens a file for writing.
Returns
status information:
  • Pointer to an open file.
  • NULL in case of an error.

The function netTFTPs_fopen opens a file for reading or writing on the server.

The argument fname specifies the name of the file to open.

The argument mode defines the type of access permitted for the file. It can have one of the following values:

Mode Description
"rb" Opens the file for reading. If the file does not exist, then the function fails.
"wb" Opens an empty file for writing if the file does not exist. If the file exists already, then the content is cleared.

The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the TFTP_Server_FS.c module.

◆ netTFTPs_fread()

uint32_t netTFTPs_fread ( void *  file,
uint8_t *  buf,
uint32_t  len 
)

Read block of data from a file on the TFTP server. [interface].

Parameters
[in]filepointer to the file to read from.
[out]bufblock of memory to write data to.
[in]lenlength of data to read in bytes.
Returns
number of bytes successfully read.

The function netTFTPs_fread reads len bytes from the file identified by the file stream pointer in the function argument.

The argument buf is a pointer to the buffer where the function stores the read data.

The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the TFTP_Server_FS.c module.

Note
The function must read len bytes. The TFTP server stops reading and closes the file if the return value is less than len bytes.

◆ netTFTPs_fwrite()

uint32_t netTFTPs_fwrite ( void *  file,
const uint8_t *  buf,
uint32_t  len 
)

Write block of data to a file on the TFTP server. [interface].

Parameters
[in]filepointer to the file to write to.
[in]bufblock of memory to be written.
[in]lenlength of data to write in bytes.
Returns
number of bytes successfully written.

The function netTFTPs_fwrite writes a block of data to the file identified by the file stream pointer.

The argument buf points to the buffer containing the data that is to be written to the file.

The argument len specifies the number of bytes to write to the file.

The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the TFTP_Server_FS.c module.

Note
The TFTP server stops writing and closes the file if the return value is less than len bytes.