/** * INITIALIZATION and DESTRUCTION */ ImuInterfaceNonRT::ImuInterfaceNonRT() { stop_reading_ = false; sl_rt_mutex_init(&mutex_); num_writes_ = 0; num_reads_ = 0; initialized_ = false; // gravity_[0] = gravity_[1] = gravity_[2] =0.0; timestamp_ = 0; }
/*!***************************************************************************** ******************************************************************************* \note initXeno \date Oct. 2009 \remarks xenomai specific initializations ******************************************************************************* Function Parameters: [in]=input,[out]=output none ******************************************************************************/ void initXeno(char *task_name) { int rc; struct sigaction sa; // lock all of the pages currently and pages that become // mapped into the address space of the process mlockall(MCL_CURRENT | MCL_FUTURE); sl_rt_mutex_init(&mutex1); //become a real-time process char name[100]; sprintf(name, "x%s_main_%d", task_name, parent_process_id); rt_task_shadow(NULL, name, 0, 0); // what to do when mode switches happen signal(SIGDEBUG, action_upon_switch); // start the non real-time printing library rt_print_auto_init(1); // get the timer info if ((rc=rt_timer_set_mode((RTIME) XENO_CLOCK_PERIOD))) printf("rc_timer_set_mode returned %d\n",rc); // check what we got RT_TIMER_INFO info; rt_timer_inquire(&info); if (info.period == TM_ONESHOT) printf("Timer Period = TM_ONESHOT\n"); else printf("Timer Period = %ld [ns]\n",(long) info.period); }