On 9/21/2020 11:58 AM, Richard Cochran wrote:
> The PTP time scale is TAI, and a PTP GM needs to provide it.  However, most
> GPS devices only provide UTC time of day information, and they do not, in
> general, offer any kind of reliable, standardized leap seconds data.  After
> all, this information is only broadcast every 12.5 minutes through the GPS
> network, and that is far too long for a PTP GM to wait after startup.
> 
> This patch allows the built in leap seconds table to be overridden by an
> up to date file provided in the environment.
> 
> Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
> ---
>  config.c             | 1 +
>  ts2phc.8             | 8 ++++++++
>  ts2phc_nmea_master.c | 2 +-
>  3 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/config.c b/config.c
> index d3446b4..d237de9 100644
> --- a/config.c
> +++ b/config.c
> @@ -260,6 +260,7 @@ struct config_item config_tab[] = {
>       PORT_ITEM_INT("inhibit_multicast_service", 0, 0, 1),
>       GLOB_ITEM_INT("initial_delay", 0, 0, INT_MAX),
>       GLOB_ITEM_INT("kernel_leap", 1, 0, 1),
> +     GLOB_ITEM_STR("leapfile", NULL),
>       PORT_ITEM_INT("logAnnounceInterval", 1, INT8_MIN, INT8_MAX),
>       PORT_ITEM_INT("logMinDelayReqInterval", 0, INT8_MIN, INT8_MAX),
>       PORT_ITEM_INT("logMinPdelayReqInterval", 0, INT8_MIN, INT8_MAX),
> diff --git a/ts2phc.8 b/ts2phc.8
> index 07a4026..77f8940 100644
> --- a/ts2phc.8
> +++ b/ts2phc.8
> @@ -116,6 +116,14 @@ This option can be useful in test scenarios, for example 
> to determine
>  how well synchronized a group of local clocks are to each other.
>  The default is 0 (adjust the slave clocks).
>  .TP
> +.B leapfile
> +The path to the current leap seconds definition file.
> +In a Debian system this file is provided by the tzdata package and can
> +be found at /usr/share/zoneinfo/leap-seconds.list.
> +The default is an empty string, which causes the program to use a hard
> +coded table that reflects the known leap seconds on the date of the
> +software's release.
> +.TP
>  .B logging_level
>  The maximum logging level of messages which should be printed.
>  The default is 6 (LOG_INFO).
> diff --git a/ts2phc_nmea_master.c b/ts2phc_nmea_master.c
> index b8f7014..76fc7ae 100644
> --- a/ts2phc_nmea_master.c
> +++ b/ts2phc_nmea_master.c
> @@ -210,8 +210,8 @@ static int ts2phc_nmea_master_getppstime(struct 
> ts2phc_master *master,
>  
>  struct ts2phc_master *ts2phc_nmea_master_create(struct config *cfg, const 
> char *dev)
>  {
> +     const char *leapfile = config_get_string(cfg, NULL, "leapfile");
>       struct ts2phc_nmea_master *master;
> -     const char *leapfile = NULL;    // TODO - read from config.
>       int err;
>  

Hah, all of the code to read leapfiles is here, but just wasn't exposed yet.

Nice to see this!

Thanks,
Jake

>       master = calloc(1, sizeof(*master));
> 


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to