comparison core/Clock.cpp @ 136:772dbb57442b ClockSync

Implemented xenomai version of Clock
author Giulio Moro <giuliomoro@yahoo.it>
date Sun, 13 Sep 2015 21:26:38 +0100
parents e77e2e712fbc
children
comparison
equal deleted inserted replaced
135:e77e2e712fbc 136:772dbb57442b
1 #include "Clock.h" 1 #include "Clock.h"
2 2
3 namespace Clock 3 namespace Clock
4 { 4 {
5 myClock_t getTimeUs(){ 5 #ifdef USE_JUCE
6 struct timeval tv; 6 myClock_t getTimeUs(){
7 struct timezone tz; 7 struct timeval tv;
8 int ret=gettimeofday(&tv, &tz); 8 struct timezone tz;
9 if(ret == -1){ 9 int ret=gettimeofday(&tv, &tz);
10 printf("Error while getting time of the day\n"); 10 if(ret == -1){
11 return -1; 11 printf("Error while getting time of the day\n");
12 } 12 return -1;
13 myClock_t time=tv.tv_usec + tv.tv_sec*1e6; 13 }
14 // printf("Time is: %.6f\n", time/1000000.0); 14 myClock_t time=tv.tv_usec + tv.tv_sec*1e6;
15 // printf("Time is: %lld\n", time); 15 // printf("Time is: %.6f\n", time/1000000.0);
16 return time; 16 // printf("Time is: %lld\n", time);
17 } 17 return time;
18 }
19 #else
20 myClock_t getTimeUs(){
21 return (myClock_t)((rt_timer_read()+500)/1000);
22 }
23 #endif /* USE_JUCE */
18 }; 24 };