wmp_misc.c
Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *---------------------           RT-WMP              --------------------
00003  *------------------------------------------------------------------------
00004  *                                                         V7.0B  11/05/10
00005  *
00006  *
00007  *  File: ./src/platforms/MaRTE_OS/wmp_misc.c
00008  *  Authors: Danilo Tardioli
00009  *  ----------------------------------------------------------------------
00010  *  Copyright (C) 2000-2010, Universidad de Zaragoza, SPAIN
00011  *
00012  *  Contact Addresses: Danilo Tardioli                   dantard@unizar.es
00013  *
00014  *  RT-WMP is free software; you can  redistribute it and/or  modify it
00015  *  under the terms of the GNU General Public License  as published by the
00016  *  Free Software Foundation;  either  version 2, or (at  your option) any
00017  *  later version.
00018  *
00019  *  RT-WMP  is distributed  in the  hope  that  it will be   useful, but
00020  *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
00021  *  MERCHANTABILITY  or  FITNESS FOR A  PARTICULAR PURPOSE.    See the GNU
00022  *  General Public License for more details.
00023  *
00024  *  You should have received  a  copy of  the  GNU General Public  License
00025  *  distributed with RT-WMP;  see file COPYING.   If not,  write to the
00026  *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
00027  *  02111-1307, USA.
00028  *
00029  *  As a  special exception, if you  link this  unit  with other  files to
00030  *  produce an   executable,   this unit  does  not  by  itself cause  the
00031  *  resulting executable to be covered by the  GNU General Public License.
00032  *  This exception does  not however invalidate  any other reasons why the
00033  *  executable file might be covered by the GNU Public License.
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 


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Fri Jan 3 2014 12:07:56