Add command line options to print the software version.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-12-10 10:28:28 +01:00
parent c3119807a3
commit 39e8ee0642
9 changed files with 57 additions and 16 deletions

View File

@ -9,6 +9,8 @@ hwstamp_ctl \- set time stamping policy at the driver level
.BI \-r " rx-filter" .BI \-r " rx-filter"
] [ ] [
.BI \-t " tx-type" .BI \-t " tx-type"
] [
.B \-v
] ]
.SH DESCRIPTION .SH DESCRIPTION
@ -50,6 +52,9 @@ Display a help message and list of possible values for
.I rx-filter .I rx-filter
and and
.IR tx-type . .IR tx-type .
.TP
.B \-v
Prints the software version and exits.
.SH SEE ALSO .SH SEE ALSO
.BR ioctl (2), .BR ioctl (2),

View File

@ -29,6 +29,8 @@
#include <linux/sockios.h> #include <linux/sockios.h>
#include <net/if.h> #include <net/if.h>
#include "version.h"
static void usage(char *progname) static void usage(char *progname)
{ {
fprintf(stderr, fprintf(stderr,
@ -53,6 +55,7 @@ static void usage(char *progname)
"\t\t%2d PTP v2/802.AS1, any layer, Sync packet\n" "\t\t%2d PTP v2/802.AS1, any layer, Sync packet\n"
"\t\t%2d PTP v2/802.AS1, any layer, Delay_req packet\n" "\t\t%2d PTP v2/802.AS1, any layer, Delay_req packet\n"
" -t [%d|%d] disable or enable transmit time stamping\n" " -t [%d|%d] disable or enable transmit time stamping\n"
" -v prints the software version and exits\n"
"\n", "\n",
progname, progname,
HWTSTAMP_FILTER_NONE, HWTSTAMP_FILTER_PTP_V2_DELAY_REQ, HWTSTAMP_FILTER_NONE, HWTSTAMP_FILTER_PTP_V2_DELAY_REQ,
@ -85,7 +88,7 @@ int main(int argc, char *argv[])
/* Process the command line arguments. */ /* Process the command line arguments. */
progname = strrchr(argv[0], '/'); progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0]; progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv, "hi:r:t:"))) { while (EOF != (c = getopt(argc, argv, "hi:r:t:v"))) {
switch (c) { switch (c) {
case 'i': case 'i':
device = optarg; device = optarg;
@ -96,6 +99,9 @@ int main(int argc, char *argv[])
case 't': case 't':
txopt = atoi(optarg); txopt = atoi(optarg);
break; break;
case 'v':
version_show(stdout);
return 0;
case 'h': case 'h':
usage(progname); usage(progname);
return 0; return 0;

View File

@ -49,11 +49,11 @@ all: $(PRG)
ptp4l: $(OBJ) ptp4l: $(OBJ)
pmc: pmc.o msg.o print.o raw.o sk.o tlv.o transport.o udp.o udp6.o uds.o util.o pmc: pmc.o msg.o print.o raw.o sk.o tlv.o transport.o udp.o udp6.o uds.o util.o version.o
phc2sys: phc2sys.o sk.o sysoff.o print.o phc2sys: phc2sys.o sk.o sysoff.o print.o version.o
hwstamp_ctl: hwstamp_ctl.o hwstamp_ctl: hwstamp_ctl.o version.o
version.o: .version version.sh $(filter-out version.d,$(DEPEND)) version.o: .version version.sh $(filter-out version.d,$(DEPEND))

View File

@ -26,6 +26,8 @@ phc2sys \- synchronize two clocks
.BI \-N " clock-readings" .BI \-N " clock-readings"
] [ ] [
.BI \-O " offset" .BI \-O " offset"
] [
.B \-v
] ]
.SH DESCRIPTION .SH DESCRIPTION
@ -92,6 +94,9 @@ The default is 0 seconds.
.TP .TP
.BI \-h .BI \-h
Display a help message. Display a help message.
.TP
.B \-v
Prints the software version and exits.
.SH SEE ALSO .SH SEE ALSO
.BR ptp4l (8) .BR ptp4l (8)

View File

@ -35,6 +35,7 @@
#include "missing.h" #include "missing.h"
#include "sk.h" #include "sk.h"
#include "sysoff.h" #include "sysoff.h"
#include "version.h"
#define KP 0.7 #define KP 0.7
#define KI 0.3 #define KI 0.3
@ -264,6 +265,7 @@ static void usage(char *progname)
" -N [num] number of master clock readings per update (5)\n" " -N [num] number of master clock readings per update (5)\n"
" -O [offset] slave-master time offset (0)\n" " -O [offset] slave-master time offset (0)\n"
" -h prints this message and exits\n" " -h prints this message and exits\n"
" -v prints the software version and exits\n"
"\n", "\n",
progname); progname);
} }
@ -280,7 +282,7 @@ int main(int argc, char *argv[])
/* Process the command line arguments. */ /* Process the command line arguments. */
progname = strrchr(argv[0], '/'); progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0]; progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv, "c:d:hs:P:I:R:N:O:i:"))) { while (EOF != (c = getopt(argc, argv, "c:d:hs:P:I:R:N:O:i:v"))) {
switch (c) { switch (c) {
case 'c': case 'c':
dst = clock_open(optarg); dst = clock_open(optarg);
@ -309,6 +311,9 @@ int main(int argc, char *argv[])
case 'i': case 'i':
ethdev = optarg; ethdev = optarg;
break; break;
case 'v':
version_show(stdout);
return 0;
case 'h': case 'h':
usage(progname); usage(progname);
return 0; return 0;

5
pmc.8
View File

@ -20,6 +20,8 @@ pmc \- PTP management client
.BI \-i " interface" .BI \-i " interface"
] [ ] [
.BI \-t " transport-specific-field" .BI \-t " transport-specific-field"
] [
.B \-v
] ]
.SH DESCRIPTION .SH DESCRIPTION
@ -71,6 +73,9 @@ The default is 0x0.
.TP .TP
.B \-h .B \-h
Display a help message. Display a help message.
.TP
.B \-v
Prints the software version and exits.
.SH MANAGEMENT IDS .SH MANAGEMENT IDS

7
pmc.c
View File

@ -31,6 +31,7 @@
#include "tlv.h" #include "tlv.h"
#include "transport.h" #include "transport.h"
#include "util.h" #include "util.h"
#include "version.h"
#define BAD_ACTION -1 #define BAD_ACTION -1
#define BAD_ID -1 #define BAD_ID -1
@ -459,6 +460,7 @@ static void usage(char *progname)
" -i [dev] interface device to use, default 'eth0'\n" " -i [dev] interface device to use, default 'eth0'\n"
" for network and '/tmp/pmc' for UDS.\n" " for network and '/tmp/pmc' for UDS.\n"
" -t [hex] transport specific field, default 0x0\n" " -t [hex] transport specific field, default 0x0\n"
" -v prints the software version and exits\n"
"\n", "\n",
progname); progname);
} }
@ -476,7 +478,7 @@ int main(int argc, char *argv[])
/* Process the command line arguments. */ /* Process the command line arguments. */
progname = strrchr(argv[0], '/'); progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0]; progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv, "246u""b:d:hi:t:"))) { while (EOF != (c = getopt(argc, argv, "246u""b:d:hi:t:v"))) {
switch (c) { switch (c) {
case '2': case '2':
transport_type = TRANS_IEEE_802_3; transport_type = TRANS_IEEE_802_3;
@ -503,6 +505,9 @@ int main(int argc, char *argv[])
if (1 == sscanf(optarg, "%x", &c)) if (1 == sscanf(optarg, "%x", &c))
transport_specific = c << 4; transport_specific = c << 4;
break; break;
case 'v':
version_show(stdout);
return 0;
case 'h': case 'h':
usage(progname); usage(progname);
return 0; return 0;

15
ptp4l.8
View File

@ -31,6 +31,8 @@ ptp4l \- PTP Boundary/Ordinary Clock
] [ ] [
.BI \-l " print-level" .BI \-l " print-level"
] [ ] [
.B \-m
] [
.B \-q .B \-q
] [ ] [
.B \-v .B \-v
@ -84,6 +86,10 @@ Select the legacy hardware time stamping.
Read configuration from the specified file. No configuration file is read by Read configuration from the specified file. No configuration file is read by
default. default.
.TP .TP
.BI \-i " interface"
Specify a PTP port, it may be used multiple times. At least one port must be
specified by this option or in the configuration file.
.TP
.BI \-p " phc-device" .BI \-p " phc-device"
With hardware time stamping, force which PHC device (e.g. /dev/ptp0) should be With hardware time stamping, force which PHC device (e.g. /dev/ptp0) should be
used. used.
@ -95,15 +101,14 @@ Enable the slaveOnly mode.
Set the maximum syslog level of messages which should be printed or sent to Set the maximum syslog level of messages which should be printed or sent to
the system logger. The default is 6 (LOG_INFO). the system logger. The default is 6 (LOG_INFO).
.TP .TP
.B \-m
Print messages to the standard output.
.TP
.B \-q .B \-q
Don't send messages to the system logger. Don't send messages to the system logger.
.TP .TP
.B \-v .B \-v
Print messages to the standard output. Prints the software version and exits.
.TP
.BI \-i " interface"
Specify a PTP port, it may be used multiple times. At least one port must be
specified by this option or in the configuration file.
.TP .TP
.BI \-h .BI \-h
Display a help message. Display a help message.

15
ptp4l.c
View File

@ -33,6 +33,7 @@
#include "transport.h" #include "transport.h"
#include "udp6.h" #include "udp6.h"
#include "util.h" #include "util.h"
#include "version.h"
int assume_two_step = 0; int assume_two_step = 0;
@ -119,8 +120,9 @@ static void usage(char *progname)
" (ignored for SOFTWARE/LEGACY HW time stamping)\n" " (ignored for SOFTWARE/LEGACY HW time stamping)\n"
" -s slave only mode (overrides configuration file)\n" " -s slave only mode (overrides configuration file)\n"
" -l [num] set the logging level to 'num'\n" " -l [num] set the logging level to 'num'\n"
" -m print messages to stdout\n"
" -q do not print messages to the syslog\n" " -q do not print messages to the syslog\n"
" -v print messages to stdout\n" " -v prints the software version and exits\n"
" -h prints this message and exits\n" " -h prints this message and exits\n"
"\n", "\n",
progname); progname);
@ -157,7 +159,7 @@ int main(int argc, char *argv[])
/* Process the command line arguments. */ /* Process the command line arguments. */
progname = strrchr(argv[0], '/'); progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0]; progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv, "AEP246HSLf:i:p:sl:qvh"))) { while (EOF != (c = getopt(argc, argv, "AEP246HSLf:i:p:sl:mqvh"))) {
switch (c) { switch (c) {
case 'A': case 'A':
*dm = DM_AUTO; *dm = DM_AUTO;
@ -213,14 +215,17 @@ int main(int argc, char *argv[])
cfg_settings.print_level = atoi(optarg); cfg_settings.print_level = atoi(optarg);
*cfg_ignore |= CFG_IGNORE_PRINT_LEVEL; *cfg_ignore |= CFG_IGNORE_PRINT_LEVEL;
break; break;
case 'm':
cfg_settings.verbose = 1;
*cfg_ignore |= CFG_IGNORE_VERBOSE;
break;
case 'q': case 'q':
cfg_settings.use_syslog = 0; cfg_settings.use_syslog = 0;
*cfg_ignore |= CFG_IGNORE_USE_SYSLOG; *cfg_ignore |= CFG_IGNORE_USE_SYSLOG;
break; break;
case 'v': case 'v':
cfg_settings.verbose = 1; version_show(stdout);
*cfg_ignore |= CFG_IGNORE_VERBOSE; return 0;
break;
case 'h': case 'h':
usage(progname); usage(progname);
return 0; return 0;