Commit 303c9771 authored by Jean-Claude BAU's avatar Jean-Claude BAU Committed by Adam Wujek

Configuration updates

- Set the minimum and maximum values of some parameters
- Fix format issues in pp_printf and sscanf
parent 6f8bd484
......@@ -54,6 +54,10 @@ typedef struct _UInteger64 { /*/* TODO : Should be replaced by UInteger64 */
#define TIME_INTERVAL_FRACBITS 16
#define TIME_INTERVAL_FRACBITS_AS_FLOAT 16.0
/* Min/max value expressed in picos (int64_t) which can be stored in a TimeInterval type */
#define TIME_INTERVAL_MIN_PICOS_VALUE_AS_INT64 ((int64_t) 0xFE0C000000000000)
#define TIME_INTERVAL_MAX_PICOS_VALUE_AS_INT64 ((int64_t) 0x1F3FFFFFFFFFC18)
typedef Integer64 TimeInterval;
/* White Rabbit extension */
......@@ -70,6 +74,10 @@ typedef struct Timestamp { /* page 13 (33) -- no typedef expected */
#define REL_DIFF_FRACBITS 62
#define REL_DIFF_FRACBITS_AS_FLOAT 62.0
/* Min/max values for RelativeDifference type */
#define RELATIVE_DIFFERENCE_MIN_VALUE_AS_DOUBLE -2.0
#define RELATIVE_DIFFERENCE_MAX_VALUE_AS_DOUBLE 1.9999999999999989
/*draft P1588_v_29: page 17*/
/* The scaledRelativeDifference member is the relative difference expressed
* as a dimensionless fraction and multiplied by 2+^62, with any remaining
......
......@@ -9,6 +9,7 @@
/* This file is built in hosted environments, so following headers are Ok */
#include <stdio.h>
#include <unistd.h>
#include <inttypes.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
......@@ -94,7 +95,7 @@ static inline void ASSIGN_INT64_FIELD(struct pp_argline *l,
/* Check min/max */
if ( v<l->min_max.min.min_int64 || v>l->min_max.max.max_int64 ) {
pp_printf("Parameter %s(%ld) out of range\n", l->keyword, (long)v);\
pp_printf("Parameter %s(%" PRId64 ") out of range\n", l->keyword, v);\
return;
}
*(int64_t *)( dest + l->field_offset) = v;
......@@ -325,10 +326,14 @@ static struct pp_argline pp_global_arglines[] = {
L1E_MIN_L1SYNC_RECEIPT_TIMEOUT,L1E_MAX_L1SYNC_RECEIPT_TIMEOUT),
#endif
INST_OPTION_INT("desiredState", ARG_NAMES, arg_states, cfg.desiredState),
INST_OPTION_INT64("egressLatency", ARG_INT64, NULL,cfg.egressLatency_ps),
INST_OPTION_INT64("ingressLatency", ARG_INT64, NULL,cfg.ingressLatency_ps),
INST_OPTION_INT64("constantAsymmetry", ARG_INT64, NULL,cfg.constantAsymmetry_ps),
INST_OPTION_DOUBLE("delayCoefficient", ARG_DOUBLE, NULL,cfg.delayCoefficient),
INST_OPTION_INT64_RANGE("egressLatency", ARG_INT64, NULL,cfg.egressLatency_ps,
TIME_INTERVAL_MIN_PICOS_VALUE_AS_INT64,TIME_INTERVAL_MAX_PICOS_VALUE_AS_INT64),
INST_OPTION_INT64_RANGE("ingressLatency", ARG_INT64, NULL,cfg.ingressLatency_ps,
TIME_INTERVAL_MIN_PICOS_VALUE_AS_INT64,TIME_INTERVAL_MAX_PICOS_VALUE_AS_INT64),
INST_OPTION_INT64_RANGE("constantAsymmetry", ARG_INT64, NULL,cfg.constantAsymmetry_ps,
TIME_INTERVAL_MIN_PICOS_VALUE_AS_INT64,TIME_INTERVAL_MAX_PICOS_VALUE_AS_INT64),
INST_OPTION_DOUBLE_RANGE("delayCoefficient", ARG_DOUBLE, NULL,cfg.delayCoefficient,
RELATIVE_DIFFERENCE_MIN_VALUE_AS_DOUBLE,RELATIVE_DIFFERENCE_MAX_VALUE_AS_DOUBLE),
RT_OPTION_INT_RANGE("clock-class", ARG_INT, NULL, clock_quality.clockClass,
PP_MIN_CLOCK_CLASS,PP_MAX_CLOCK_CLASS),
RT_OPTION_INT_RANGE("clock-accuracy", ARG_INT, NULL,clock_quality.clockAccuracy,
......@@ -549,7 +554,7 @@ static int pp_config_line(struct pp_globals *ppg, char *line, int lineno)
break;
case ARG_INT64:
if (sscanf(line, "%lli", &(cfg_arg.i64)) != 1) {
if (sscanf(line, "%" SCNd64, &(cfg_arg.i64)) != 1) {
pp_error("line %i: \"%s\"[%s]: not int64\n", lineno, word,line);
return -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment