Changeset 202 in flair-src


Ignore:
Timestamp:
Nov 2, 2017, 3:04:47 PM (4 years ago)
Author:
Sanahuja Guillaume
Message:

modifs usleep

Location:
trunk/lib
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/Thread.cpp

    r139 r202  
    9191  if (status != 0) {
    9292                char errorMsg[256];
    93     Err("%s, error rt_task_sleep_until (%s), resume time: %lld, actual time: "
    94         "%lld\n", ObjectName().c_str(), strerror_r(-status, errorMsg, sizeof(errorMsg)), time, GetTime());
     93    Err("%error rt_task_sleep_until (%s), resume time: %lld, actual time: "
     94        "%lld\n",strerror_r(-status, errorMsg, sizeof(errorMsg)), time, GetTime());
    9595        }
    9696// Printf("rt_task_sleep_until, resume time: %lld, actual time:
     
    9999  Time current = GetTime();
    100100  if (current < time) {
    101     usleep((time - current) / 1000);
     101    //usleep((time - current) / 1000);
     102    struct timespec req;
     103    req.tv_nsec = time - current;
     104    req.tv_sec = req.tv_nsec / 1000000000;
     105    req.tv_nsec %= 1000000000;
     106    struct timespec rem;
     107    if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
     108  } else {
     109    Err("error resume time is passed by %lldns\n", ( current-time));
    102110  }
    103111#endif
     
    112120        }
    113121#else
    114   usleep(time * 1000);
     122  //usleep(time * 1000);
     123  struct timespec req;
     124  req.tv_nsec = time * 1000000;
     125  req.tv_sec = req.tv_nsec / 1000000000;
     126  req.tv_nsec %= 1000000000;
     127  struct timespec rem;
     128  if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
    115129#endif
    116130}
     
    124138        }
    125139#else
    126   usleep(time);
     140  //usleep(time);
     141  struct timespec req;
     142  req.tv_nsec = time * 1000;
     143  req.tv_sec = req.tv_nsec / 1000000000;
     144  req.tv_nsec %= 1000000000;
     145  struct timespec rem;
     146  if(nanosleep(&req,&rem)!=0) Err("error in nanosleep\n");//todo, handle EINTR
    127147#endif
    128148}
  • trunk/lib/FlairCore/src/Thread_impl.cpp

    r186 r202  
    232232#else
    233233  self->SleepUntil(next_time);
    234   next_time += period;
     234  Time current = GetTime();
     235  if(current>next_time+period) self->Err("overrun of %lld\n", current-next_time);
     236  while (next_time < current) {
     237    next_time += period;
     238  }
    235239#endif
    236240  ComputeLatency(GetTime());
     
    326330  if(last!=0)
    327331#endif
    328     { Printf("Thread::%s :\n", self->ObjectName().c_str()); }
     332    { Printf("Thread::%s :\n", self->ObjectName().c_str());
     333    if(period_set) {Printf("    period (ns): %lld\n", period);}}
    329334#ifdef __XENO__
    330335    Printf("    number of context switches: %i\n", info.ctxswitches);
     
    349354      Printf("    max latency (ns): %lld\n", max_latency);
    350355      Printf("    latency moy (ns): %lld\n", mean_latency / cpt);
    351       Printf("    itertions: %lld\n", cpt);
     356      Printf("    iterations: %lld\n", cpt);
    352357    }
    353358  }
  • trunk/lib/FlairSensorActuator/src/EmulatedController.cpp

    r178 r202  
    1919#include <cvmatrix.h>
    2020#include <stdexcept>
    21 
    22 #include <unistd.h> // for sleep (debug)
    2321
    2422using namespace flair::core;
  • trunk/lib/FlairSensorActuator/src/SimuImu.cpp

    r198 r202  
    3434namespace sensor {
    3535
     36//Construct a SimuImu. Control part.
    3637SimuImu::SimuImu(string name, uint32_t modelId,uint32_t deviceId,
    3738                 uint8_t priority)
     
    4647}
    4748
     49//Construct a SimuImu. Simulation part.
    4850SimuImu::SimuImu(const IODevice *parent, string name, uint32_t modelId,uint32_t deviceId)
    4951    : Imu(parent,name), Thread(parent, name, 0) {
     
    109111      SetPeriodUS((uint32_t)(1000000. / dataRate->Value()));
    110112    }
    111 
    112113    shmem->Read((char *)&state, sizeof(imu_states_t));
    113    
    114     Quaternion  quaternion(state.q0, state.q1, state.q2, state.q3);
     114    Quaternion quaternion(state.q0, state.q1, state.q2, state.q3);
    115115    Vector3Df angRate(state.wx, state.wy, state.wz);
    116116    Vector3Df rawAcc(state.ax, state.ay, state.az);
     
    128128    imuData->SetDataTime(GetTime());
    129129    ahrsData->SetDataTime(GetTime());
    130 
    131130    ProcessUpdate(ahrsData);
    132131  }
  • trunk/lib/FlairSensorActuator/src/TargetController.cpp

    r186 r202  
    2424#include <cstring>
    2525#include <string>
    26 
    27 #include <unistd.h> //for usleep
    2826
    2927using namespace flair::core;
  • trunk/lib/FlairSensorActuator/src/TargetEthController.cpp

    r178 r202  
    2727#include <stdexcept>
    2828
    29 #include <unistd.h> // for sleep (debug)
    30 
    3129using namespace flair::core;
    3230using namespace flair::gui;
  • trunk/lib/FlairSimulator/src/Model_impl.cpp

    r186 r202  
    5454Model_impl::Model_impl(Model *self, std::string name,uint32_t modelId)
    5555    : ISceneNode(getGui()->getSceneManager()->getRootSceneNode(), getGui()->getSceneManager(), -1),
    56       Thread(self, name, 50), vrpn_Tracker(name.c_str(), getSimulator()->pimpl_)
     56      Thread(self, name, 99), vrpn_Tracker(name.c_str(), getSimulator()->pimpl_)
    5757
    5858#else
    5959Model_impl::Model_impl(Model *self, std::string name,uint32_t modelId)
    60     : Thread(self, name, 50), vrpn_Tracker(name.c_str(), getSimulator()->pimpl_)
     60    : Thread(self, name, 99), vrpn_Tracker(name.c_str(), getSimulator()->pimpl_)
    6161#endif
    6262{
Note: See TracChangeset for help on using the changeset viewer.