config: convert the 'step_threshold' option to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
28fbc390f6
commit
df578135d3
21
config.c
21
config.c
|
@ -61,6 +61,14 @@ struct config_item {
|
|||
|
||||
#define N_CONFIG_ITEMS (sizeof(config_tab) / sizeof(config_tab[0]))
|
||||
|
||||
#define CONFIG_ITEM_DBL(_label, _port, _default, _min, _max) { \
|
||||
.label = _label, \
|
||||
.type = CFG_TYPE_DOUBLE, \
|
||||
.flags = _port ? CFG_ITEM_PORT : 0, \
|
||||
.val.d = _default, \
|
||||
.min.d = _min, \
|
||||
.max.d = _max, \
|
||||
}
|
||||
#define CONFIG_ITEM_INT(_label, _port, _default, _min, _max) { \
|
||||
.label = _label, \
|
||||
.type = CFG_TYPE_INT, \
|
||||
|
@ -70,15 +78,22 @@ struct config_item {
|
|||
.max.i = _max, \
|
||||
}
|
||||
|
||||
#define GLOB_ITEM_DBL(label, _default, min, max) \
|
||||
CONFIG_ITEM_DBL(label, 0, _default, min, max)
|
||||
|
||||
#define GLOB_ITEM_INT(label, _default, min, max) \
|
||||
CONFIG_ITEM_INT(label, 0, _default, min, max)
|
||||
|
||||
#define PORT_ITEM_DBL(label, _default, min, max) \
|
||||
CONFIG_ITEM_DBL(label, 1, _default, min, max)
|
||||
|
||||
#define PORT_ITEM_INT(label, _default, min, max) \
|
||||
CONFIG_ITEM_INT(label, 1, _default, min, max)
|
||||
|
||||
struct config_item config_tab[] = {
|
||||
GLOB_ITEM_INT("assume_two_step", 0, 0, 1),
|
||||
GLOB_ITEM_INT("check_fup_sync", 0, 0, 1),
|
||||
GLOB_ITEM_DBL("step_threshold", 0.0, 0.0, DBL_MAX),
|
||||
GLOB_ITEM_INT("tx_timestamp_timeout", 1, 1, INT_MAX),
|
||||
PORT_ITEM_INT("udp_ttl", 1, 1, 255),
|
||||
};
|
||||
|
@ -569,12 +584,6 @@ static enum parser_result parse_global_setting(const char *option,
|
|||
return r;
|
||||
*cfg->pi_integral_norm_max = df;
|
||||
|
||||
} else if (!strcmp(option, "step_threshold")) {
|
||||
r = get_ranged_double(value, &df, 0.0, DBL_MAX);
|
||||
if (r != PARSED_OK)
|
||||
return r;
|
||||
*cfg->step_threshold = df;
|
||||
|
||||
} else if (!strcmp(option, "first_step_threshold")) {
|
||||
r = get_ranged_double(value, &df, 0.0, DBL_MAX);
|
||||
if (r != PARSED_OK)
|
||||
|
|
1
config.h
1
config.h
|
@ -72,7 +72,6 @@ struct config {
|
|||
struct port_defaults pod;
|
||||
enum servo_type clock_servo;
|
||||
|
||||
double *step_threshold;
|
||||
double *first_step_threshold;
|
||||
int *max_frequency;
|
||||
|
||||
|
|
|
@ -1222,11 +1222,12 @@ int main(int argc, char *argv[])
|
|||
char *progname;
|
||||
char *src_name = NULL, *dst_name = NULL;
|
||||
struct clock *src, *dst;
|
||||
struct config *cfg;
|
||||
int autocfg = 0, rt = 0;
|
||||
int c, domain_number = 0, pps_fd = -1;
|
||||
int r, wait_sync = 0;
|
||||
int print_level = LOG_INFO, use_syslog = 1, verbose = 0;
|
||||
double phc_rate;
|
||||
double phc_rate, tmp;
|
||||
struct node node = {
|
||||
.sanity_freq_limit = 200000000,
|
||||
.servo_type = CLOCK_SERVO_PI,
|
||||
|
@ -1240,6 +1241,7 @@ int main(int argc, char *argv[])
|
|||
if (config_init(&phc2sys_config)) {
|
||||
return -1;
|
||||
}
|
||||
cfg = &phc2sys_config;
|
||||
|
||||
configured_pi_kp = KP;
|
||||
configured_pi_ki = KI;
|
||||
|
@ -1297,8 +1299,9 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
break;
|
||||
case 'S':
|
||||
if (get_arg_val_d(c, optarg, &servo_step_threshold,
|
||||
0.0, DBL_MAX))
|
||||
if (get_arg_val_d(c, optarg, &tmp, 0.0, DBL_MAX))
|
||||
return -1;
|
||||
if (config_set_double(cfg, "step_threshold", tmp))
|
||||
return -1;
|
||||
break;
|
||||
case 'F':
|
||||
|
|
1
ptp4l.c
1
ptp4l.c
|
@ -103,7 +103,6 @@ static struct config cfg_settings = {
|
|||
.transport = TRANS_UDP_IPV4,
|
||||
.clock_servo = CLOCK_SERVO_PI,
|
||||
|
||||
.step_threshold = &servo_step_threshold,
|
||||
.first_step_threshold = &servo_first_step_threshold,
|
||||
.max_frequency = &servo_max_frequency,
|
||||
|
||||
|
|
4
servo.c
4
servo.c
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "linreg.h"
|
||||
#include "ntpshm.h"
|
||||
#include "nullf.h"
|
||||
|
@ -26,13 +27,13 @@
|
|||
|
||||
#define NSEC_PER_SEC 1000000000
|
||||
|
||||
double servo_step_threshold = 0.0;
|
||||
double servo_first_step_threshold = 0.00002; /* 20 microseconds */
|
||||
int servo_max_frequency = 900000000;
|
||||
|
||||
struct servo *servo_create(struct config *cfg, enum servo_type type,
|
||||
int fadj, int max_ppb, int sw_ts)
|
||||
{
|
||||
double servo_step_threshold;
|
||||
struct servo *servo;
|
||||
|
||||
switch (type) {
|
||||
|
@ -52,6 +53,7 @@ struct servo *servo_create(struct config *cfg, enum servo_type type,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
servo_step_threshold = config_get_double(cfg, NULL, "step_threshold");
|
||||
if (servo_step_threshold > 0.0) {
|
||||
servo->step_threshold = servo_step_threshold * NSEC_PER_SEC;
|
||||
} else {
|
||||
|
|
9
servo.h
9
servo.h
|
@ -24,15 +24,6 @@
|
|||
|
||||
struct config;
|
||||
|
||||
/**
|
||||
* When set to a non-zero value, this variable controls the maximum allowed
|
||||
* offset before a clock jump occurs instead of the default clock-slewing
|
||||
* mechanism.
|
||||
*
|
||||
* Note that this variable is measured in seconds, and allows fractional values.
|
||||
*/
|
||||
extern double servo_step_threshold;
|
||||
|
||||
/**
|
||||
* When set to zero, the clock is not stepped on start. When set to a non-zero
|
||||
* value, the value bahaves as a threshold and the clock is stepped on start if
|
||||
|
|
Loading…
Reference in New Issue