#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <sys/time.h>
#include <errno.h>
static int willExit = 0;
{
char buf[50];
buf[0] = '\0';
printf("%s: failed, stat=%d (%s)\n", id, (int)stat, buf);
}
}
static void printUsageAndExit(char *prgName)
{
printf("Usage: '%s <channel>'\n", prgName);
exit(1);
}
static void sighand(int sig)
{
(void)sig;
willExit = 1;
}
int main(int argc, char *argv[])
{
unsigned long time, last = 0, lastsys = 0;
struct timeval tv;
int channel;
if (argc != 2) {
printUsageAndExit(argv[0]);
}
{
char *endPtr = NULL;
errno = 0;
channel = strtol(argv[1], &endPtr, 10);
if ( (errno != 0) || ((channel == 0) && (endPtr == argv[1])) ) {
printUsageAndExit(argv[0]);
}
}
signal(SIGINT, sighand);
siginterrupt(SIGINT, 1);
if (hnd < 0) {
printf("canOpenChannel %d", channel);
check("", hnd);
return -1;
}
while (!willExit) {
check("canReadTimer", stat);
break;
}
printf("Time=%lu ms (%lu)\n", time, time - last);
gettimeofday(&tv, NULL);
printf("system:%lu\n", tv.tv_sec * 1000 + tv.tv_usec / 1000 - lastsys);
last = time;
lastsys = tv.tv_sec * 1000 + tv.tv_usec / 1000;
sleep(1);
}
check("canUnloadLibrary", stat);
return -1;
}
return 0;
}