コード例 #1
0
void process_uart_rx_fifo()
{
    if(fifo_get_size(&uart_rx_fifo) >= COMMAND_SIZE)
    {
        uint8_t received_cmd[COMMAND_SIZE];
        fifo_pop(&uart_rx_fifo, received_cmd, COMMAND_SIZE);
        if(strncmp(received_cmd, COMMAND_CHAN, COMMAND_SIZE) == 0)
        {
            process_command_chan();
        }
        else if(strncmp(received_cmd, COMMAND_LOOP, COMMAND_SIZE) == 0)
        {
            process_command_loop();
        }
        else if(strncmp(received_cmd, COMMAND_RSET, COMMAND_SIZE) == 0)
        {
            hw_reset();
        }
        else
        {
            char err[40];
            snprintf(err, sizeof(err), "ERROR invalid command %.4s\n", received_cmd);
            console_print(err);
        }

        fifo_clear(&uart_rx_fifo);
    }
}
コード例 #2
0
static void process_uart_rx_fifo()
{
    if(fifo_get_size(&uart_rx_fifo) >= COMMAND_SIZE)
    {
        uint8_t received_cmd[COMMAND_SIZE];
        fifo_pop(&uart_rx_fifo, received_cmd, COMMAND_SIZE);
        if(strncmp(received_cmd, COMMAND_CHAN, COMMAND_SIZE) == 0)
        {
            process_command_chan();
        }
        else if(strncmp(received_cmd, COMMAND_TRAN, COMMAND_SIZE) == 0)
        {
            while(fifo_get_size(&uart_rx_fifo) < COMMAND_TRAN_PARAM_SIZE);

            char param[COMMAND_TRAN_PARAM_SIZE];
            fifo_pop(&uart_rx_fifo, param, COMMAND_TRAN_PARAM_SIZE);
            tx_packet_delay_s = atoi(param);
            DPRINT("performing TRAN command with %d tx_packet_delay_s\r\n",
                   tx_packet_delay_s);

            stop();
            is_mode_rx = false;
            current_state = STATE_RUNNING;
            sched_post_task(&start);
        }
        else if(strncmp(received_cmd, COMMAND_RECV, COMMAND_SIZE) == 0)
        {
            DPRINT("entering RECV mode\r\n");
            stop();
            is_mode_rx = true;
            current_state = STATE_RUNNING;
            sched_post_task(&start);
        }
        else if(strncmp(received_cmd, COMMAND_RSET, COMMAND_SIZE) == 0)
        {
            DPRINT("resetting...\r\n");
            hw_reset();
        }
        else
        {
            char err[40];
            DPRINT("ERROR invalid command %.4s\n\r", received_cmd);
        }

        fifo_clear(&uart_rx_fifo);
    }

    timer_post_task_delay(&process_uart_rx_fifo, TIMER_TICKS_PER_SEC);
}
コード例 #3
0
static void process_uart_rx_fifo()
{
    if(fifo_get_size(&uart_rx_fifo) >= COMMAND_SIZE)
    {
        uint8_t received_cmd[COMMAND_SIZE];
        fifo_pop(&uart_rx_fifo, received_cmd, COMMAND_SIZE);
        if(strncmp(received_cmd, COMMAND_CHAN, COMMAND_SIZE) == 0)
        {
            process_command_chan();
        }
        else if(strncmp(received_cmd, COMMAND_TRAN, COMMAND_SIZE) == 0)
        {
            while(fifo_get_size(&uart_rx_fifo) < COMMAND_TRAN_PARAM_SIZE);

            char param[COMMAND_TRAN_PARAM_SIZE];
            fifo_pop(&uart_rx_fifo, param, COMMAND_TRAN_PARAM_SIZE);
            tx_packet_delay_s = atoi(param);

            stop();
            is_mode_rx = false;
            current_state = STATE_RUNNING;
            sched_post_task(&start);
        }
        else if(strncmp(received_cmd, COMMAND_RECV, COMMAND_SIZE) == 0)
        {
            stop();
            is_mode_rx = true;
            current_state = STATE_RUNNING;
            sched_post_task(&start);
        }
        else if(strncmp(received_cmd, COMMAND_RSET, COMMAND_SIZE) == 0)
        {
            hw_reset();
        }
        else
        {
            char err[40];
            snprintf(err, sizeof(err), "ERROR invalid command %.4s\n", received_cmd);
            uart_transmit_string(err);
        }

        fifo_clear(&uart_rx_fifo);
    }

    timer_post_task_delay(&process_uart_rx_fifo, TIMER_TICKS_PER_SEC);
}