Browse Source

Removes OFFSETASSERT requirement from ppstest and ppsctl.

There was a bizarre and undocumented 675ns offset being applied by
ppstest.  Any PPS offset is highly system-specific and doesn't belong
as a hardcoded constant in an application program.  In addition, at
least one PPS driver (pps-gmtimer) doesn't support OFFSETASSERT
(mainly as a defense against misguided programs such as this one), and
was unusable with ppstest due to the insistence of OFFSETASSERT.

This change:

1) Removes the OFFSETASSERT requirement from ppstest.

2) If the OFFSETASSERT capability exists, ppstest now uses it to clear
the offset, undoing any lingering offset from the old version.

3) Removes the OFFSETASSERT requirement from ppsctl.

TESTED:
Built and ran ppstest against both pps-gpio and pps-gmtimer on a
Beaglebone Black.
Built ppsctl.
tags/v1.0.1
Fred Wright Alexander Gerasiov 3 years ago
parent
commit
c746f3ae1d
2 changed files with 9 additions and 13 deletions
  1. +0
    -4
      ppsctl.c
  2. +9
    -9
      ppstest.c

+ 0
- 4
ppsctl.c View File

@@ -69,10 +69,6 @@ static int find_source(char *path, pps_handle_t *handle, int *avail_mode)
fprintf(stderr, "cannot CAPTUREASSERT\n");
return -1;
}
if ((*avail_mode & PPS_OFFSETASSERT) == 0) {
fprintf(stderr, "cannot OFFSETASSERT\n");
return -1;
}

return 0;
}


+ 9
- 9
ppstest.c View File

@@ -23,6 +23,8 @@

#include "timepps.h"

static struct timespec offset_assert = {0, 0};

int find_source(char *path, pps_handle_t *handle, int *avail_mode)
{
pps_params_t params;
@@ -56,21 +58,19 @@ int find_source(char *path, pps_handle_t *handle, int *avail_mode)
fprintf(stderr, "cannot CAPTUREASSERT\n");
return -1;
}
if ((*avail_mode & PPS_OFFSETASSERT) == 0) {
fprintf(stderr, "cannot OFFSETASSERT\n");
return -1;
}

/* Capture assert timestamps, and compensate for a 675 nsec
* propagation delay */
/* Capture assert timestamps */
ret = time_pps_getparams(*handle, &params);
if (ret < 0) {
fprintf(stderr, "cannot get parameters (%m)\n");
return -1;
}
params.assert_offset.tv_sec = 0;
params.assert_offset.tv_nsec = 675;
params.mode |= PPS_CAPTUREASSERT | PPS_OFFSETASSERT;
params.mode |= PPS_CAPTUREASSERT;
/* Override any previous offset if possible */
if ((*avail_mode & PPS_OFFSETASSERT) != 0) {
params.mode |= PPS_OFFSETASSERT;
params.assert_offset = offset_assert;
}
ret = time_pps_setparams(*handle, &params);
if (ret < 0) {
fprintf(stderr, "cannot set parameters (%m)\n");


Loading…
Cancel
Save