コード例 #1
0
/******************************************************************************
*   @name        Shell_decrease_volume
*
*   @brief       Servers the decrease volume command
*
*   @param       None
*
*   @return      None
*
******************************************************************************
* This function is used to decrease volume of the audio device
*****************************************************************************/
int32_t Shell_decrease_volume(int32_t argc,char *argv[])
{
    bool         print_usage = TRUE, shorthelp = FALSE;
    print_usage = Shell_check_help_request (argc, argv, &shorthelp);
    if (!print_usage)
    {
        if (argc > 1)
        {
            printf ("  Error: Channel parameter is too large\n");
            return (SHELL_EXIT_ERROR);
        }
        else
        {
            audio_decrease_volume_command();
        }
    }
    else
    {
        if (shorthelp)
        {
            printf("%s\n", argv[0]);
        }
        else
        {
            printf("Usage: %s\n", argv[0]);
        }
    }

    return(SHELL_EXIT_SUCCESS);
}
コード例 #2
0
ファイル: sh_exit.c プロジェクト: Wangwenxue/FutureMove-T-box
int32_t  Shell_exit(int32_t argc, char *argv[] )
{
   bool              print_usage, shorthelp = FALSE;
   int32_t               return_code = SHELL_EXIT_SUCCESS;
   SHELL_CONTEXT_PTR    shell_ptr = Shell_get_context( argv ); 

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      shell_ptr = Shell_get_context( argv );
      shell_ptr->EXIT = TRUE;
      if (shell_ptr->COMMAND_FP != stdin)  {
         fclose(shell_ptr->COMMAND_FP);
      }   
   }

   if (print_usage)  {
      if (shorthelp)  {
         printf("%s\n", argv[0]);
      } else  {
         printf("Usage: %s\n", argv[0]);
      }
   }
   return return_code;
} /* Endbody */
コード例 #3
0
ファイル: hmi.c プロジェクト: jewlenchow/MQX_3.8.1
int_32 Shell_get_module(int_32 argc, char_ptr argv[] )
{
    boolean     print_usage, shorthelp = FALSE;
    int_32      return_code = SHELL_EXIT_SUCCESS;

    print_usage = Shell_check_help_request(argc, argv, &shorthelp );

    if (!print_usage)
    {
        if (argc > 2)
        {
            printf("Error, invalid number of parameters\n");
            return_code = SHELL_EXIT_ERROR;
            print_usage = TRUE;
        }
        else
        {
            if (argc == 1)
            {
                printf("Module %d active.\n", _bsp_btnled_get_twrpi());
            }
        }
    }
    if (print_usage)
    {
            printf("Usage: %s \n", argv[0]); /* show in help command */
    }
    return return_code;
}
コード例 #4
0
/******************************************************************************
*   @name        Shell_mute
*
*   @brief       Servers the mute command
*
*   @param       None
*
*   @return      None
*
******************************************************************************
* This function is used to mute the audio device
*****************************************************************************/
int32_t Shell_mute(int32_t argc, char *argv[])
{
    bool         print_usage, shorthelp = FALSE;
    print_usage = Shell_check_help_request (argc, argv, &shorthelp);

    if (!print_usage)
    {
        if (argc > 1)
        {
            printf("  Error: This command doesn't need parameters\n");
            return (SHELL_EXIT_ERROR);
        }
        else
        {
            audio_mute_command();
        }
    }

    if (print_usage)
    {
        if (shorthelp)
        {
            printf("%s\n", argv[0]);
        }
        else
        {
            printf("Usage: %s\n", argv[0]);
        }
    }
    return(SHELL_EXIT_SUCCESS);
}
コード例 #5
0
ファイル: boot_cmd.c プロジェクト: mihaSoro/MQX-3.7.0
int_32  Shell_bootloader_go_image(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean             print_usage, shorthelp = FALSE;
   int_32              return_code = SHELL_EXIT_SUCCESS;
   
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );
   
  
   if (!print_usage)  {
   
      _autoboot_cmd = AUTOBOOT_DISABLE;
      _image_index = _io_atoi(argv[1]);
      if(_bootloader_check_image(FALSE,_image_index)) {
         printf("\nStarting application at image:%d\n",_image_index);
         _mqx_exit(0);
      }
      else {
         printf("\nError no image found !\n");
      }
      
   }
   
 if (print_usage)  {
      if (shorthelp)  {
         printf("%s [<index>] \n", argv[0]);
      } else  {
         printf("Usage: %s [<index>] \n", argv[0]);
         printf("   <index> = image index in memory table \n");
         
      }
 }
}
コード例 #6
0
ファイル: sh_clock.c プロジェクト: gxliu/MQX_3.8.0
int_32  Shell_Clock_server_start(int_32 argc, char_ptr argv[] )
{
   uint_32  result;
   boolean              print_usage, shorthelp = FALSE;
   int_32               return_code = SHELL_EXIT_SUCCESS;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc == 1)  {
         result =RTCS_task_create("Clock_server", SHELL_CLOCK_SERVER_PRIO, 
            SHELL_CLOCK_SERVER_STACK, Clock_server_task, NULL);
         if (result ==  0)  {
            printf("Clock Server Started.\n");
         } else  {
            printf("Unable to start Clock Server, error = 0x%x\n",result);
            return_code = SHELL_EXIT_ERROR;
         }
      } else  {
         printf("Error, %s invoked with incorrect number of arguments\n", argv[0]);
         print_usage = TRUE;
      }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s \n", argv[0]);
      } else  {
         printf("Usage: %s\n",argv[0]);
      }
   }
   return return_code;
} /* Endbody */
コード例 #7
0
ファイル: sh_audio.c プロジェクト: BillyZhangZ/wifi
/******************************************************************************
*   @name        Shell_decrease_volume
*
*   @brief       Servers the decrease volume command
*
*   @param       None
*
*   @return      None
*
******************************************************************************
* This function is used to decrease volume of the audio device
*****************************************************************************/
int_32 Shell_decrease_volume(int_32 argc,char_ptr argv[])
{
    boolean         print_usage = TRUE, shorthelp = FALSE;
    volatile static uint_16         cur_volume, min_volume; 
    print_usage = Shell_check_help_request (argc, argv, &shorthelp);
    if (!print_usage)
    {
        if (argc > 1)
        {   
            printf ("  Error: Channel parameter is too large\n");
            return (SHELL_EXIT_ERROR);
        }  
        else
        {
            audio_decrease_volume_command();
        }
    }
    else
    {
        if (shorthelp)
        {
            printf("%s\n", argv[0]);
        }
        else
        {
            printf("Usage: %s\n", argv[0]);
        }
    }

    return(SHELL_EXIT_SUCCESS);
}
コード例 #8
0
ファイル: sh_ftpc.c プロジェクト: zhouglu/K60F120M
int_32  Shell_FTP_client(int_32 inargc, char_ptr inargv[] )
{
   boolean              print_usage, shorthelp = FALSE;
   int_32               return_code = SHELL_EXIT_SUCCESS;
   

   print_usage = Shell_check_help_request(inargc, inargv, &shorthelp );

   if (!print_usage)  {

      if (inargc > 2)  {
         printf("Error, %s invoked with incorrect number of arguments\n", inargv[0]);
         print_usage = TRUE;
      } else  {
         FTP_client(inargv[1] );
      } 
   } 

   if (print_usage)  {
      if (shorthelp)  {
         printf("%s [<host>]\n", inargv[0]);
      } else  {
         printf("Usage: %s [<host>]\n", inargv[0]);
         printf("   <host>   = host ip address or name\n");
      }
   }
   return return_code;
} /* Endbody */
コード例 #9
0
ファイル: sh_cmdlist.c プロジェクト: mihaSoro/MQX-3.7.0
int_32  Shell_command_list(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean              print_usage, shorthelp = FALSE;
   int_32               return_code = SHELL_EXIT_SUCCESS;
   SHELL_CONTEXT_PTR    shell_ptr = Shell_get_context( argv ); 
   SHELL_COMMAND_PTR    command_ptr;
   uint_32              i; 

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc==1)  {
         for (i=0,command_ptr = shell_ptr->COMMAND_LIST_PTR; 
              command_ptr->COMMAND != NULL; 
              i++,command_ptr++)  
          {
            printf("%-8s ", command_ptr->COMMAND);
            if ((i&7)==7) printf("\n");
         } /* Endwhile */
         if ((i&7)!=0) printf("\n");        
      } else {  
         print_usage = TRUE;
      }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s\n", argv[0]);
      } else  {
         printf("Usage: %s\n", argv[0]);
      }
   }
   return return_code;
} /* Endbody */
コード例 #10
0
/*
 *  Turn off LED1 or LED2. 
 */
