Atmel Software Framework

shell.h File Reference
#include "compiler.h"
#include "FreeRTOS.h"
#include "supervisor.h"

Macros

#define ABORT_CHAR   CTRL_C
 
#define BKSPACE_CHAR   '\b'
 
#define CR   '\r'
 
#define CRLF   "\r\n"
 
#define CTRL_C   0x03
 
#define CTRL_Q   0x11
 
#define ERROR_CRLF   "Error"CRLF
 
#define LF   '\n'
 
#define OK_CRLF   "OK"CRLF
 
#define QUIT_APPEND   CTRL_Q
 
#define SHELL_ERRMSG_CONFIGERROR   ERROR_CRLF"COULD NOT SET CONFIG"CRLF
 
#define SHELL_ERRMSG_MAINTENANCEMODE   ERROR_CRLF"Command unavailable in maintenance mode"CRLF
 
#define SHELL_ERRMSG_MEMALLOC   ERROR_CRLF"Memory allocation failed"CRLF
 
#define SHELL_ERRMSG_NOTIMPLEMENTED   "NOT IMPLEMENTED"CRLF
 
#define SHELL_MAX_MSGOUT_LEN   128
 
#define SHELL_MSG_CONFIG_SET   "config updated"CRLF
 
#define SHELL_MSG_REBOOT   "Reboot to take effect"CRLF
 

Typedefs

typedef eExecStatus(* pfShellCmd )(eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 Function pointer typedef that each command should abide to. More...
 

Enumerations

enum  eExecStatus {
  SHELL_EXECSTATUS_OK,
  SHELL_EXECSTATUS_OK_NO_FREE,
  SHELL_EXECSTATUS_KO
}
 

Functions

eExecStatus Shell_exec (signed portCHAR *pcStringCmd, eModId xModId, signed short FsNavId, signed portCHAR **ppcStringReply)
 a command line executor. More...
 
void v_shell_Print_String_To_Requester_Stream (eModId xModId, const signed portCHAR *pcStringToDisplay)
 Print a string directly to the output stream of a module. More...
 

#define ABORT_CHAR   CTRL_C
#define BKSPACE_CHAR   '\b'
#define CR   '\r'
#define CRLF   "\r\n"
#define CTRL_C   0x03
#define CTRL_Q   0x11
#define ERROR_CRLF   "Error"CRLF
#define LF   '\n'
#define OK_CRLF   "OK"CRLF
#define QUIT_APPEND   CTRL_Q
#define SHELL_ERRMSG_MAINTENANCEMODE   ERROR_CRLF"Command unavailable in maintenance mode"CRLF
#define SHELL_ERRMSG_NOTIMPLEMENTED   "NOT IMPLEMENTED"CRLF
#define SHELL_MAX_MSGOUT_LEN   128

The max length of a response line.

Referenced by e_fscmds_shell_disk(), e_fscmds_shell_pwd(), e_usbsys_lsusb(), prv_df(), and prv_ls().

#define SHELL_MSG_CONFIG_SET   "config updated"CRLF
#define SHELL_MSG_REBOOT   "Reboot to take effect"CRLF

typedef eExecStatus(* pfShellCmd)(eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)

Function pointer typedef that each command should abide to.

Parameters
xModIdInput. The module that is calling this function.
FsNavIdInput. The file system navigator id to use if the cmd is a file system command.
acInput. The argument counter.
avInput. The argument vector.
ppcStringReplyInput/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed if the returned status is OK; the caller must then free this string.
Returns
the status of the command execution.

The exec command return status.

Enumerator
SHELL_EXECSTATUS_OK 
SHELL_EXECSTATUS_OK_NO_FREE 
SHELL_EXECSTATUS_KO 

eExecStatus Shell_exec ( signed portCHAR *  pcStringCmd,
eModId  xModId,
signed short  FsNavId,
signed portCHAR **  ppcStringReply 
)

a command line executor.

Parameters
pcStringCmdInput. The cmd line to execute. NULL-terminated string. Format: cmd [arg[=val]], 2 (arg,val) maximum. WARNING: this string will be modified.
xModIdInput. The module that is calling this exe function.
FsNavIdInput. The file system navigator id to use if the cmd is a file system command.
ppcStringReplyOutput. The caller must free this string (by calling vportFree()) only if it is non-NULL and the returned status is OK.
Returns
the status of the command execution.
Parameters
pcStringCmdInput. The cmd line to execute. NULL-terminated string. Format: cmd [arg] [arg=val], with 6 (arg,val) maximum. WARNING: this string will be modified.
xModIdInput. The module that is calling this exe function.
FsNavIdInput. The file system navigator id to use if the cmd is a file system command.
ppcStringReplyOutput. The caller must free this string (by calling vportFree()) only if it is non-NULL and the returned status is OK.
Returns
the status of the command execution.

References i, NULL, pdFALSE, st_cmd_registration::pf_exec_cmd, PrevCmdAc, PrevCmdIdx, prvCmdIdentify_Tokenize(), SHELL_CMDSTATUS_NOTFOUND, SHELL_CMDSTATUS_PERMISSIONDENIED, SHELL_ERRMSG_MAINTENANCEMODE, SHELL_EXECSTATUS_KO, SHELL_FS_FIRSTCMDIDX, SHELL_FS_LASTCMDIDX, SHELL_MAX_NBTOKEN, x_supervisor_SemaphoreGive(), and x_supervisor_SemaphoreTake().

Referenced by portTASK_FUNCTION().

void v_shell_Print_String_To_Requester_Stream ( eModId  xModId,
const signed portCHAR *  pcStringToDisplay 
)

Print a string directly to the output stream of a module.

Parameters
xModIdInput. The module associated with the target output stream.
pcStringToDisplayInput. The string to print.

References SYS_MODID_COM1SHELL, SYS_MODID_USB, TRACE_COM2, and vcom1shell_PrintMsg().

Referenced by e_fscmds_shell_fat(), e_fscmds_shell_pwd(), e_usbsys_lsusb(), prv_append(), prv_cat(), prv_df(), prv_e_usbsys_sync_cp_ukey(), and prv_ls().