Added Util::getNTP() to timing library.

This commit is contained in:
Thulinma 2014-05-04 01:25:52 +02:00
parent 54c31922f7
commit 6c54546048
2 changed files with 7 additions and 0 deletions

View file

@ -35,6 +35,12 @@ void Util::sleep(int ms){
nanosleep( &T, 0); nanosleep( &T, 0);
} }
long long Util::getNTP(){
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
return ((((long long int)t.tv_sec) + 2208988800) << 32) + (t.tv_nsec*4.2949);
}
/// Gets the current time in milliseconds. /// Gets the current time in milliseconds.
long long int Util::getMS(){ long long int Util::getMS(){
struct timespec t; struct timespec t;

View file

@ -8,5 +8,6 @@ namespace Util {
long long int getMS(); ///< Gets the current time in milliseconds. long long int getMS(); ///< Gets the current time in milliseconds.
long long unsigned int getMicros();///<Gets the current time in microseconds. long long unsigned int getMicros();///<Gets the current time in microseconds.
long long unsigned int getMicros(long long unsigned int previous);///<Gets the time difference in microseconds. long long unsigned int getMicros(long long unsigned int previous);///<Gets the time difference in microseconds.
long long int getNTP();
long long int epoch(); ///< Gets the amount of seconds since 01/01/1970. long long int epoch(); ///< Gets the amount of seconds since 01/01/1970.
} }