    #include <stdio.h>
    #include <stdlib.h>
    #include <errno.h>
    #include <time.h>
    #include <sys/types.h>
    #include <sys/ipc.h>
    #include <sys/msg.h>
    #include "gps.h"

    int main(void)
    {
        struct gps_msgbuf buf;
        int msqid;
        key_t key;
	suseconds_t time_delta;	
        struct timeval now;

	time_delta = 1000000;

	buf.mtype = GPS_MSGTYPE;        

        if ((key = ftok("compute.c", 'A')) == -1) {
            perror("ftok");
            exit(1);
            }

	key = 1;
        if ((msqid = msgget(key, 0644 | IPC_CREAT)) == -1) {
            perror("msgget");
            exit(1);
            }

	while(1)
	  {
	  buf.lat = 38.0;
          buf.lon = 122.0;
	  buf.elev = 1.1;
	  buf.cog = 235;
	  buf.sog = 4.1;
	  buf.gps_time = 100; 
	  
	  gettimeofday(&now,NULL);
	  buf.time_sec = now.tv_sec;
	  buf.time_usec = now.tv_usec;

          if(msgsnd(msqid, (struct msgbuf *)&buf, sizeof(buf), 0) == -1)
	    {
	    perror("ERROR: can't send GPS message\n");
            }
	  usleep(time_delta);
	  }


        if (msgctl(msqid, IPC_RMID, NULL) == -1) {
            perror("msgctl");
            exit(1);
        }

        return 0;
    }
