Category:EmbeddedLinux - Time Sample

From Digi Developer

Jump to: navigation, search


Contents

Time Program for EmbeddedLinux

EmbeddedLinux Time Sample (For Digi EmbeddedLinux 5.x modules) This example Demonstrates how to get time with the Digi EmbeddedLinux modules.


Test Files

This sample program contains one file. The main function is in main.c.


EmbeddedLinux Time Program Test Sample Application

The EmbeddedLinux Time Test sample application can be found here: Media:Time_del_sample.zip


Basic Usage

Compile, load and run application.


Sample of main.c file:

/*
 * main.c
 *
 *  Created on: Jan 9, 2012
 *      Author: athomas
 */
 
 
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
 
int main()
{
	struct timeval tv;
	while(1)
	{
		if(gettimeofday(&tv,NULL) != 0)
			perror("Gettime Error\n");
		printf("gettimeofday() Seconds : %ld , Microseconds : %ld\n",tv.tv_sec,tv.tv_usec);
		sleep(1);
	}
	return 0;
}

Subcategories

There is one subcategory to this category.

E

Personal tools
Wiki Editing