Пример #1
0
void *VRBRAINScheduler::_timer_thread(void *arg)
{
    VRBRAINScheduler *sched = (VRBRAINScheduler *)arg;
    uint32_t last_ran_overtime = 0;

    pthread_setname_np(pthread_self(), "apm_timer");

    while (!sched->_hal_initialized) {
        poll(nullptr, 0, 1);
    }
    while (!_vrbrain_thread_should_exit) {
        sched->delay_microseconds_semaphore(1000);

        // run registered timers
        perf_begin(sched->_perf_timers);
        sched->_run_timers();
        perf_end(sched->_perf_timers);

        // process any pending RC output requests
        hal.rcout->timer_tick();

        // process any pending RC input requests
        ((VRBRAINRCInput *)hal.rcin)->_timer_tick();

        if (vrbrain_ran_overtime && AP_HAL::millis() - last_ran_overtime > 2000) {
            last_ran_overtime = AP_HAL::millis();
#if 0
            printf("Overtime in task %d\n", (int)AP_Scheduler::current_task);
            hal.console->printf("Overtime in task %d\n", (int)AP_Scheduler::current_task);
#endif
        }
    }
    return nullptr;
}
Пример #2
0
void *VRBRAINScheduler::_storage_thread(void *arg)
{
    VRBRAINScheduler *sched = (VRBRAINScheduler *)arg;

    pthread_setname_np(pthread_self(), "apm_storage");

    while (!sched->_hal_initialized) {
        poll(nullptr, 0, 1);
    }
    while (!_vrbrain_thread_should_exit) {
        sched->delay_microseconds_semaphore(10000);

        // process any pending storage writes
        perf_begin(sched->_perf_storage_timer);
        hal.storage->_timer_tick();
        perf_end(sched->_perf_storage_timer);
    }
    return nullptr;
}
Пример #3
0
void *VRBRAINScheduler::_io_thread(void *arg)
{
    VRBRAINScheduler *sched = (VRBRAINScheduler *)arg;

    pthread_setname_np(pthread_self(), "apm_io");

    while (!sched->_hal_initialized) {
        poll(nullptr, 0, 1);
    }
    while (!_vrbrain_thread_should_exit) {
        sched->delay_microseconds_semaphore(1000);

        // run registered IO processes
        perf_begin(sched->_perf_io_timers);
        sched->_run_io();
        perf_end(sched->_perf_io_timers);
    }
    return nullptr;
}
Пример #4
0
void *VRBRAINScheduler::_uart_thread(void *arg)
{
    VRBRAINScheduler *sched = (VRBRAINScheduler *)arg;

    while (!sched->_hal_initialized) {
        poll(NULL, 0, 1);
    }
    while (!_vrbrain_thread_should_exit) {
        sched->delay_microseconds_semaphore(1000);

        // process any pending serial bytes
        ((VRBRAINUARTDriver *)hal.uartA)->_timer_tick();
        ((VRBRAINUARTDriver *)hal.uartB)->_timer_tick();
        ((VRBRAINUARTDriver *)hal.uartC)->_timer_tick();
        ((VRBRAINUARTDriver *)hal.uartD)->_timer_tick();
        ((VRBRAINUARTDriver *)hal.uartE)->_timer_tick();
        ((VRBRAINUARTDriver *)hal.uartF)->_timer_tick();
    }
    return NULL;
}
Пример #5
0
void *VRBRAINScheduler::_uart_thread(void *arg)
{
    VRBRAINScheduler *sched = (VRBRAINScheduler *)arg;

    pthread_setname_np(pthread_self(), "apm_uart");

    while (!sched->_hal_initialized) {
        poll(nullptr, 0, 1);
    }
    while (!_vrbrain_thread_should_exit) {
        sched->delay_microseconds_semaphore(1000);

        // process any pending serial bytes
        hal.uartA->_timer_tick();
        hal.uartB->_timer_tick();
        hal.uartC->_timer_tick();
        hal.uartD->_timer_tick();
        hal.uartE->_timer_tick();
        hal.uartF->_timer_tick();
    }
    return nullptr;
}