Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "config/compiler.h"
00038 #include <sys/time.h>
00039 #include <time.h>
00040 #include <unistd.h>
00041 #include <stdio.h>
00042 #include "core/include/wmp_misc.h"
00043
00044
00045 static unsigned long long timeZero=0;
00046 static int initialized=0;
00047
00048 unsigned long long getActualTimems(){
00049 struct timeval tv;
00050 gettimeofday(&tv,NULL);
00051 unsigned long long tmp=(tv.tv_sec)*1000000LL;
00052 tmp+=tv.tv_usec;
00053 tmp=tmp-timeZero;
00054 tmp=(unsigned long long) ((double)tmp/1000.0);
00055 return tmp;
00056 }
00057
00058 unsigned long long getActualTimeus(){
00059 if (!initialized) {
00060 initialized=1;
00061 struct timeval tv;
00062 gettimeofday(&tv,0);
00063 unsigned long long tmp=(tv.tv_sec)*1000000LL;
00064 tmp+=tv.tv_usec;
00065 timeZero=tmp;
00066 }
00067 struct timeval tv;
00068 gettimeofday(&tv,0);
00069 unsigned long long tmp=(tv.tv_sec)*1000000LL;
00070 tmp+=tv.tv_usec;
00071 tmp=tmp-timeZero;
00072 return tmp;
00073
00074 }
00075
00076 void mssleep(int ms){
00077 struct timespec ts;
00078
00079 ts.tv_sec = 0;
00080 ts.tv_nsec = ms*1000*1000;
00081 nanosleep (&ts, NULL);
00082 }
00083
00084 void ussleep(int us){
00085 struct timespec ts;
00086
00087 ts.tv_sec = 0;
00088 ts.tv_nsec = us*1000;
00089 nanosleep (&ts, NULL);
00090 }
00091
00092 unsigned long long getActualDateus(){
00093 unsigned long long timer=0;
00094 struct timeval tv;
00095 gettimeofday(&tv,0);
00096 unsigned long long tmp=(tv.tv_sec)*1000000LL;
00097 tmp+=tv.tv_usec;
00098 return tmp;
00099 }
00100
00101 unsigned long long getRawActualTimeus() {
00102 struct timeval tv;
00103 gettimeofday(&tv, 0);
00104 unsigned long long tim1=tv.tv_sec;
00105 tim1*=1000000;
00106 tim1+=tv.tv_usec;
00107 return tim1;
00108 }
00109
00110 typedef void (*sighandler_t)(int);
00111 sighandler_t signal(int signum, sighandler_t handler){
00112 WMP_MSG(stderr,"*** WARNING *** signal not yet implemented in MaRTE_OS\n");
00113 }
00114
00115 #include <time.h>
00116 void wmp_get_timestamp(char *timecad)
00117 {
00118 char buffer[30];
00119 struct timeval tv;
00120 time_t curtime;
00121 struct tm *t;
00122 gettimeofday(&tv, NULL);
00123 curtime = tv.tv_sec;
00124 t = localtime(&curtime);
00125 sprintf(timecad, "%02d%02d", t->tm_hour, t->tm_min);
00126 }
00127
00128 int system(char * txt){
00129 fprintf(stderr,"*** Function 'system' not implemented in MaRTE_OS\n*** Unable to execute %s\n",txt);
00130 return 0;
00131 }
00132