Exemple #1
0
int32_t pl011_uart_interrupt_handler(void) {

	uint32_t ascii;

	/* read byte */
	while(1) {
		ascii=pl011_uart_getc_noblock();
		if (ascii==-1) break;

		/* Send to console */
		console_insert_char(ascii);
	}

	/* Clear receive interrupt */

	bcm2835_write(UART0_ICR,UART0_ICR_RTIC);

	return 0;
}
Exemple #2
0
cmd_err_t console_process_char( char c )
{
    cmd_err_t err = ERR_CMD_OK;
    in_process_char = WICED_TRUE;

    /* printf("ConsoleProcessChar\r\n"); */
    if ( console_in_esc_seq )
    {
        console_in_esc_seq = console_process_esc_seq( c );
    }
    else
    {
        /* printf("%lu %lu\r\n", (uint32_t)c, (uint32_t)'\b'); */
        switch ( c )
        {
            case 9: /* tab char */
                if ( tab_handling_func )
                {
                    tab_handling_func( );
                }
                break;
            case 10: /* line feed */
                /* ignore it */
                break;
            case '\r': /* newline */
                if ( newline_handling_func )
                {
                    err = newline_handling_func( );
                }
                break;
            case 27: /* escape char */
                console_in_esc_seq = WICED_TRUE;
                break;
            case '\b': /* backspace */
            case '\x7F': /* backspace */
                console_do_backspace( );
                break;
            case 16: /* ctrl-p */
                console_do_up( );
                break;
            case 14: /* ctrl-n */
                console_do_down( );
                break;
            case 2: /* ctrl-b */
                console_do_left( );
                break;
            case 6: /* ctrl-f */
                console_do_right( );
                break;
            case 1: /* ctrl-a */
                console_do_home( );
                break;
            case 5: /* ctrl-e */
                console_do_end( );
                break;
            case 4: /* ctrl-d */
                console_do_delete( );
                break;
            default:
                if ( ( c > 31 ) && ( c < 127 ) )
                { /* limit to printables */
                    if ( strlen( console_buffer ) + 1 < console_line_len )
                    {
                        console_current_line = 0;
                        console_insert_char( c );
                    }
                    else
                    {
                        send_charstr( console_bell_string );
                    }
                }
                else
                {
                    send_charstr( console_bell_string );
                }
                break;
        }
    }

    in_process_char = WICED_FALSE;
    return err;
}
Exemple #3
0
void console_do_tab( void )
{
    uint32_t buf_len = strlen( console_buffer );
    const command_t* cmd_ptr = NULL;

    console_do_end( );

    if ( console_in_tab_tab == WICED_FALSE )
    {
        char *src = NULL;
        wiced_bool_t single_match = WICED_FALSE;
        uint32_t len = 0;

        /* for each where the buffer matches it's start */
        for ( cmd_ptr = console_command_table; cmd_ptr->name != NULL; cmd_ptr++ )
        {
            if ( strncmp( cmd_ptr->name, console_buffer, buf_len ) == 0 )
            {
                /* if we already have one or more matches then the completion is the longest common prefix */
                if ( src )
                {
                    single_match = WICED_FALSE;
                    uint32_t i = buf_len;
                    while ( ( i < len ) && ( src[i] == cmd_ptr->name[i] ) )
                    {
                        i++;
                    }
                    len = i;
                }
                /* for the first match the completion is the whole command */
                else
                {
                    single_match = WICED_TRUE;
                    src = cmd_ptr->name;
                    len = strlen( cmd_ptr->name );
                }
            }
        }

        /* if there is a valid completion then add it to the buffer */
        if ( src && ( ( len > strlen( console_buffer ) ) || single_match ) )
        {
            uint32_t i;
            for ( i = buf_len; i < len; i++ )
            {
                console_insert_char( src[i] );
            }
            if ( single_match )
            {
                console_insert_char( ' ' );
            }
        }
        else
        {
            console_in_tab_tab = WICED_TRUE;
        }
    }
    else
    {
        uint32_t cnt = 0;

        for ( cmd_ptr = console_command_table; cmd_ptr->name != NULL; cmd_ptr++ )
        {
            if ( ( strncmp( cmd_ptr->name, console_buffer, buf_len ) == 0 ) && ( strcmp( cmd_ptr->name, "" ) != 0 ) )
            {
                if ( ( cnt % 4 ) == 0 )
                {
                    send_str( (char*) "\r\n" );
                }
                else
                {
                    send_char( ' ' );
                }
                printf( "%-19.19s", cmd_ptr->name );
                cnt++;
            }
        }
        if ( cnt )
        {
            send_str( (char*) "\r\n" );
            send_str( console_prompt_string );
            send_str( console_buffer );
        }
        console_in_tab_tab = WICED_FALSE;
    }
}