Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

\Micrium\Software\uC-TFTPc

...

Copy the file from the µC/TFTPc configuration folder into your application as illustrated below.


Panel
titleFigure - TFTPc Template File Copy

Image Added


Adding µC/TFTPc Example Application Code

...

Note that some sections of the source code have been removed or modified to help focus on the µC/TFTPc module use.


Code Block
languagecpp
titleListing - TFTPc Example Application Code
#define  TFTPc_TEST_SERVER_IP               "192.168.1.102"
#define  TFTPc_TEST_SERVER_PORT                         69 
            
#define  TFTPc_TEST_FILE_NAME_LOCAL          "\\file_local"
#define  TFTPc_TEST_FILE_NAME_REMOTE_GET  "file_remote_get"
#define  TFTPc_TEST_FILE_NAME_REMOTE_PUT  "test_remote_put"
            
static  void  App_TestTFTPc (void) 
{ 
    NET_IP_ADDR  ip_server; 
    NET_ERR      err_net; 
    TFTPc_ERR    err; 
            
            
    ip_server = NetASCII_Str_to_IP(TFTPc_TEST_SERVER_IP,                                     /* See Note #1. */
                                  &err_net); 
    if (err_net != NET_ASCII_ERR_NONE) { 
        printf("Error - NetASCII_Str_to_IP: %d\n\r", err_net);   
        return; 
    }
     
    TFTPc_Init(&TFTPc_Cfg, &err);                                                            /* See Note #2. */
    if (err != TFTPc_ERR_NONE) {
        printf("Error - TFTPc Initialization: %d\n\r", err);  
        return; 
    }
 
    (void)TFTPc_Get(DEF_NULL,                                                                /*See Note #3.

...

 */
                    TFTPc_TEST_FILE_NAME_LOCAL, 
                    TFTPc_TEST_FILE_NAME_REMOTE_GET, 
                    TFTPc_MODE_NETASCII,
                   &err); 
    if (err != TFTPc_ERR_NONE) { 
        printf("Error - TFTPc_Get: %d\n\r", err); 
    } 
             
    (void)TFTPc_Put(DEF_NULL,                                                                /*See Note #4. */
                    TFTPc_TEST_FILE_NAME_LOCAL, 
                    TFTPc_TEST_FILE_NAME_REMOTE_PUT, 
                    TFTPc_MODE_NETASCII,
                   &err);  
    if (err != TFTPc_ERR_NONE) { 
        printf("Error - TFTPc_Put: %d\n\r", err); 
    }
}


Panel
bgColor#f0f0f0
  1. Converts the ASCII dotted-decimal notation to a network protocol IPv4 address.
  2. Initializes the TFPTc suite.
  3. Initiates a “GET” request, that is a request for reading (RRQ) from the default server configuration.
  4. Initiates a “PUT” request, that is a request for writing (WRQ) to the default server configuration.