phc2sys.c: Implement configuration file handling

Signed-off-by: Peter Schneider <peter@psch.de>
master
Peter Schneider 2018-04-15 21:13:55 +02:00 committed by Richard Cochran
parent 26308c219a
commit c70f9b3e07
1 changed files with 10 additions and 3 deletions

View File

@ -1313,6 +1313,7 @@ static void usage(char *progname)
" -O [offset] slave-master time offset (0)\n"
" -w wait for ptp4l\n"
" common options:\n"
" -f [file] configuration file\n"
" -E [pi|linreg] clock servo (pi)\n"
" -P [kp] proportional constant (0.7)\n"
" -I [ki] integration constant (0.3)\n"
@ -1338,8 +1339,7 @@ static void usage(char *progname)
int main(int argc, char *argv[])
{
char *progname;
char *src_name = NULL, *dst_name = NULL;
char *config = NULL, *dst_name = NULL, *progname, *src_name = NULL;
struct clock *src, *dst;
struct config *cfg;
int autocfg = 0, rt = 0;
@ -1367,7 +1367,7 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv,
"arc:d:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
"arc:d:f:s:E:P:I:S:F:R:N:O:L:M:i:u:wn:xz:l:t:mqvh"))) {
switch (c) {
case 'a':
autocfg = 1;
@ -1386,6 +1386,9 @@ int main(int argc, char *argv[])
goto end;
}
break;
case 'f':
config = optarg;
break;
case 'i':
fprintf(stderr,
"'-i' has been deprecated. please use '-s' instead.\n");
@ -1518,6 +1521,10 @@ int main(int argc, char *argv[])
}
}
if (config && (c = config_read(config, cfg))) {
return c;
}
if (autocfg && (src_name || dst_name || pps_fd >= 0 || wait_sync || node.forced_sync_offset)) {
fprintf(stderr,
"autoconfiguration cannot be mixed with manual config options.\n");