From 3464c9cfb4f6300dd24b8ce0713dbb8ad85a0f9c Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Fri, 28 Sep 2012 11:45:54 -0700 Subject: [PATCH] ptp4l: add servo selection to the configuration file this patch adds the servo selection to the configuration file Signed-off-by: Jacob Keller --- config.c | 7 +++++++ config.h | 4 ++++ ptp4l.c | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 2c66d6b..79341b6 100644 --- a/config.c +++ b/config.c @@ -303,6 +303,13 @@ static void scan_global_line(const char *s, struct config *cfg) cfg->transport = TRANS_IEEE_802_3; } + + } else if (1 == sscanf(s, " clock_servo %1023s", string)) { + + if (0 == strcasecmp("pi", string)) + + cfg->clock_servo = CLOCK_SERVO_PI; + } } diff --git a/config.h b/config.h index 7c52225..9691478 100644 --- a/config.h +++ b/config.h @@ -23,6 +23,7 @@ #include "ds.h" #include "dm.h" #include "transport.h" +#include "servo.h" #define MAX_PORTS 8 #define MAX_IFNAME_SIZE 16 @@ -60,6 +61,9 @@ struct config { int *assume_two_step; int *tx_timestamp_retries; int *rx_timestamp_l2only; + + enum servo_type clock_servo; + double *pi_proportional_const; double *pi_integral_const; unsigned char *ptp_dst_mac; diff --git a/ptp4l.c b/ptp4l.c index b35f559..7a2ef61 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -65,6 +65,9 @@ static struct config cfg_settings = { .assume_two_step = &assume_two_step, .tx_timestamp_retries = &sk_tx_retries, .rx_timestamp_l2only = &sk_prefer_layer2, + + .clock_servo = CLOCK_SERVO_PI, + .pi_proportional_const = &configured_pi_kp, .pi_integral_const = &configured_pi_ki, .ptp_dst_mac = ptp_dst_mac, @@ -272,7 +275,7 @@ int main(int argc, char *argv[]) } clock = clock_create(phc_index, iface, cfg_settings.nports, - *timestamping, ds, CLOCK_SERVO_PI); + *timestamping, ds, cfg_settings.clock_servo); if (!clock) { fprintf(stderr, "failed to create a clock\n"); return -1;