phc2sys: remove useless option.

The 'rdelay' option has been obsoleted by the newer read_phc() logic.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-09-25 20:03:04 +02:00
parent 0ff2d47d61
commit 99d7c128a1
1 changed files with 6 additions and 10 deletions

View File

@ -85,7 +85,8 @@ static void clock_step(clockid_t clkid, int64_t ns)
fprintf(stderr, "failed to step clock: %m\n"); fprintf(stderr, "failed to step clock: %m\n");
} }
static int read_phc(clockid_t clkid, clockid_t sysclk, int rdelay, int readings, int64_t *offset, uint64_t *ts) static int read_phc(clockid_t clkid, clockid_t sysclk, int readings,
int64_t *offset, uint64_t *ts)
{ {
struct timespec tdst1, tdst2, tsrc; struct timespec tdst1, tdst2, tsrc;
int i; int i;
@ -106,8 +107,7 @@ static int read_phc(clockid_t clkid, clockid_t sysclk, int rdelay, int readings,
if (best_interval > interval) { if (best_interval > interval) {
best_interval = interval; best_interval = interval;
*offset = (tdst1.tv_sec - tsrc.tv_sec) * NS_PER_SEC + *offset = (tdst1.tv_sec - tsrc.tv_sec) * NS_PER_SEC +
tdst1.tv_nsec - tsrc.tv_nsec + tdst1.tv_nsec - tsrc.tv_nsec + interval / 2;
interval / 2 - rdelay;
*ts = tdst2.tv_sec * NS_PER_SEC + tdst2.tv_nsec; *ts = tdst2.tv_sec * NS_PER_SEC + tdst2.tv_nsec;
} }
} }
@ -199,7 +199,6 @@ static void usage(char *progname)
" -c [device] slave clock device, default CLOCK_REALTIME\n" " -c [device] slave clock device, default CLOCK_REALTIME\n"
" -d [device] master device, source of PPS events\n" " -d [device] master device, source of PPS events\n"
" -h prints this message and exits\n" " -h prints this message and exits\n"
" -r [val] reading the PHC device takes 'val' nanoseconds\n"
" -s [device] set the time from this PHC device\n" " -s [device] set the time from this PHC device\n"
" -P [val] set proportional constant to 'val'\n" " -P [val] set proportional constant to 'val'\n"
" -I [val] set integration constant to 'val'\n" " -I [val] set integration constant to 'val'\n"
@ -216,12 +215,12 @@ int main(int argc, char *argv[])
clockid_t src = CLOCK_INVALID, dst = CLOCK_REALTIME; clockid_t src = CLOCK_INVALID, dst = CLOCK_REALTIME;
uint64_t pps_ts, phc_ts; uint64_t pps_ts, phc_ts;
int64_t pps_offset, phc_offset; int64_t pps_offset, phc_offset;
int c, fd = 0, rdelay = 0, phc_readings = 5, phc_rate = 1; int c, fd = 0, phc_readings = 5, phc_rate = 1;
/* Process the command line arguments. */ /* Process the command line arguments. */
progname = strrchr(argv[0], '/'); progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0]; progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv, "c:d:hr:s:P:I:R:N:"))) { while (EOF != (c = getopt(argc, argv, "c:d:hs:P:I:R:N:"))) {
switch (c) { switch (c) {
case 'c': case 'c':
dst = clock_open(optarg); dst = clock_open(optarg);
@ -229,9 +228,6 @@ int main(int argc, char *argv[])
case 'd': case 'd':
device = optarg; device = optarg;
break; break;
case 'r':
rdelay = atoi(optarg);
break;
case 's': case 's':
src = clock_open(optarg); src = clock_open(optarg);
break; break;
@ -283,7 +279,7 @@ int main(int argc, char *argv[])
usleep(1000000 / phc_rate); usleep(1000000 / phc_rate);
if (src != CLOCK_INVALID) { if (src != CLOCK_INVALID) {
if (!read_phc(src, dst, rdelay, phc_readings, &phc_offset, &phc_ts)) if (!read_phc(src, dst, phc_readings, &phc_offset, &phc_ts))
continue; continue;
printf("phc %9lld ", phc_offset); printf("phc %9lld ", phc_offset);
} }