Current implementation requires specifying the -s argument for PPS
sources that don't provide ToD information and for GNSS modules.

Add ts2phc.tod_source config option to enable specifying the source
in the config file. Currently only "generic" and "nmea" options
are allowed.

Signed-off-by: Maciek Machnikowski <mac...@machnikowski.net>
---
 config.c |  1 +
 ts2phc.8 |  8 ++++++++
 ts2phc.c | 12 ++++++++++++
 3 files changed, 21 insertions(+)

diff --git a/config.c b/config.c
index e454c91..33176f4 100644
--- a/config.c
+++ b/config.c
@@ -330,6 +330,7 @@ struct config_item config_tab[] = {
        PORT_ITEM_INT("ts2phc.perout_phase", -1, 0, 999999999),
        PORT_ITEM_INT("ts2phc.pin_index", 0, 0, INT_MAX),
        GLOB_ITEM_INT("ts2phc.pulsewidth", 500000000, 1000000, 999000000),
+       GLOB_ITEM_STR("ts2phc.tod_source", ""),
        PORT_ITEM_ENU("tsproc_mode", TSPROC_FILTER, tsproc_enu),
        GLOB_ITEM_INT("twoStepFlag", 1, 0, 1),
        GLOB_ITEM_INT("tx_timestamp_timeout", 10, 1, INT_MAX),
diff --git a/ts2phc.8 b/ts2phc.8
index ded6f9a..208027e 100644
--- a/ts2phc.8
+++ b/ts2phc.8
@@ -160,6 +160,14 @@ by changing the clock frequency instead of stepping the 
clock. When
 set to 0.0, the servo will never step the clock except on start.
 The default is 0.0.
 .TP
+.B ts2phc.tod_source
+Specifies the source of the Time of Day information when not specifying
+any PPS source.
+Use the key word "generic" for an external 1-PPS without ToD information
+and use the system time's ToD information.
+Use the key word "nmea" for an external 1-PPS from a GNSS providing ToD
+information via the RMC NMEA sentence.
+.TP
 .B ts2phc.nmea_remote_host, ts2phc.nmea_remote_port
 Specifies the remote host providing ToD information when using the
 "nmea" PPS signal source.  Note that if these two options are both
diff --git a/ts2phc.c b/ts2phc.c
index f7a57e4..458406a 100644
--- a/ts2phc.c
+++ b/ts2phc.c
@@ -714,6 +714,18 @@ int main(int argc, char *argv[])
                usage(progname);
                return -1;
        }
+
+       if (!pps_source) {
+               pps_source = config_get_string(cfg, NULL, "ts2phc.tod_source");
+               if (pps_source && strcasecmp(pps_source, "generic") &&
+                   strcasecmp(pps_source, "nmea")) {
+                       fprintf(stderr, "%s ToD source in config file is 
invalid\n",
+                               pps_source);
+                       ts2phc_cleanup(&priv);
+                       return -1;
+               }
+       }
+
        if (!pps_source) {
                fprintf(stderr, "no PPS source specified\n");
                ts2phc_cleanup(&priv);
-- 
2.37.0 (Apple Git-136)



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

Reply via email to