What is the relation between the Gryphon timestamp and real time?

Gryphon time is the number of 10-microsecond units since midnight, January 1, 1970. This time is kept internally in the Gryphon as a 64-bit (long) number.

Gryphon data frames report the least significant 32-bits of this 64-bit time in the data frames' timestamp field.

The complete 64-bit time value may be retrieved from the Gryphon at any time by means of the CMD_GET_TIME GCProtocol command. If a client application needs to keep track of the entire 64-bit time value of data messages, the most significant 32-bits may be tracked by means of the CMD_GET_TIME command and combined with the least significant 32-bits contained in the data message's time stamp (the most significant 32-bits will change approximately once per twelve hours).

Clients running locally on the Gryphon hardware may also retrieve this 64-bit current timestamp by means of the gettimeofday() system call. The value returned is the same as by CMD_GET_TIME. Use of gettimeofday() can be used to retrieve the Gryphon timestamp ONLY when code is running locally on the Gryphon hardware; for all other clients, CMD_GET_TIME is the recommended method of timestamp retrieval.

Timestamps acquired by either of the above method may be converted to ASCII strings by means of the Unix library function ctime(). This function accepts as an argument the number of seconds since the 1970 epoch, which can be obtained by dividing the 64-bit Gryphon timestamp by 100,000.

The example below demonstrates acquisition of 64-bit and 32-bit timestamps by means of the gettimeofday() function and printing of ASCII values by means of ctime(). Similar code can be used with the 64-bit timestamp returned by the CMD_GET_TIME GCProtocol command (code will vary depending on the client's method of implementation of this remote command).

Example:


#include <sys/time.h> 
#include <unistd.h> 
#include <stdio.h> 
#include <time.h> 
int main() 
{ 
struct timeval tv; 
unsigned long long ull; 
unsigned long ul; 
time_t tt;                   /* time_t is just an integer type of some sort */ 

if(gettimeofday(&tv,NULL)) 
        { 
        perror("gettimeofday"); 
        exit(1); 
        }; 

ull=((unsigned long long)(tv.tv_sec))*((unsigned long long)100000); 
ull+=((unsigned long long)(tv.tv_usec/10)); 

printf("64 bit gryphon time: %llu decimal, 0x%llx hex\n",ull,ull); 

ul=(tv.tv_sec*100000)+(tv.tv_usec/10); 

printf("32 bit gryphon time: %lu decimal, 0x%lx hex\n",ul,ul); 

/* note ull has been obtained with gettimeofday(2), but it could have */ 
/* been obtained with a gryphon CMD_GET_TIME and this would still work: */ 

tt=(ull/((unsigned long long)100000)); 

printf("human readable time: %s\n",ctime(&tt)); 

return(0); 
} 


Note: It is suggested to use the 'CMD_GET_TIME' function instead of 
'gettimeofday()' so that the code can run on a client machine instead 
of just on the Gryphon locally. 


This document was obtained from:

Dearborn Group, Inc.
(248) 488-2080
dg@dgtech.com
http://www.dgtech.com

Copyright © 2003 Dearborn Group Inc.