 
 |   | ||
|  | ||
|   | ||
The main() function of the application (see Listing 11.6) is called from start() . The start() function established the connection with the monitor through the monConnect() call and immediately executed the mon_getargv() API function to retrieve an argument list from the monitors space. This argument list can be built by the monitors argv command, or it is automatically loaded when a TFS-based executable is called from the monitor command line. Thus a main() function in an application running on the monitor basically looks like any other main() function.
|  | 
  #include "monlib.h"   main(int argc,char *argv[])   {   int     i;   char    *env;   for(i=0;i<argc;i++) {   mon_printf("argv[%d] = %s\n",i,argv[i]);   }   mon_printf("Hello embedded world!\n");   env = mon_getenv("ENV");   if (env) {   mon_printf(" The ENV variable is : %s\n",env);   }   mon_appexit(0);   }   |  | 
The three different mon_xxx calls in the example of Listing 11.6 demonstrate additional API functions available to the application when the monitor is present. Some key features are:
applications that are loaded from TFS can be passed different argument lists to invoke different actions depending on the need;
the application immediately has access to the monitors console interface through mon_printf();
shell variables created in monitor space are accessible by the application through the mon_getenv() API call;
the application can return control to the monitor by either returning to the caller of start() or by issuing the mon_appexit() API call.
|   | ||
|  | ||
|   | ||
 
  
  
  
  
  
 