[Xenomai] task sleep time is getting added when I move my mouse

Ashok kumar ashokkumar.bb at gmail.com
Tue Jul 24 14:48:39 CEST 2018


I mention below a sample code of my project using soem I use the task
function as below

void Dc_time_Pll_function()

     struct timespec   ts, tleft;

     static int64 integral = 0;

     int64 sec, nsec,delta, cycletime=1000000;

     clock_gettime(CLOCK_MONOTONIC, &ts);
             previous1 = rt_timer_read();   //read time

             input_ek1818  = (Ek1818_data_inputt *)
ec_slave[slave_pos_beck_digitalIO].inputs;//struct pointers to slave I/O
pointers inputs//
             output_ek1818 = (Ek1818_data_outputt*)
             in_EL5101     = (in_EL5101t*)
             out_EL5101    = (out_EL5101t*)

             nsec = (cycletime + offsettime) % NSEC_PER_SEC;
             sec  = ((cycletime + offsettime) - nsec) / NSEC_PER_SEC;

             ts.tv_sec += sec;
             ts.tv_nsec += nsec;

             if (ts.tv_nsec >= NSEC_PER_SEC )
               nsec = ts.tv_nsec % NSEC_PER_SEC;
               ts.tv_sec += (ts.tv_nsec - nsec) / NSEC_PER_SEC;
               ts.tv_nsec = nsec;
             clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts,
           // Loop user code here

        if (ec_slave[0].hasdc)
          //ec_Dctime is the system time synchronised with Ethercat
              delta = (ec_DCtime -(cycletime/4)) % cycletime;
                  if(delta > (cycletime / 2))
                       delta= delta - cycletime;


                  offsettime = -(delta / 100) - (integral / 20);


and I am using clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts,
&tleft);     to wait for a time untill the sleep wakes up this routine
works good,

but when I move a mouse the clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME,
&ts, &tleft);  gets some amount of microsecond added then, and my ethercat
slave loss frame but the slave is synchronised with master.

can anybody solve the problem such that when I move my mouse or keyboard
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, &tleft);  nanosleep
time should not get jumped or time get added to it so that

I dont loss any ethercat frames.

Thank you

R. Ashokkumar

<https://mailtrack.io/> Sent with Mailtrack

More information about the Xenomai mailing list