wmp_misc.c
Go to the documentation of this file.
00001 /*------------------------------------------------------------------------
00002  *---------------------           RT-WMP              --------------------
00003  *------------------------------------------------------------------------
00004  *                                                         
00005  *
00006  *
00007  *  File: ./src/platforms/linux_ks/wmp_misc.c
00008  *  Authors: Rubén Durán
00009  *           Danilo Tardioli
00010  *  ----------------------------------------------------------------------
00011  *  Copyright (C) 2000-2011, Universidad de Zaragoza, SPAIN
00012  *
00013  *  Contact Addresses: Danilo Tardioli                   dantard@unizar.es
00014  *
00015  *  RT-WMP is free software; you can  redistribute it and/or  modify it
00016  *  under the terms of the GNU General Public License  as published by the
00017  *  Free Software Foundation;  either  version 2, or (at  your option) any
00018  *  later version.
00019  *
00020  *  RT-WMP  is distributed  in the  hope  that  it will be   useful, but
00021  *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
00022  *  MERCHANTABILITY  or  FITNESS FOR A  PARTICULAR PURPOSE.    See the GNU
00023  *  General Public License for more details.
00024  *
00025  *  You should have received  a  copy of  the  GNU General Public  License
00026  *  distributed with RT-WMP;  see file COPYING.   If not,  write to the
00027  *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
00028  *  02111-1307, USA.
00029  *
00030  *  As a  special exception, if you  link this  unit  with other  files to
00031  *  produce an   executable,   this unit  does  not  by  itself cause  the
00032  *  resulting executable to be covered by the  GNU General Public License.
00033  *  This exception does  not however invalidate  any other reasons why the
00034  *  executable file might be covered by the GNU Public License.
00035  *
00036  *----------------------------------------------------------------------*/
00037 
00038 #include <linux/time.h>
00039 #include <linux/delay.h>
00040 
00041 #include "config/compiler.h"
00042 
00043 #define gettimeofday(p_tv, foo) do_gettimeofday(p_tv)
00044 
00045 unsigned long long timeZero=0;
00046 
00047 
00048 unsigned long getActualTimems(void) {
00049    struct timeval tv;
00050    unsigned long long tmp;
00051    long timer;
00052 
00053         static int initialized = 0;
00054         timer = 0;
00055         if (!initialized) {
00056                 initialized = 1;
00057                 gettimeofday(&tv, 0);
00058                 tmp = (tv.tv_sec) * 1000000LL;
00059                 tmp += tv.tv_usec;
00060                 timeZero = tmp;
00061         }
00062 
00063         gettimeofday(&tv, 0);
00064         tmp = (tv.tv_sec) * 1000000LL;
00065         tmp += tv.tv_usec;
00066         tmp = tmp - timeZero;
00067         tmp = DO_DIV64(tmp, 1000);
00068         return (unsigned long) tmp;
00069 }
00070 
00071 
00072 unsigned long long getActualTimeus(void){
00073    struct timeval tv;
00074    unsigned long long tmp;
00075    long timer;
00076 
00077         static int initialized = 0;
00078         timer=0;
00079         if (!initialized) {
00080                 initialized=1;
00081                 gettimeofday(&tv,0);
00082                 tmp=(tv.tv_sec)*1000000LL;
00083                 tmp+=tv.tv_usec;
00084                 timeZero=tmp;
00085         }
00086 
00087         gettimeofday(&tv,0);
00088         tmp=(tv.tv_sec)*1000000LL;
00089         tmp+=tv.tv_usec;
00090         tmp=tmp-timeZero;
00091         return tmp;
00092 }
00093 
00094 void mssleep(int ms){
00095         msleep(ms);
00096 }
00097 
00098 unsigned long long getActualDateus(void){
00099                 unsigned long long tmp;
00100                 struct timeval tv;
00101                 gettimeofday(&tv,0);
00102                 tmp=(tv.tv_sec)*1000000LL;
00103                 tmp+=tv.tv_usec;
00104                 return tmp;
00105 }
00106 
00107 unsigned long long getRawActualTimeus(void) {
00108    unsigned long long tim1;
00109    struct timeval tv;
00110    gettimeofday(&tv, 0);
00111    tim1=tv.tv_sec;
00112    tim1*=1000000;
00113    tim1+=tv.tv_usec;
00114    return tim1;
00115 }
00116 
00117 
00118 void wmp_get_timestamp(char *timecad){
00119    struct timeval tiempo;
00120    struct tm strtm;
00121    do_gettimeofday(&tiempo);
00122    time_to_tm(tiempo.tv_sec, -60*sys_tz.tz_minuteswest, &strtm);
00123    snprintf(timecad, 80, "%d-%02d-%02d_%02d-%02d",
00124             (int)(strtm.tm_year + 1900),   /* Years since 1900 */
00125             strtm.tm_mon + 1,       /* Range 0 to 11, so we add 1 */
00126             strtm.tm_mday,          /* Day of the month, in the range 1 to 31 */
00127             strtm.tm_hour,
00128             strtm.tm_min);
00129 }
00130 


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