/*= EchoCharacter =========================================================== Purpose: Echoes a character to the terminal. Inputs: new_char -- character to echo Returns: none ============================================================================*/ static void EchoCharacter(INT8 c) { if (IS_ECHO_ON()) { /* output cr then lf for lf */ if (c == (INT8)'\n') { putcUART('\r'); } putcUART(c); } }
/*= EchoCharacter =========================================================== Purpose: Echoes a character to the terminal. Inputs: new_char -- character to echo Returns: none ============================================================================*/ static tZGVoidReturn EchoCharacter(tZGS8 c) { if (IS_ECHO_ON()) { /* output cr then lf for lf */ if (c == (tZGS8)'\n') { ZGSYS_UART_PUTC(kStdoutPort, '\r'); } ZGSYS_UART_PUTC(kStdoutPort, c); } }
/*= EchoCharacter =========================================================== Purpose: Echoes a character to the terminal. Inputs: new_char -- character to echo Returns: none ============================================================================*/ static void EchoCharacter(int8_t c) { if (IS_ECHO_ON()) { /* output cr then lf for lf */ if (c == (int8_t)'\n') { SYS_CONSOLE_PUTC('\r'); } SYS_CONSOLE_PUTC(c); } }
/***************************************************************************** * FUNCTION: process_cmd * * RETURNS: None * * PARAMS: None * * NOTES: Determines which command has been received and processes it. *****************************************************************************/ void process_cmd(void) { bool new_arg; uint8_t i; g_ConsoleContext.argc = 0; new_arg = true; // Get pointers to each token in the command string TokenizeCmdLine(g_ConsoleContext.rxBuf); // if command line nothing but white kSpace or a linefeed if ( g_ConsoleContext.argc == 0u ) { return; // nothing to do } // change the command itself (token[0]) to lower case for (i = 0; i < strlen((char *)g_ConsoleContext.argv[0]); ++i) { g_ConsoleContext.argv[0][i] = tolower(g_ConsoleContext.argv[0][i]); } if ( IS_ECHO_ON() ) { SYS_CONSOLE_MESSAGE("\n\r"); } switch (GetCmdId()) { case HELP_MSG: do_help_msg(); IperfConsoleSetMsgFlag(); break; case RESET_HOST: Reset(); break; case CLEAR_SCREEN_MSG: do_cls_cmd(); break; default: IperfConsoleSetMsgFlag(); break; } }
/*= Enter ==================================================================== Purpose: Enter key processing Inputs: None Returns: none ============================================================================*/ static void Enter(void) { BOOL cmd_flag = FALSE; if ( IS_ECHO_ON() ) { /* if the command line has any characters in it and it is not just white space */ if ( (GET_LEN_RX_CMD_STRING() > 0u) && (!isCmdLineOnlyWhitespace() ) ) { #if (kWFNumHistoryEntries > 0) AddCmdToHistory(); #endif cmd_flag = TRUE; } } // else talking to PC app, presume it only sends valid commands else { cmd_flag = TRUE; } // Process command if (cmd_flag == TRUE) { process_cmd(); } // if we got an app-specific command, if (g_ConsoleContext.appConsoleMsgRx == FALSE) { /* linefeed and output prompt */ OutputCommandPrompt(); } // don't output command prompt, which also clears rx buf, until app processes it's command }
/***************************************************************************** * FUNCTION: process_cmd * * RETURNS: None * * PARAMS: None * * NOTES: Determines which command has been received and processes it. *****************************************************************************/ void process_cmd(void) { BOOL new_arg; UINT8 i; g_ConsoleContext.argc = 0; new_arg = TRUE; // Get pointers to each token in the command string TokenizeCmdLine(g_ConsoleContext.rxBuf); // if command line nothing but white kWFSpace or a linefeed if ( g_ConsoleContext.argc == 0u ) { return; // nothing to do } // change the command itself (token[0]) to lower case for (i = 0; i < strlen((char *)g_ConsoleContext.argv[0]); ++i) { g_ConsoleContext.argv[0][i] = tolower(g_ConsoleContext.argv[0][i]); } if ( IS_ECHO_ON() ) { putrsUART("\n\r"); } switch (GetCmdId()) { case HELP_MSG: do_help_msg(); WFConsoleSetMsgFlag(); break; case GET_WF_VERSION_MSG: do_get_wfver_cmd(); break; case RESET_HOST: Reset(); break; case CLEAR_SCREEN_MSG: do_cls_cmd(); break; #if defined(MRF24WG) case WPS_PIN_MSG: do_wps_pin_cmd(); break; case WPS_PUSHBUTTON_MSG: do_wps_push_button_cmd(); break; case WPS_GET_CREDENTIALS_MSG: do_wps_get_credentials_cmd(); break; #endif /* MRF24WG */ #if defined(WF_CONSOLE_IFCFGUTIL) case IFCONFIG_MSG: do_ifconfig_cmd(); break; case IWCONFIG_MSG: do_iwconfig_cmd(); break; case IWPRIV_MSG: do_iwpriv_cmd(); break; #endif // WF_CONSOLE_IFCFGUTIL default: WFConsoleSetMsgFlag(); break; } }
/***************************************************************************** * FUNCTION: process_cmd * * RETURNS: None * * PARAMS: None * * NOTES: Determines which command has been received and processes it. *****************************************************************************/ tZGVoidReturn process_cmd(tZGVoidInput) { tZGBool new_arg; tZGU8 i; g_ConsoleContext.argc = 0; new_arg = kZGBoolTrue; // Get pointers to each token in the command string TokenizeCmdLine(g_ConsoleContext.rxBuf); // if command line nothing but white kZGSpace or a linefeed if ( g_ConsoleContext.argc == 0u ) { return; // nothing to do } // change the command itself (token[0]) to lower case for (i = 0; i < strlen((char *)g_ConsoleContext.argv[0]); ++i) { g_ConsoleContext.argv[0][i] = tolower(g_ConsoleContext.argv[0][i]); } if ( IS_ECHO_ON() ) { ZG_PUTRSUART("\n\r"); } switch (GetCmdId()) { case HELP_MSG: do_help_msg(); break; case GET_ZG2100_VERSION_MSG: do_get_zg2100_version_cmd(); break; case RESET_HOST: Reset(); break; case CLEAR_SCREEN_MSG: do_cls_cmd(); break; case IFCONFIG_MSG: do_ifconfig_cmd(); break; case IWCONFIG_MSG: do_iwconfig_cmd(); break; case IWPRIV_MSG: do_iwpriv_cmd(); break; default: // if we don't match one of the built-in command strings, check to // see if we match one of the application-defined command strings if (CheckForAppSpecificCommand(g_ConsoleContext.argv[0])) { ; // nothing else to do } else { sprintf((char *) g_ConsoleContext.txBuf, "Unknown cmd: %s\n\r", ARGV[0]); ZG_PUTSUART( (char *) g_ConsoleContext.txBuf ); } break; } }