Example #1
0
/*****************************************************************************
 * FUNCTION: WFConsoleProcess
 *
 * RETURNS: None
 *
 * PARAMS:  None
 *
 * NOTES:   State machine called from main loop of app.  Handles serial input.
 *
 *****************************************************************************/
void WFConsoleProcess(void)
{
    //UINT8 *pStart = &(cmdline[0]);
    UINT16  rc;
    INT8  c;
    static INT8 escape_sequence[kWFMaxInputEscapeSequence];
    static INT8 esc_seq_index;

    // if this state machine has been disabled
    if (g_ConsoleContext.bStateMachineLoop == FALSE)
    {
        return;
    }


    // if a command was entered that is application=specific
    if (g_ConsoleContext.appConsoleMsgRx == TRUE)
    {
        return;  // wait until app done before processing further characters
    }

    // if no character(s) received
    if ( (rc = DataRdyUART() ) == 0u )
    {
        return;
    }

    // get the character
    c = (INT8) ReadUART();

    // if this is the very first character received by this state machine
    if (g_ConsoleContext.firstChar == FALSE)
    {
        Output_Monitor_Hdr();
        g_ConsoleContext.firstChar = TRUE;
    }

    switch( GET_RX_STATE() )
    {
        //------------------------------------------
        case kSTWaitForChar:
        //------------------------------------------
            // if a 'normal' printable character
            if (isPrintableCharacter(c))
            {
                InsertCharacter(c);
            }
            // else if Delete key
            else if (c == kWFDelete)
            {
                Delete();
            }
            // else if Backspace key
            else if (c == (INT8)kWFBackspace)
            {
                Backspace();
            }
            // else if Enter key
            else if (c == kWFEnter)
            {
                Enter();
            }
            // else if Escape key
            else if (c == kWFEscape)
            {
                /* zero out escape buffer, init with ESC */
                memset(escape_sequence, 0x00, sizeof(escape_sequence));
                escape_sequence[0] = kWFEscape;
                esc_seq_index = 1;
                SET_RX_STATE(kSTWaitForEscSeqSecondChar);
            }
            // else if Ctrl C
            else if (c == kWFCtrl_C)
            {
               OutputCommandPrompt();
            }
            else {
                // Enter();
            }
            break;

        //------------------------------------------
        case kSTWaitForEscSeqSecondChar:
        //------------------------------------------
            /* if an arrow key, home, or end key (which is all that this state machine handles) */
            if (c == 0x5b)
            {
               escape_sequence[1] = c;
               SET_RX_STATE(kSTWaitForEscSeqThirdChar);
            }
            // else if user pressed escape followed by any printable character
            else if (isPrintableCharacter(c))
            {
                InsertCharacter(c);
                SET_RX_STATE(kSTWaitForChar);
            }
            // start this command line over
            else // anything else
            {
                OutputCommandPrompt();
                SET_RX_STATE(kSTWaitForChar);
            }
            break;

        //------------------------------------------
        case kSTWaitForEscSeqThirdChar:
        //------------------------------------------
            escape_sequence[2] = c;
            ProcessEscapeSequence(escape_sequence);
            SET_RX_STATE(kSTWaitForChar);
            break;


    } // end switch
}
static tZGVoidReturn do_cls_cmd(tZGVoidInput)
{
    Output_Monitor_Hdr();
}
Example #3
0
static void do_cls_cmd(void)
{
    Output_Monitor_Hdr();
}
Example #4
0
/*****************************************************************************
 * FUNCTION: IperfConsoleProcess
 *
 * RETURNS: None
 *
 * PARAMS:  None
 *
 * NOTES:   State machine called from main loop of app.  Handles serial input.
 *
 *****************************************************************************/
void IperfConsoleProcess(void)
{
    //uint8_t *pStart = &(cmdline[0]);
    int8_t  c;
    static int8_t escape_sequence[kMaxInputEscapeSequence];
    static int8_t esc_seq_index;

    // if this state machine has been disabled
    if (g_ConsoleContext.bStateMachineLoop == false)
    {
        return;
    }


    // if a command was entered that is application=specific
    if (g_ConsoleContext.appConsoleMsgRx == true)
    {
        return;  // wait until app done before processing further characters
    }

    // if no character(s) received
    if (SYS_CONSOLE_DATA_RDY() == 0)
    {
        return;
    }

    // get the character
    c = (int8_t) SYS_CONSOLE_GETC();

    // if this is the very first character received by this state machine
    if (g_ConsoleContext.firstChar == false)
    {
        Output_Monitor_Hdr();
        g_ConsoleContext.firstChar = true;
    }

    switch( GET_RX_STATE() )
    {
        //------------------------------------------
        case kSTWaitForChar:
        //------------------------------------------
            // if a 'normal' printable character
            if (isPrintableCharacter(c))
            {
                InsertCharacter(c);
            }
            // else if Delete key
            else if (c == kDelete)
            {
                Delete();
            }
            // else if Backspace key
            else if (c == (int8_t)kBackspace)
            {
                Backspace();
            }
            // else if Enter key
            else if (c == kEnter)
            {
                Enter();
            }
            // else if Escape key
            else if (c == kEscape)
            {
                /* zero out escape buffer, init with ESC */
                memset(escape_sequence, 0x00, sizeof(escape_sequence));
                escape_sequence[0] = kEscape;
                esc_seq_index = 1;
                SET_RX_STATE(kSTWaitForEscSeqSecondChar);
            }
            // else if Ctrl C
            else if (c == kCtrl_C)
            {
               OutputCommandPrompt();
            }
            else {
                // Enter();
            }
            break;

        //------------------------------------------
        case kSTWaitForEscSeqSecondChar:
        //------------------------------------------
            /* if an arrow key, home, or end key (which is all that this state machine handles) */
            if (c == 0x5b)
            {
               escape_sequence[1] = c;
               SET_RX_STATE(kSTWaitForEscSeqThirdChar);
            }
            // else if user pressed escape followed by any printable character
            else if (isPrintableCharacter(c))
            {
                InsertCharacter(c);
                SET_RX_STATE(kSTWaitForChar);
            }
            // start this command line over
            else // anything else
            {
                OutputCommandPrompt();
                SET_RX_STATE(kSTWaitForChar);
            }
            break;

        //------------------------------------------
        case kSTWaitForEscSeqThirdChar:
        //------------------------------------------
            escape_sequence[2] = c;
            
            if ((c == 0x31) || (c == 0x34))   // home or end key
            {
                SET_RX_STATE(kSTWaitForEscSeqFourthChar);
            }
            else
            {    
                ProcessEscapeSequence(escape_sequence);
                SET_RX_STATE(kSTWaitForChar);
            }    
            break;
            
        //------------------------------------------            
        case kSTWaitForEscSeqFourthChar:
        //------------------------------------------
            ProcessEscapeSequence(escape_sequence);
            SET_RX_STATE(kSTWaitForChar);
            break;
            


    } // end switch
}