int_32  Shell_ledoff(int_32 argc, char_ptr argv[] )
{
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  
   {
      if (argc !=2 ) 
      {
         printf("Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
      } 
      else 
      {
        /* Read in command line argument to determine LED to turn on */
        if(argv[1][0]=='1' && argv[1][1]=='\0')
          SEC_SetOutput(SEC_LED1_OUTPUT, 0);
        else if(argv[1][0]=='2' && argv[1][1]=='\0')
          SEC_SetOutput(SEC_LED2_OUTPUT, 0);
        else if(argv[1][0]=='3' && argv[1][1]=='\0')
          SEC_SetOutput(SEC_LED3_OUTPUT, 0);
        else
          printf("Invalid Argument. Must be '1', '2' or '3'\n");
      }
   }
   
   if (print_usage)  {
      print_usage_led (shorthelp, argv[0], "<LED number> = Turn off LED1, LED2 or LED3");
   }
   return return_code;
}
コード例 #11
0
/*
 *  Print out current value of push buttons, if board is moving or tiled, 
 *  the value of the potentiometer, and the elapsed time since bootup
 */
int_32  Shell_status(int_32 argc, char_ptr argv[] )
{
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;
   int pot;
        
    TIME_STRUCT time;
    DATE_STRUCT date;
    
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  
   {
      if (argc > 1) 
      {
         printf("Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
      } 
      else 
      {
        /* Print out 'Door' status */
        printf("Door (SW2):                      ");
        if(SEC_GetDoorStatus()==OPENED)
            printf("Open\n");
        else
            printf("Closed\n");
      
        /* Print out 'Window' status */ 
            printf("Window (SW3):                    ");
        if(SEC_GetWindowStatus()==OPENED)
            printf("Open\n");
        else
            printf("Closed\n");
        
        /* Print out movement/tilt status */
            printf("Motion Detection:                ");
        if(SEC_GetMovementStatus()==MOVING)
            printf("Movement\n");
        else
            printf("No Movement\n");
        
        /* Print out potentiometer percentage in 10% increments */
        pot = (SEC_Params.GarageStatus / 409) * 10;
        printf("Garage Door (Potentiometer R2):  %d%% Open\n",pot);

        /* Print out elapsed time since bootup */
            _time_get(&time);
            _time_to_date(&time,&date);   
            printf("Time Since Bootup:               %02d:%02d:%02d\n\n",date.HOUR,date.MINUTE,date.SECOND);    
        
      }
   }
   
   if (print_usage)  
   {
      print_usage_simple (shorthelp, argv[0], "Display security system status");
   }
   return return_code;
} 
コード例 #12
0
ファイル: sh_arpdisp.c プロジェクト: gxliu/MQX_3.8.0
int_32 Shell_arpdel(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;
   _ip_address       ipaddr;
   _rtcs_if_handle   ihandle = ipcfg_get_ihandle (BSP_DEFAULT_ENET_DEVICE);
  
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc != 2)  {
         return_code = SHELL_EXIT_ERROR;
         print_usage = TRUE;
      } else  if (! Shell_parse_ip_address( argv[1], &ipaddr))  {
          printf("Error, invalid ip address\n");
          return_code = SHELL_EXIT_ERROR;
      }
      if (return_code == SHELL_EXIT_SUCCESS) {
          RTCS_arp_delete(ihandle,ipaddr);
      }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s <ip_address>\n", argv[0]);
      } else  {
         printf("Usage: %s <ip_address> \n", argv[0]);
         printf("   <ip_address>  = IP Address\n");
      }
   }

   return return_code;
} /* Endbody */
コード例 #13
0
ファイル: boot_cmd.c プロジェクト: mihaSoro/MQX-3.7.0
int_32  Shell_bootloader_list_image(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean             print_usage, shorthelp = FALSE;
   int_32              return_code = SHELL_EXIT_SUCCESS;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );


   if (!print_usage)  {
      
     if (argc != 1) {
         printf("Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
     }
      else { 
         _bootloader_list_image();
      }
   }

   if (print_usage)  {
      if (shorthelp)  {
         printf("%s\n", argv[0]);
      } else  {
         printf("Usage: %s ", argv[0]);
         printf("   <%s> to list image table\n",argv[0]);
      }
   }

} /* Endbody */
コード例 #14
0
ファイル: sh_arpdisp.c プロジェクト: gxliu/MQX_3.8.0
int_32 Shell_arpdisp(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;
   _rtcs_if_handle   ihandle = ipcfg_get_ihandle (BSP_DEFAULT_ENET_DEVICE);
  
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

    if (!print_usage)  {
      if (argc > 2)  {
         return_code = SHELL_EXIT_ERROR;
         print_usage = TRUE;
      } else  { 
        ARP_display_if_table(ihandle);
      }
    }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s [<ihandle>]\n", argv[0]);
      } else  {
         printf("Usage: %s [<ihandle>] \n", argv[0]);
         printf("   <ihandle>  = Interface handle\n");
      }
   }

   return return_code;
} /* Endbody */
コード例 #15
0
ファイル: boot_cmd.c プロジェクト: mihaSoro/MQX-3.7.0
int_32  Shell_bootloader_del_image(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean             print_usage, shorthelp = FALSE;
   int_32              return_code = SHELL_EXIT_SUCCESS;
   uint_32             index, block, result;
   
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );
   
  
   if (!print_usage)  {
   
     if ((argc < 2) || (argc >= 3)) {     
      printf("Error, invalid number of parameters\n");
      return_code = SHELL_EXIT_ERROR;
      print_usage=TRUE;
     }
     else 
     {
      index = _io_atoi(argv[1]);
      _bootloader_del_image(index);
   }
   
   }
 if (print_usage)  {
      if (shorthelp)  {
         printf("%s <index> \n", argv[0]);
      } else  {
         printf("Usage: %s <index> \n", argv[0]);
         printf("  <index> = index of image to delete\n");
         
      }
 }
}
コード例 #16
0
ファイル: sh_getroute.c プロジェクト: mihaSoro/MQX-3.7.0
int_32 Shell_walkroute(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc >1)  {
         return_code = SHELL_EXIT_ERROR;
         print_usage = TRUE;
      }          
         
         
      if (return_code == SHELL_EXIT_SUCCESS)  {
         RTCS_walk_route();
      } 
   }

   if (print_usage)  {
      if (shorthelp)  {
         printf("%s\n", argv[0]);
      } else  {
         printf("Usage: %s\n", argv[0]);
      }
   }

   return return_code;
} /* Endbody */
コード例 #17
0
int32_t  Shell_format(int32_t argc, char *argv[] )
{ /* Body */
   bool                    print_usage, shorthelp = FALSE;
   int32_t                     return_code = SHELL_EXIT_SUCCESS;
   int32_t                     error_code = IO_ERROR;
   MQX_FILE_PTR               fs_ptr = NULL;
   char                   *volume_ptr[SFILENAME_SIZE];
   uint64_t                    big_number;
   uint32_t                    small_number;
   
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc < 2 || argc >  3) {
         printf("Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
      } else  {
         if (argc == 3)  {
            memcpy (volume_ptr, argv[2], SFILENAME_SIZE);
         } else  {
            volume_ptr[0] = 0;
         }
         fs_ptr = _io_get_fs_by_name(argv[1]);
         if (fs_ptr == NULL)  {
            printf("Error, file system %s not found\n", argv[1] );
            return_code = SHELL_EXIT_ERROR;
         } else {
            printf("\nFormatting...\n");
            error_code = ioctl(fs_ptr, IO_IOCTL_DEFAULT_FORMAT,  NULL);
            if ( !error_code && (*volume_ptr)) {
               error_code = ioctl(fs_ptr, IO_IOCTL_SET_VOLUME,  (void *) volume_ptr);
            }       
            if (error_code) {
               printf("Error while formatting: 0x%x\n", error_code);
            } else  {
               /* print disk information */
               error_code = ioctl(fs_ptr, IO_IOCTL_GET_VOLUME, (uint32_t*)volume_ptr);
               printf("Done. Volume name is %s\n", volume_ptr);
               ioctl(fs_ptr, IO_IOCTL_FREE_SPACE, &big_number);
               for (small_number = 0; big_number > 128 * 1024; big_number >>= 10) small_number++;
               printf("Free disk space: %lu %s\n", (uint32_t)big_number, BYTE_SIZES[small_number]);
            } 
         }
      }
   }
      
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s <drive:> [<volume label>]\n", argv[0]);
      } else  {
         printf("Usage: %s <drive:> [<volume label>]\n", argv[0]);
         printf("   <drive:> = specifies the drive name (followed by a colon)\n");
         printf("   <volume label>  = specifies the volume label\n");
      }
   }
   return return_code;
}
コード例 #18
0
ファイル: sh_help.c プロジェクト: gxliu/MQX_3.8.0
int_32  Shell_help(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean              print_usage, shorthelp = FALSE;
   int_32               return_code = SHELL_EXIT_SUCCESS;
   SHELL_CONTEXT_PTR    shell_ptr = Shell_get_context( argv );
   SHELL_COMMAND_PTR    command_ptr; 

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc==1)  {
         shell_ptr->ARGV[1] = "help";
         shell_ptr->ARGV[2] = "short"; 
         shell_ptr->ARGV[3] = NULL; 
         printf("Available commands:\n");
         command_ptr = shell_ptr->COMMAND_LIST_PTR; 
         while (command_ptr->COMMAND != NULL)  {
            shell_ptr->ARGV[0] = command_ptr->COMMAND;
            printf("   ");
            return_code = (*command_ptr->SHELL_FUNC)(3, shell_ptr->ARGV);
            command_ptr++;        
         } /* Endwhile */        
      } else {
         /* Help on a specific command */
         if (argc==2)  {
            shell_ptr->ARGV[0] = argv[1];
            shell_ptr->ARGV[1] = "help";
            shell_ptr->ARGV[2] = "usage"; 
            shell_ptr->ARGV[3] = NULL; 
            command_ptr = shell_ptr->COMMAND_LIST_PTR; 
            while (command_ptr->COMMAND != NULL)  {
               if (strcmp(argv[0], command_ptr->COMMAND) == 0)  {
                  return_code = (*command_ptr->SHELL_FUNC)(3, shell_ptr->ARGV);
                  break;   
               } 
               command_ptr++;        
            } /* Endwhile */
            if (command_ptr->COMMAND == NULL)  {
               printf("Error, command \"%s\" not registered.\n", argv[1] );
            }
         } else {
            print_usage = TRUE;
         }    
      }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s [<command>]\n", argv[0]);
      } else  {
         printf("Usage: %s [<command>]\n", argv[0]);
         printf("   <command> = command to get help on\n");
      }
   }
   return return_code;
} /* Endbody */
コード例 #19
0
ファイル: sh_snmpd.c プロジェクト: gxliu/MQX_3.8.0
int_32  Shell_SNMPd(int_32 argc, char_ptr argv[] )
{
   uint_32  result;
   boolean  print_usage, shorthelp = FALSE;
   int_32   return_code = SHELL_EXIT_SUCCESS;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc == 2)  {
         if (strcmp(argv[1], "start") == 0)  {
         
            result = SNMP_init("SNMP_agent", SHELL_SNMP_PRIO, SHELL_SNMP_STACK );
            if (result ==  0)  {
               printf("SNMP Agent Started.\n");
               
               /* Install some MIBs for the SNMP agent */
               MIB1213_init();
               MIBMQX_init();
            } else  {
               printf("Unable to start SNMP Agent, error = 0x%x\n",result);
               return_code = SHELL_EXIT_ERROR;
            }
         } else if (strcmp(argv[1], "stop") == 0)  {
            result = SNMP_stop();
            if (result ==  0)  {
               printf("SNMP Agent Stopped.\n");
            } else  {
               printf("Unable to stop SNMP Agent, error = 0x%x\n",result);
               return_code = SHELL_EXIT_ERROR;
            }
         } else  {
         printf("Error, %s invoked with incorrect option\n", argv[0]);
            print_usage = TRUE;
         }
      } else  {
         printf("Error, %s invoked with incorrect number of arguments\n", argv[0]);
         print_usage = TRUE;
      }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s [start|stop]\n", argv[0]);
      } else  {
         printf("Usage: %s [start|stop]\n",argv[0]);
      }
   }
   return return_code;
} /* Endbody */
コード例 #20
0
ファイル: sh_ftpd.c プロジェクト: gxliu/MQX_3.8.0
int_32  Shell_FTPd(int_32 argc, char_ptr argv[] )
{
   uint_32  result;
   boolean              print_usage, shorthelp = FALSE;
   int_32               return_code = SHELL_EXIT_SUCCESS;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc == 2)  {
         if (strcmp(argv[1], "start") == 0)  {
         
            result = FTPd_init("FTP_server", SHELL_FTPD_PRIO, SHELL_FTPD_STACK );
//            result = FTPSRV_init("FTPserver", SHELL_FTPD_PRIO, SHELL_FTPD_STACK );
            if (result ==  0)  {
               printf("FTP Server Started.\n");
            } else  {
               printf("Unable to start FTP Server, error = 0x%x\n",result);
               return_code = SHELL_EXIT_ERROR;
            }
         } else if (strcmp(argv[1], "stop") == 0)  {
//            result = FTPSRV_stop();
            result = FTPd_stop();
            if (result ==  0)  {
               printf("FTP Server Stopped.\n");
            } else  {
               printf("Unable to stop FTP Server, error = 0x%x\n",result);
               return_code = SHELL_EXIT_ERROR;
            }
         } else  {
         printf("Error, %s invoked with incorrect option\n", argv[0]);
            print_usage = TRUE;
         }
      } else  {
         printf("Error, %s invoked with incorrect number of arguments\n", argv[0]);
         print_usage = TRUE;
      }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s [start|stop]\n", argv[0]);
      } else  {
         printf("Usage: %s [start|stop]\n",argv[0]);
      }
   }
   return return_code;
} /* Endbody */
コード例 #21
0
ファイル: sh_getroute.c プロジェクト: mihaSoro/MQX-3.7.0
int_32 Shell_getroute(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;

   _ip_address       gate_ipaddr;
   _ip_address       ipaddr;
   _ip_address       ipmask;
  
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc != 2)  {
         return_code = SHELL_EXIT_ERROR;
         print_usage = TRUE;
      } else  {
         if (! Shell_parse_ip_address( argv[1], &ipaddr  ))  {
            printf("Error, invalid ip address\n");
            return_code = SHELL_EXIT_ERROR;
         } else if (argc > 2)  {
            if (! Shell_parse_ip_address( argv[2], &ipmask  ))  {
               printf("Error, invalid ip mask\n");
               return_code = SHELL_EXIT_ERROR;
            }
         }          
      }          
         
         
      if (return_code == SHELL_EXIT_SUCCESS)  {
         gate_ipaddr = RTCS_get_route(ipaddr, ipmask);
         printf("The route to ip address: %d.%d.%d.%d, netmask: %d.%d.%d.%d is gateway %d.%d.%d.%d\n",
            IPBYTES(ipaddr),IPBYTES(ipmask),IPBYTES(gate_ipaddr));
      } 
   }

   if (print_usage)  {
      if (shorthelp)  {
         printf("%s <ipaddr> <netmask>\n", argv[0]);
      } else  {
         printf("Usage: %s <ipaddr> <netmask>\n", argv[0]);
         printf("   <ipaddr>  = IP address \n");
         printf("   <netmask> = Network mask\n");
      }
   }

   return return_code;
} /* Endbody */
コード例 #22
0
/*
 *  Display the last MAX_QUEUE events that occured with a timestamp
 *  Button pushes and movement changes logged. Potentiometer changes are not logged.
 */
int_32  Shell_displaylog(int_32 argc, char_ptr argv[] )
{
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;
        
    TIME_STRUCT time;
    DATE_STRUCT date;
    SEC_HIST_PTR hist;
    int i;

    
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  
   {
      if (argc > 1) 
      {
         printf("Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
      } 
      else 
      {

            _time_get_elapsed(&time);
            _time_to_date(&time,&date);   
            printf("Time Since Bootup: %02d:%02d:%02d\n",date.HOUR,date.MINUTE,date.SECOND);    
        
            /* Print out last MAX_QUEUE events */
            for(i = (MAX_QUEUE - 1);i >= 0;i--)
            {
           hist = &(SEC_Params.History[(i+SEC_Params.HistoryIndex)%MAX_QUEUE]);
               if(NULL != hist->eventptr) {
              _time_to_date(&hist->time,&date);
              printf("%02d:%02d:%02d %s\n", date.HOUR,date.MINUTE,date.SECOND,hist->eventptr);
               }
            }       
        
      }
   }
   
   if (print_usage)  
   {
      print_usage_simple (shorthelp, argv[0], "Display event log");
   }
   return return_code;
} 
コード例 #23
0
ファイル: sh_flush.c プロジェクト: kylemanna/kinetis-sdk1
int32_t  Shell_flush_cache(int32_t argc, char *argv[] )
{ /* Body */
   bool                    print_usage, shorthelp = FALSE;
   int32_t                     return_code = SHELL_EXIT_SUCCESS;
   int fd;
   char                   *name_ptr = NULL;
   SHELL_CONTEXT_PTR shell_ptr = Shell_get_context(argv);


   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc > 2) {
         fprintf(shell_ptr->STDOUT, "Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
      } else {
         if (argc==2) {
            name_ptr = argv[1];
         } else {
            name_ptr = Shell_get_current_filesystem_name(argv);
         }

         if (_nio_supp_validate_device(name_ptr)) {
            fd = open(name_ptr, O_RDWR);
            if (0 > fd)  {
               fprintf(shell_ptr->STDOUT, "Error, unable to access file system\n" );
               return_code = SHELL_EXIT_ERROR;
            } else  {
               write(fd, NULL, 0); //This flushes fd.
               close(fd);
            }
         }
      }
   }


   if (print_usage)  {
      if (shorthelp)  {
         fprintf(shell_ptr->STDOUT, "%s <filesys:>\n", argv[0]);
      } else  {
         fprintf(shell_ptr->STDOUT, "Usage: %s <filesys:>\n", argv[0]);
         fprintf(shell_ptr->STDOUT, "   filesys: = name of MFS file system\n");
      }
   }
   return return_code;
} /* Endbody */
コード例 #24
0
int_32  Shell_scale(int_32 argc, char_ptr argv[] )
{
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;
   uint_32           temp;
 
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc > 2) {
         printf("Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
      } else {
         if (argc == 2) {
            if (*argv[1] == 'f') {
               HVAC_SetTemperatureScale(Fahrenheit);
            } else if (*argv[1] == 'c') {
               HVAC_SetTemperatureScale(Celsius);
            } else {
               printf("Invalid temperature scale\n");
            } 
         }

         if (HVAC_GetTemperatureScale() == Fahrenheit) {
            printf("Temperature scale is Fahrenheit\n");
         } else {
            printf("Temperature scale is Celsius\n");
         }         
         temp  = HVAC_GetDesiredTemperature();
         printf("Desired Temperature is %d.%1d %c\n", temp/10, temp%10, HVAC_GetTemperatureSymbol());
         temp  = HVAC_GetActualTemperature();
         printf("Actual Temperature is %d.%1d %c\n", temp/10, temp%10, HVAC_GetTemperatureSymbol());
      }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s [c | f]\n", argv[0]);
      } else  {
         printf("Usage: %s [c | f]\n", argv[0]);
         printf("   c = switch to Celsius scale\n");
         printf("   f = switch to Fahrenheit scale\n");
      }
   }
   return return_code;
} 
コード例 #25
0
ファイル: sh_erase.c プロジェクト: jewlenchow/MQX_3.8.1
int_32  Shell_erase(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;
   uint_32           block;

   MQX_FILE_PTR      fd;
   char_ptr          abs_path;   
   boolean           cache_enabled=TRUE;
   SHELL_CONTEXT_PTR    shell_ptr = Shell_get_context( argv );
   char                 buf[SHELL_BLOCK_SIZE];
   
   MQX_FILE_PTR   nandflash_hdl;
    
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
   
    nandflash_hdl = fopen("nandflash:", NULL);
   
    if ((argc < 2) || (argc >= 3)) {
         printf("Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
      }
      
      block = _io_atoi( argv[1]);
            
      if(MQX_OK != ioctl(nandflash_hdl, NANDFLASH_IOCTL_ERASE_BLOCK, (void*)block))
         printf("\n\nErasing block %d failed.",block);
      else
         printf("\n\nErasing block %d passed.\n",block);
   }
      
 if (print_usage)  {
      if (shorthelp)  {
         printf("%s <block>\n", argv[0]);
      } else  {
         printf("Usage: %s <block> ", argv[0]);
         printf("   <block>      = number of block to erase\n");
      
      }
   }     
} /* Endbody */
コード例 #26
0
ファイル: sh_tnet.c プロジェクト: zhouglu/K60F120M
int_32  Shell_Telnet_client(int_32 argc, char_ptr argv[] )
{ /* Body */
   _ip_address    hostaddr;
   char           hostname[MAX_HOSTNAMESIZE];
   int_32         error;
   boolean              print_usage, shorthelp = FALSE;
   int_32               return_code = SHELL_EXIT_SUCCESS;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {

      if (argc == 2)  {
         RTCS_resolve_ip_address( argv[1], &hostaddr, hostname, MAX_HOSTNAMESIZE ); 

         if (hostaddr)  {
            printf("Connecting to %s [%ld.%ld.%ld.%ld]:\n", hostname, IPBYTES(hostaddr));

            error = TELNET_connect(hostaddr);
            if (error) {
               printf("Connection failed, error 0x%04lX\n", error);
               return_code = SHELL_EXIT_ERROR;
            } 
            printf("Connection closed\n", error);
         } else  {
            printf("Unable to resolve host\n");
            return_code = SHELL_EXIT_ERROR;
         }
      } else  {
         printf("Error, %s invoked with incorrect number of arguments\n", argv[0]);
         print_usage = TRUE;
      }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s <host>\n", argv[0]);
      } else  {
         printf("Usage: %s  <host>\n", argv[0]);
         printf("   <host>   = host ip address or name\n");
      }
   }
   return return_code;
} /* Endbody */
コード例 #27
0
int_32  Shell_temp(int_32 argc, char_ptr argv[] )
{
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;
   uint_32           temp,temp_fract;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc > 2) {
         printf("Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
      } else {
         if (argc == 2) {
            temp_fract = 0;
            if (sscanf(argv[1],"%d.%d",&temp,&temp_fract)>=1) {
               if (temp_fract<10) {
                  HVAC_SetDesiredTemperature(temp*10+temp_fract);
               } else {
                  printf("Invalid temperature specified, format is dd.d\n");
               }
            } else {
               printf("Invalid temperature specified\n");
            } 
         }

         temp  = HVAC_GetDesiredTemperature();
         printf("Desired Temperature is %d.%1d %c\n", temp/10, temp%10, HVAC_GetTemperatureSymbol());
         temp  = HVAC_GetActualTemperature();
         printf("Actual Temperature is %d.%1d %c\n", temp/10, temp%10, HVAC_GetTemperatureSymbol());
      }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s [<temperature>]\n", argv[0]);
      } else  {
         printf("Usage: %s [<temperature>]\n", argv[0]);
         printf("   <temperature> = desired temperature (degrees)\n");
      }
   }
   return return_code;
} 
コード例 #28
0
ファイル: fs_walker.c プロジェクト: NeoXiong/MP3
int_32 Shell_dir_r(int_32 argc, char_ptr argv[]) {
	boolean print_usage, shorthelp = FALSE;
	TIME_STRUCT time, time_new;
	char full_name[255];
	
	print_usage = Shell_check_help_request(argc, argv, &shorthelp);

	/* Check if help should be printed out */
	if (print_usage) {
		if (shorthelp) {
			printf("%s dir \n", argv[0]);
		} else {
			printf("Usage: %s dir \n", argv[0]);
			printf("\tList all the files in the directory.\n");
			printf("   dir        = directory to be listed.\n");
		}
	}

	set_file_filter(ext_wantted);

	_time_get(&time);
	if (0 == strcmp(argv[2], "next"))
		get_next_file_name(argv[1], full_name);
	else if (0 == strcmp(argv[2], "prev"))
		get_prev_file_name(argv[1], full_name);
	_time_get(&time_new);

	printf("%s\n", full_name);
	/*       
	 if(NULL != fopen(full_name, "r")){
	 printf("The file %s opened.\n", full_name);
	 }
	 */
	/*
	 printf("Taken %dms to list %d directories and %d files.\n", 
	 (time_new.SECONDS - time.SECONDS) * 1000 + (time_new.MILLISECONDS - time.MILLISECONDS),
	 dir_listed,
	 file_listed
	 );
	 */

	return (SHELL_EXIT_SUCCESS);
}
コード例 #29
0
ファイル: sh_abort.c プロジェクト: nevinxu/HM502B2
int32_t  Shell_abort(int32_t argc, char *argv[] ) {
   SHELL_CONTEXT_PTR shell_ptr = Shell_get_context(argv);
   bool     print_usage, shorthelp = FALSE;
   int32_t      return_code = SHELL_EXIT_SUCCESS;
   _task_id    task_id;
   uint32_t     result;

   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      
      if (argc == 2)  {
         task_id = _task_get_id_from_name( argv[1] );
         if (task_id == MQX_NULL_TASK_ID)  {
            fprintf(shell_ptr->STDOUT, "No task named %s running.\n",argv[1]);
            return_code = SHELL_EXIT_ERROR;
         } else  {
            result = _task_abort(task_id);
            if (result == MQX_OK)  {  
               fprintf(shell_ptr->STDOUT, "Task %s aborted.\n",argv[1]);
            } else  {
               fprintf(shell_ptr->STDOUT, "Unable to abort task %s.\n",argv[1]);
               return_code = SHELL_EXIT_ERROR;
            }
         }
      } else  {
         fprintf(shell_ptr->STDOUT, "Error, %s invoked with incorrect number of arguments\n", argv[0]);
         print_usage = TRUE;
      }
   }

   if (print_usage)  {
      if (shorthelp)  {
         fprintf(shell_ptr->STDOUT, "%s <taskname>\n", argv[0]);
      } else  {
         fprintf(shell_ptr->STDOUT, "Usage: %s <taskname>\n", argv[0]);
         fprintf(shell_ptr->STDOUT, "   <taskname> = MQX Task name\n");
      }
   }

   return return_code;
} /* Endbody */
コード例 #30
0
ファイル: boot_cmd.c プロジェクト: mihaSoro/MQX-3.7.0
int_32  Shell_bootloader_set_timeout(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean             print_usage, shorthelp = FALSE;
   int_32              return_code = SHELL_EXIT_SUCCESS;
    
   int_32              index,timeout;
    
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );
   
  
   if (!print_usage)  {
   
      if (argc != 3) {
         printf("Error, invalid number of parameters\n");
         return_code = SHELL_EXIT_ERROR;
         print_usage=TRUE;
        }
      else
      {
          index = _io_atoi( argv[1]);
          timeout = _io_atoi( argv[2]);
          if (MQX_OK ==_bootloader_set_timeout(index,timeout)){
            printf ("Set image %d autoboot timeout in %d seconds success\n",index,timeout);
          }
          else{
            printf ("Set default error\n ");
          }
           
      }
    }
 if (print_usage)  {
      if (shorthelp)  {
         printf("%s <index> <timeout>\n", argv[0]);
      } else  {
         printf("Usage: %s <index> <timeout> \n", argv[0]);
         printf("   <index>    = Image index to set autoboot timeout\n");
         printf("   <timeout>  = Timeout value in second\n");
      }
    
   }
  } /* Endbody */