From 506f6f30431dc31235725aa2943d844286429bf5 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Sun, 8 Dec 2019 00:52:17 +0100 Subject: [PATCH 01/89] canfdtest: can_echo_gen(): initialize tx_frames with zero This avoids having the padding in the struct can_fame contain bogus values, which are interpreted by "candump -x" as CAN-FD BRS and ESI values. Signed-off-by: Marc Kleine-Budde --- canfdtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/canfdtest.c b/canfdtest.c index cf59a3a..b06193b 100644 --- a/canfdtest.c +++ b/canfdtest.c @@ -236,7 +236,7 @@ static int can_echo_dut(void) static int can_echo_gen(void) { - struct can_frame tx_frames[CAN_MSG_COUNT]; + struct can_frame tx_frames[CAN_MSG_COUNT] = { }; int recv_tx[CAN_MSG_COUNT]; struct can_frame rx_frame; unsigned char counter = 0; From 8106214b5503ce3e9648d506305445f54b6a7206 Mon Sep 17 00:00:00 2001 From: Alexander GQ Gerasiov Date: Mon, 20 Apr 2020 10:18:08 +0300 Subject: [PATCH 02/89] Rename j* to j1939\1 Using j*smthng* for j1939-related tools is not very good for 2 reasons: 1. j prefix is not very informative; 2. jcat name is used by journal cat tool from popular sleuthkit toolkit; 2`. jacd sounds very similar to jackd. 2``. Possible future name conflicts for new tools. Thus I renamed j* to j1939\1 to deal with this issue. Signed-off-by: Alexander GQ Gerasiov --- .gitignore | 8 ++-- CMakeLists.txt | 8 ++-- GNUmakefile.am | 16 ++++---- Makefile | 24 ++++++------ jacd.c => j1939acd.c | 6 +-- jcat.c => j1939cat.c | 92 ++++++++++++++++++++++---------------------- jspy.c => j1939spy.c | 4 +- jsr.c => j1939sr.c | 4 +- 8 files changed, 81 insertions(+), 81 deletions(-) rename jacd.c => j1939acd.c (98%) rename jcat.c => j1939cat.c (84%) rename jspy.c => j1939spy.c (98%) rename jsr.c => j1939sr.c (98%) diff --git a/.gitignore b/.gitignore index 6ee4e9f..c2291bb 100644 --- a/.gitignore +++ b/.gitignore @@ -40,10 +40,10 @@ GNUmakefile.in /isotpserver /isotpsniffer /isotptun -/jacd -/jcat -/jspy -/jsr +/j1939acd +/j1939cat +/j1939spy +/j1939sr /log2asc /log2long /slcan_attach diff --git a/CMakeLists.txt b/CMakeLists.txt index 54717ff..d40c6ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,10 +36,10 @@ set(PROGRAMS_CANLIB ) set(PROGRAMS_J1939 - jacd - jcat - jspy - jsr + j1939acd + j1939cat + j1939spy + j1939sr testj1939 ) diff --git a/GNUmakefile.am b/GNUmakefile.am index 013c8ed..f47ddd3 100644 --- a/GNUmakefile.am +++ b/GNUmakefile.am @@ -58,10 +58,10 @@ bin_PROGRAMS = \ isotpserver \ isotpsniffer \ isotptun \ - jacd \ - jcat \ - jspy \ - jsr \ + j1939acd \ + j1939cat \ + j1939spy \ + j1939sr \ log2asc \ log2long \ slcan_attach \ @@ -69,10 +69,10 @@ bin_PROGRAMS = \ slcanpty \ testj1939 -jacd_LDADD = libj1939.la -jcat_LDADD = libj1939.la -jspy_LDADD = libj1939.la -jsr_LDADD = libj1939.la +j1939acd_LDADD = libj1939.la +j1939cat_LDADD = libj1939.la +j1939spy_LDADD = libj1939.la +j1939sr_LDADD = libj1939.la testj1939_LDADD = libj1939.la EXTRA_DIST = \ diff --git a/Makefile b/Makefile index d215b1a..15caa85 100644 --- a/Makefile +++ b/Makefile @@ -67,10 +67,10 @@ PROGRAMS_ISOTP := \ isotptun PROGRAMS_J1939 := \ - jacd \ - jcat \ - jspy \ - jsr \ + j1939acd \ + j1939cat \ + j1939spy \ + j1939sr \ testj1939 PROGRAMS_SLCAN := \ @@ -118,10 +118,10 @@ canplayer.o: lib.h cansend.o: lib.h log2asc.o: lib.h log2long.o: lib.h -jacd.o: libj1939.h -jcat.o: libj1939.h -jspy.o: libj1939.h -jsr.o: libj1939.h +j1939acd.o: libj1939.h +j1939cat.o: libj1939.h +j1939spy.o: libj1939.h +j1939sr.o: libj1939.h testj1939.o: libj1939.h canframelen.o: canframelen.h @@ -133,9 +133,9 @@ canplayer: canplayer.o lib.o cansend: cansend.o lib.o log2asc: log2asc.o lib.o log2long: log2long.o lib.o -jacd: jacd.o libj1939.o -jcat: jcat.o libj1939.o -jspy: jspy.o libj1939.o -jsr: jsr.o libj1939.o +j1939acd: j1939acd.o libj1939.o +j1939cat: j1939cat.o libj1939.o +j1939spy: j1939spy.o libj1939.o +j1939sr: j1939sr.o libj1939.o testj1939: testj1939.o libj1939.o canbusload: canbusload.o canframelen.o diff --git a/jacd.c b/j1939acd.c similarity index 98% rename from jacd.c rename to j1939acd.c index 3cf45e2..31bb265 100644 --- a/jacd.c +++ b/j1939acd.c @@ -30,8 +30,8 @@ #include "libj1939.h" static const char help_msg[] = - "jacd: An SAE J1939 address claiming daemon" "\n" - "Usage: jacd [options] NAME [INTF]" "\n" + "j1939acd: An SAE J1939 address claiming daemon" "\n" + "Usage: j1939acd [options] NAME [INTF]" "\n" "\n" " -v, --verbose Increase verbosity" "\n" " -r, --range=RANGE Ranges of source addresses" "\n" @@ -43,7 +43,7 @@ static const char help_msg[] = "NAME is the 64bit nodename" "\n" "\n" "Example:" "\n" - "jacd -r 100,80-120 -c /tmp/1122334455667788.jacd 1122334455667788" "\n" + "j1939acd -r 100,80-120 -c /tmp/1122334455667788.jacd 1122334455667788" "\n" ; #ifdef _GNU_SOURCE diff --git a/jcat.c b/j1939cat.c similarity index 84% rename from jcat.c rename to j1939cat.c index fedeb66..5ad9375 100644 --- a/jcat.c +++ b/j1939cat.c @@ -36,13 +36,13 @@ _min1 < _min2 ? _min1 : _min2; }) -struct jcat_stats { +struct j1939cat_stats { int err; uint32_t tskey; uint32_t send; }; -struct jcat_priv { +struct j1939cat_priv { int sock; int infile; int outfile; @@ -63,12 +63,12 @@ struct jcat_priv { struct sock_extended_err *serr; struct scm_timestamping *tss; - struct jcat_stats stats; + struct j1939cat_stats stats; }; static const char help_msg[] = - "jcat: netcat tool for j1939\n" - "Usage: jcat FROM TO\n" + "j1939cat: netcat tool for j1939\n" + "Usage: j1939cat FROM TO\n" " FROM / TO - or [IFACE][:[SA][,[PGN][,NAME]]]\n" "Options:\n" " -i (default stdin)\n" @@ -79,15 +79,15 @@ static const char help_msg[] = " -R Set send repeat count. Default: 1\n" "\n" "Example:\n" - "jcat -i some_file_to_send can0:0x80 :0x90,0x12300\n" - "jcat can0:0x90 -r > /tmp/some_file_to_receive\n" + "j1939cat -i some_file_to_send can0:0x80 :0x90,0x12300\n" + "j1939cat can0:0x90 -r > /tmp/some_file_to_receive\n" "\n" ; static const char optstring[] = "?i:vs:rp:P:R:"; -static void jcat_init_sockaddr_can(struct sockaddr_can *sac) +static void j1939cat_init_sockaddr_can(struct sockaddr_can *sac) { sac->can_family = AF_CAN; sac->can_addr.j1939.addr = J1939_NO_ADDR; @@ -95,7 +95,7 @@ static void jcat_init_sockaddr_can(struct sockaddr_can *sac) sac->can_addr.j1939.pgn = J1939_NO_PGN; } -static ssize_t jcat_send_one(struct jcat_priv *priv, int out_fd, +static ssize_t j1939cat_send_one(struct j1939cat_priv *priv, int out_fd, const void *buf, size_t buf_size) { ssize_t num_sent; @@ -129,10 +129,10 @@ static ssize_t jcat_send_one(struct jcat_priv *priv, int out_fd, return num_sent; } -static void jcat_print_timestamp(struct jcat_priv *priv, const char *name, +static void j1939cat_print_timestamp(struct j1939cat_priv *priv, const char *name, struct timespec *cur) { - struct jcat_stats *stats = &priv->stats; + struct j1939cat_stats *stats = &priv->stats; if (!(cur->tv_sec | cur->tv_nsec)) return; @@ -144,7 +144,7 @@ static void jcat_print_timestamp(struct jcat_priv *priv, const char *name, fprintf(stderr, "\n"); } -static const char *jcat_tstype_to_str(int tstype) +static const char *j1939cat_tstype_to_str(int tstype) { switch (tstype) { case SCM_TSTAMP_SCHED: @@ -159,9 +159,9 @@ static const char *jcat_tstype_to_str(int tstype) } /* Check the stats of SCM_TIMESTAMPING_OPT_STATS */ -static void jcat_scm_opt_stats(struct jcat_priv *priv, void *buf, int len) +static void j1939cat_scm_opt_stats(struct j1939cat_priv *priv, void *buf, int len) { - struct jcat_stats *stats = &priv->stats; + struct j1939cat_stats *stats = &priv->stats; int offset = 0; while (offset < len) { @@ -179,9 +179,9 @@ static void jcat_scm_opt_stats(struct jcat_priv *priv, void *buf, int len) } } -static int jcat_extract_serr(struct jcat_priv *priv) +static int j1939cat_extract_serr(struct j1939cat_priv *priv) { - struct jcat_stats *stats = &priv->stats; + struct j1939cat_stats *stats = &priv->stats; struct sock_extended_err *serr = priv->serr; struct scm_timestamping *tss = priv->tss; @@ -205,7 +205,7 @@ static int jcat_extract_serr(struct jcat_priv *priv) serr->ee_errno); stats->tskey = serr->ee_data; - jcat_print_timestamp(priv, jcat_tstype_to_str(serr->ee_info), + j1939cat_print_timestamp(priv, j1939cat_tstype_to_str(serr->ee_info), &tss->ts[0]); if (serr->ee_info == SCM_TSTAMP_SCHED) @@ -232,7 +232,7 @@ static int jcat_extract_serr(struct jcat_priv *priv) warnx("serr: unknown ee_info: %i", serr->ee_info); - jcat_print_timestamp(priv, " ABT", &tss->ts[0]); + j1939cat_print_timestamp(priv, " ABT", &tss->ts[0]); warnx("serr: tx error: %i, %s", serr->ee_errno, strerror(serr->ee_errno)); return serr->ee_errno; @@ -243,7 +243,7 @@ static int jcat_extract_serr(struct jcat_priv *priv) return 0; } -static int jcat_parse_cm(struct jcat_priv *priv, struct cmsghdr *cm) +static int j1939cat_parse_cm(struct j1939cat_priv *priv, struct cmsghdr *cm) { const size_t hdr_len = CMSG_ALIGN(sizeof(struct cmsghdr)); @@ -253,7 +253,7 @@ static int jcat_parse_cm(struct jcat_priv *priv, struct cmsghdr *cm) void *jstats = (void *)CMSG_DATA(cm); /* Activated with SOF_TIMESTAMPING_OPT_STATS */ - jcat_scm_opt_stats(priv, jstats, cm->cmsg_len - hdr_len); + j1939cat_scm_opt_stats(priv, jstats, cm->cmsg_len - hdr_len); } else if (cm->cmsg_level == SOL_CAN_J1939 && cm->cmsg_type == SCM_J1939_ERRQUEUE) { priv->serr = (void *)CMSG_DATA(cm); @@ -264,7 +264,7 @@ static int jcat_parse_cm(struct jcat_priv *priv, struct cmsghdr *cm) return 0; } -static int jcat_recv_err(struct jcat_priv *priv) +static int j1939cat_recv_err(struct j1939cat_priv *priv) { char control[100]; struct cmsghdr *cm; @@ -285,18 +285,18 @@ static int jcat_recv_err(struct jcat_priv *priv) for (cm = CMSG_FIRSTHDR(&msg); cm && cm->cmsg_len; cm = CMSG_NXTHDR(&msg, cm)) { - jcat_parse_cm(priv, cm); + j1939cat_parse_cm(priv, cm); if (priv->serr && priv->tss) - return jcat_extract_serr(priv); + return j1939cat_extract_serr(priv); } return 0; } -static int jcat_send_loop(struct jcat_priv *priv, int out_fd, char *buf, +static int j1939cat_send_loop(struct j1939cat_priv *priv, int out_fd, char *buf, size_t buf_size) { - struct jcat_stats *stats = &priv->stats; + struct j1939cat_stats *stats = &priv->stats; ssize_t count; char *tmp_buf = buf; unsigned int events = POLLOUT | POLLERR; @@ -328,7 +328,7 @@ static int jcat_send_loop(struct jcat_priv *priv, int out_fd, char *buf, } if (fds.revents & POLLERR) { - ret = jcat_recv_err(priv); + ret = j1939cat_recv_err(priv); if (ret == -EINTR) continue; else if (ret) @@ -339,12 +339,12 @@ static int jcat_send_loop(struct jcat_priv *priv, int out_fd, char *buf, } if (fds.revents & POLLOUT) { - num_sent = jcat_send_one(priv, out_fd, tmp_buf, count); + num_sent = j1939cat_send_one(priv, out_fd, tmp_buf, count); if (num_sent < 0) return num_sent; } } else { - num_sent = jcat_send_one(priv, out_fd, tmp_buf, count); + num_sent = j1939cat_send_one(priv, out_fd, tmp_buf, count); if (num_sent < 0) return num_sent; } @@ -366,7 +366,7 @@ static int jcat_send_loop(struct jcat_priv *priv, int out_fd, char *buf, return 0; } -static int jcat_sendfile(struct jcat_priv *priv, int out_fd, int in_fd, +static int j1939cat_sendfile(struct j1939cat_priv *priv, int out_fd, int in_fd, off_t *offset, size_t count) { int ret = EXIT_SUCCESS; @@ -408,7 +408,7 @@ static int jcat_sendfile(struct jcat_priv *priv, int out_fd, int in_fd, if (num_read == 0) break; /* EOF */ - ret = jcat_send_loop(priv, out_fd, buf, num_read); + ret = j1939cat_send_loop(priv, out_fd, buf, num_read); if (ret) goto do_free; @@ -437,7 +437,7 @@ do_nofree: return ret; } -static size_t jcat_get_file_size(int fd) +static size_t j1939cat_get_file_size(int fd) { off_t offset; @@ -451,20 +451,20 @@ static size_t jcat_get_file_size(int fd) return offset; } -static int jcat_send(struct jcat_priv *priv) +static int j1939cat_send(struct j1939cat_priv *priv) { unsigned int size = 0; int ret, i; if (priv->todo_filesize) - size = jcat_get_file_size(priv->infile); + size = j1939cat_get_file_size(priv->infile); if (!size) return EXIT_FAILURE; for (i = 0; i < priv->repeat; i++) { priv->round++; - ret = jcat_sendfile(priv, priv->sock, priv->infile, NULL, size); + ret = j1939cat_sendfile(priv, priv->sock, priv->infile, NULL, size); if (ret) break; @@ -475,7 +475,7 @@ static int jcat_send(struct jcat_priv *priv) return ret; } -static int jcat_recv_one(struct jcat_priv *priv, uint8_t *buf, size_t buf_size) +static int j1939cat_recv_one(struct j1939cat_priv *priv, uint8_t *buf, size_t buf_size) { int ret; @@ -494,7 +494,7 @@ static int jcat_recv_one(struct jcat_priv *priv, uint8_t *buf, size_t buf_size) return EXIT_SUCCESS; } -static int jcat_recv(struct jcat_priv *priv) +static int j1939cat_recv(struct j1939cat_priv *priv) { int ret = EXIT_SUCCESS; size_t buf_size; @@ -508,7 +508,7 @@ static int jcat_recv(struct jcat_priv *priv) } while (priv->todo_recv) { - ret = jcat_recv_one(priv, buf, buf_size); + ret = j1939cat_recv_one(priv, buf, buf_size); if (ret) break; } @@ -517,7 +517,7 @@ static int jcat_recv(struct jcat_priv *priv) return ret; } -static int jcat_sock_prepare(struct jcat_priv *priv) +static int j1939cat_sock_prepare(struct j1939cat_priv *priv) { unsigned int sock_opt; int value; @@ -581,7 +581,7 @@ static int jcat_sock_prepare(struct jcat_priv *priv) return EXIT_SUCCESS; } -static int jcat_parse_args(struct jcat_priv *priv, int argc, char *argv[]) +static int j1939cat_parse_args(struct j1939cat_priv *priv, int argc, char *argv[]) { int opt; @@ -641,7 +641,7 @@ static int jcat_parse_args(struct jcat_priv *priv, int argc, char *argv[]) int main(int argc, char *argv[]) { - struct jcat_priv *priv; + struct j1939cat_priv *priv; int ret; priv = malloc(sizeof(*priv)); @@ -657,21 +657,21 @@ int main(int argc, char *argv[]) priv->polltimeout = 100000; priv->repeat = 1; - jcat_init_sockaddr_can(&priv->sockname); - jcat_init_sockaddr_can(&priv->peername); + j1939cat_init_sockaddr_can(&priv->sockname); + j1939cat_init_sockaddr_can(&priv->peername); - ret = jcat_parse_args(priv, argc, argv); + ret = j1939cat_parse_args(priv, argc, argv); if (ret) return ret; - ret = jcat_sock_prepare(priv); + ret = j1939cat_sock_prepare(priv); if (ret) return ret; if (priv->todo_recv) - ret = jcat_recv(priv); + ret = j1939cat_recv(priv); else - ret = jcat_send(priv); + ret = j1939cat_send(priv); close(priv->infile); close(priv->outfile); diff --git a/jspy.c b/j1939spy.c similarity index 98% rename from jspy.c rename to j1939spy.c index d2ae177..93bd40c 100644 --- a/jspy.c +++ b/j1939spy.c @@ -30,8 +30,8 @@ * getopt */ static const char help_msg[] = - "jspy: An SAE J1939 spy utility" "\n" - "Usage: jspy [OPTION...] [[IFACE:][NAME|SA][,PGN]]" "\n" + "j1939spy: An SAE J1939 spy utility" "\n" + "Usage: j1939spy [OPTION...] [[IFACE:][NAME|SA][,PGN]]" "\n" "\n" " -v, --verbose Increase verbosity" "\n" " -P, --promisc Run in promiscuous mode" "\n" diff --git a/jsr.c b/j1939sr.c similarity index 98% rename from jsr.c rename to j1939sr.c index 3b84f0d..c657778 100644 --- a/jsr.c +++ b/j1939sr.c @@ -31,8 +31,8 @@ * getopt */ static const char help_msg[] = - "jsr: An SAE J1939 send/recv utility" "\n" - "Usage: jsr [OPTION...] SOURCE [DEST]" "\n" + "j1939sr: An SAE J1939 send/recv utility" "\n" + "Usage: j1939sr [OPTION...] SOURCE [DEST]" "\n" "\n" " -v, --verbose Increase verbosity" "\n" " -p, --priority=VAL J1939 priority (0..7, default 6)" "\n" From eb639c1b3d0da26eb63ebfb8510313834b635acc Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Sun, 26 Apr 2020 08:30:55 +0200 Subject: [PATCH 03/89] cansniffer: fix gap calculation output The gap between two consecutive frames of a specific has been calculated in handle_timeo() instead of handle_bcm() which lead to values that where at minimum the loop time of the display refresh. The effect can be seen when displaying a 10ms gap CAN frame with a 200ms display refresh (option -l 20 => default) in opposite to a 10ms display refresh (option -l 1). Signed-off-by: Oliver Hartkopp --- cansniffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cansniffer.c b/cansniffer.c index 0ff29b4..ccd6b4d 100644 --- a/cansniffer.c +++ b/cansniffer.c @@ -506,6 +506,7 @@ int handle_bcm(int fd, long currcms){ } id = bmsg.msg_head.can_id; + sniftab[id].laststamp = sniftab[id].currstamp; ioctl(fd, SIOCGSTAMP, &sniftab[id].currstamp); if (bmsg.msg_head.opcode != RX_CHANGED) { @@ -587,7 +588,6 @@ int handle_timeo(int fd, long currcms){ } } sniftab[i].last = sniftab[i].current; - sniftab[i].laststamp = sniftab[i].currstamp; } } From bceadb8696f5145efa1b84bf90b579af7a09288e Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Sun, 26 Apr 2020 15:56:08 +0200 Subject: [PATCH 04/89] cansniffer: fix colorization when notching relevant bits When notching marked (and colored) bits with the interactive '#' command the binary output omits colored bits - as intended. But when switching back to the hex and ASCII output the bytes with notched bits remained uncolored even when some bits inside the hex bytes would have needed to be colored. The check for the colored output was a logical AND operation which is fine for the binary representation but needed to be a bit-wise operation in the hex/ASCII byte mode case. Signed-off-by: Oliver Hartkopp --- cansniffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cansniffer.c b/cansniffer.c index ccd6b4d..1a41b8a 100644 --- a/cansniffer.c +++ b/cansniffer.c @@ -646,7 +646,7 @@ void print_snifline(int id){ else { for (i=0; i 0x1F) && (sniftab[id].current.data[i] < 0x7F)) - if ((color) && (sniftab[id].marker.data[i]) && (!(sniftab[id].notch.data[i]))) + if ((color) && (sniftab[id].marker.data[i] & ~sniftab[id].notch.data[i])) printf("%s%c%s", ATTCOLOR, sniftab[id].current.data[i], ATTRESET); else putchar(sniftab[id].current.data[i]); From b740fb7fab97a6dfba330e54390adfc5393c1833 Mon Sep 17 00:00:00 2001 From: Alexander Gerasiov Date: Sun, 11 Feb 2018 19:03:05 +0300 Subject: [PATCH 05/89] asc2log.c: Reformat help/usage output to be compatible with help2man. Signed-off-by: Alexander Gerasiov Gbp-Pq: Name 0001-asc2log.c-Reformat-help-usage-output-to-be-compatibl.patch --- asc2log.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/asc2log.c b/asc2log.c index 59f2f98..cecaa9f 100644 --- a/asc2log.c +++ b/asc2log.c @@ -61,9 +61,11 @@ extern int optind, opterr, optopt; void print_usage(char *prg) { + fprintf(stderr, "%s - convert ASC logfile to compact CAN frame logfile.\n", prg); fprintf(stderr, "Usage: %s\n", prg); - fprintf(stderr, "Options: -I (default stdin)\n"); - fprintf(stderr, " -O (default stdout)\n"); + fprintf(stderr, "Options:\n"); + fprintf(stderr, "\t-I \t(default stdin)\n"); + fprintf(stderr, "\t-O \t(default stdout)\n"); } void prframe(FILE *file, struct timeval *tv, int dev, struct can_frame *cf) { From 69865c824719e050db27189fcbf73128af222cd6 Mon Sep 17 00:00:00 2001 From: Alexander Gerasiov Date: Sun, 11 Feb 2018 19:03:05 +0300 Subject: [PATCH 06/89] canbusload.c: Reformat help/usage output to be compatible with help2man. Signed-off-by: Alexander Gerasiov Gbp-Pq: Name 0002-canbusload.c-Reformat-help-usage-output-to-be-compat.patch --- canbusload.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/canbusload.c b/canbusload.c index f5f130b..b002b66 100644 --- a/canbusload.c +++ b/canbusload.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ /* - * canbusload.c + * canbusload.c - monitor CAN bus load * * Copyright (c) 2002-2008 Volkswagen Group Electronic Research * All rights reserved. @@ -91,14 +91,16 @@ static char *prg; void print_usage(char *prg) { + fprintf(stderr, "%s - monitor CAN bus load.\n", prg); fprintf(stderr, "\nUsage: %s [options] +\n", prg); fprintf(stderr, " (use CTRL-C to terminate %s)\n\n", prg); - fprintf(stderr, "Options: -t (show current time on the first line)\n"); - fprintf(stderr, " -c (colorize lines)\n"); - fprintf(stderr, " -b (show bargraph in %d%% resolution)\n", PERCENTRES); - fprintf(stderr, " -r (redraw the terminal - similar to top)\n"); - fprintf(stderr, " -i (ignore bitstuffing in bandwidth calculation)\n"); - fprintf(stderr, " -e (exact calculation of stuffed bits)\n"); + fprintf(stderr, "Options:\n"); + fprintf(stderr, " -t (show current time on the first line)\n"); + fprintf(stderr, " -c (colorize lines)\n"); + fprintf(stderr, " -b (show bargraph in %d%% resolution)\n", PERCENTRES); + fprintf(stderr, " -r (redraw the terminal - similar to top)\n"); + fprintf(stderr, " -i (ignore bitstuffing in bandwidth calculation)\n"); + fprintf(stderr, " -e (exact calculation of stuffed bits)\n"); fprintf(stderr, "\n"); fprintf(stderr, "Up to %d CAN interfaces with mandatory bitrate can be specified on the \n", MAXSOCK); fprintf(stderr, "commandline in the form: @\n\n"); @@ -107,7 +109,7 @@ void print_usage(char *prg) fprintf(stderr, "Due to the bitstuffing estimation the calculated busload may exceed 100%%.\n"); fprintf(stderr, "For each given interface the data is presented in one line which contains:\n\n"); fprintf(stderr, "(interface) (received CAN frames) (used bits total) (used bits for payload)\n"); - fprintf(stderr, "\nExample:\n"); + fprintf(stderr, "\nExamples:\n"); fprintf(stderr, "\nuser$> canbusload can0@100000 can1@500000 can2@500000 can3@500000 -r -t -b -c\n\n"); fprintf(stderr, "%s 2014-02-01 21:13:16 (worst case bitstuffing)\n", prg); fprintf(stderr, " can0@100000 805 74491 36656 74%% |XXXXXXXXXXXXXX......|\n"); From f4a9e5b57deff103787bb050d8f34ad7bc594205 Mon Sep 17 00:00:00 2001 From: Alexander Gerasiov Date: Sun, 11 Feb 2018 19:03:05 +0300 Subject: [PATCH 07/89] can-calc-bit-timing.c: Reformat help/usage output to be compatible with help2man. Signed-off-by: Alexander Gerasiov Gbp-Pq: Name 0003-can-calc-bit-timing.c-Reformat-help-usage-output-to-.patch --- can-calc-bit-timing.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/can-calc-bit-timing.c b/can-calc-bit-timing.c index abbc4ca..49347f8 100644 --- a/can-calc-bit-timing.c +++ b/can-calc-bit-timing.c @@ -131,17 +131,16 @@ static inline void *netdev_priv(const struct net_device *dev) static void print_usage(char *cmd) { + printf("%s - calculate CAN bit timing parameters.\n", cmd); printf("Usage: %s [options] []\n" - "\tOptions:\n" - "\t-q : don't print header line\n" - "\t-l : list all support CAN controller names\n" - "\t-b : bit-rate in bits/sec\n" - "\t-s : sample-point in one-tenth of a percent\n" + "Options:\n" + "\t-q don't print header line\n" + "\t-l list all support CAN controller names\n" + "\t-b bit-rate in bits/sec\n" + "\t-s sample-point in one-tenth of a percent\n" "\t or 0 for CIA recommended sample points\n" - "\t-c : real CAN system clock in Hz\n", + "\t-c real CAN system clock in Hz\n", cmd); - - exit(EXIT_FAILURE); } static void printf_btr_sja1000(struct can_bittiming *bt, bool hdr) @@ -638,7 +637,7 @@ int main(int argc, char *argv[]) const struct calc_bittiming_const *btc; - while ((opt = getopt(argc, argv, "b:c:lqs:")) != -1) { + while ((opt = getopt(argc, argv, "b:c:lqs:?")) != -1) { switch (opt) { case 'b': bitrate_nominal = atoi(optarg); @@ -660,14 +659,22 @@ int main(int argc, char *argv[]) spt_nominal = strtoul(optarg, NULL, 10); break; + case '?': + print_usage(argv[0]); + exit(EXIT_SUCCESS); + break; + default: print_usage(argv[0]); + exit(EXIT_FAILURE); break; } } - if (argc > optind + 1) + if (argc > optind + 1) { print_usage(argv[0]); + exit(EXIT_FAILURE); + } if (argc == optind + 1) name = argv[optind]; @@ -677,8 +684,10 @@ int main(int argc, char *argv[]) exit(EXIT_SUCCESS); } - if (spt_nominal && (spt_nominal >= 1000 || spt_nominal < 100)) + if (spt_nominal && (spt_nominal >= 1000 || spt_nominal < 100)) { print_usage(argv[0]); + exit(EXIT_FAILURE); + } for (i = 0; i < ARRAY_SIZE(can_calc_consts); i++) { if (name && strcmp(can_calc_consts[i].bittiming_const.name, name)) From 6db632531dc37522c35a6325802f2a9219655910 Mon Sep 17 00:00:00 2001 From: Alexander GQ Gerasiov Date: Sat, 11 Apr 2020 13:46:56 +0300 Subject: [PATCH 08/89] candump.c: Reformat help/usage output to be compatible with help2man. Gbp-Pq: Name 0004-candump.c-Reformat-help-usage-output-to-be-compatibl.patch --- candump.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/candump.c b/candump.c index 16382d1..4fcffef 100644 --- a/candump.c +++ b/candump.c @@ -116,9 +116,11 @@ static volatile int running = 1; void print_usage(char *prg) { + fprintf(stderr, "%s - dump CAN bus traffic.\n", prg); fprintf(stderr, "\nUsage: %s [options] +\n", prg); fprintf(stderr, " (use CTRL-C to terminate %s)\n\n", prg); - fprintf(stderr, "Options: -t (timestamp: (a)bsolute/(d)elta/(z)ero/(A)bsolute w date)\n"); + fprintf(stderr, "Options:\n"); + fprintf(stderr, " -t (timestamp: (a)bsolute/(d)elta/(z)ero/(A)bsolute w date)\n"); fprintf(stderr, " -H (read hardware timestamps instead of system timestamps)\n"); fprintf(stderr, " -c (increment color mode level)\n"); fprintf(stderr, " -i (binary output - may exceed 80 chars/line)\n"); @@ -137,22 +139,23 @@ void print_usage(char *prg) fprintf(stderr, "\n"); fprintf(stderr, "Up to %d CAN interfaces with optional filter sets can be specified\n", MAXSOCK); fprintf(stderr, "on the commandline in the form: [,filter]*\n"); - fprintf(stderr, "\nComma separated filters can be specified for each given CAN interface:\n"); - fprintf(stderr, " : (matches when & mask == can_id & mask)\n"); - fprintf(stderr, " ~ (matches when & mask != can_id & mask)\n"); - fprintf(stderr, " # (set error frame filter, see include/linux/can/error.h)\n"); - fprintf(stderr, " [j|J] (join the given CAN filters - logical AND semantic)\n"); + fprintf(stderr, "\nFilters:\n"); + fprintf(stderr, " Comma separated filters can be specified for each given CAN interface:\n"); + fprintf(stderr, ":\n\t(matches when & mask == can_id & mask)\n"); + fprintf(stderr, "~\n\t(matches when & mask != can_id & mask)\n"); + fprintf(stderr, "#\n\t(set error frame filter, see include/linux/can/error.h)\n"); + fprintf(stderr, "[j|J]\n\t(join the given CAN filters - logical AND semantic)\n"); fprintf(stderr, "\nCAN IDs, masks and data content are given and expected in hexadecimal values.\n"); fprintf(stderr, "When the can_id is 8 digits long the CAN_EFF_FLAG is set for 29 bit EFF format.\n"); fprintf(stderr, "Without any given filter all data frames are received ('0:0' default filter).\n"); fprintf(stderr, "\nUse interface name '%s' to receive from all CAN interfaces.\n", ANYDEV); fprintf(stderr, "\nExamples:\n"); - fprintf(stderr, "%s -c -c -ta can0,123:7FF,400:700,#000000FF can2,400~7F0 can3 can8\n", prg); - fprintf(stderr, "%s -l any,0~0,#FFFFFFFF (log only error frames but no(!) data frames)\n", prg); - fprintf(stderr, "%s -l any,0:0,#FFFFFFFF (log error frames and also all data frames)\n", prg); - fprintf(stderr, "%s vcan2,12345678:DFFFFFFF (match only for extended CAN ID 12345678)\n", prg); - fprintf(stderr, "%s vcan2,123:7FF (matches CAN ID 123 - including EFF and RTR frames)\n", prg); - fprintf(stderr, "%s vcan2,123:C00007FF (matches CAN ID 123 - only SFF and non-RTR frames)\n", prg); + fprintf(stderr, "%s -c -c -ta can0,123:7FF,400:700,#000000FF can2,400~7F0 can3 can8\n\n", prg); + fprintf(stderr, "%s -l any,0~0,#FFFFFFFF\n\t(log only error frames but no(!) data frames)\n", prg); + fprintf(stderr, "%s -l any,0:0,#FFFFFFFF\n\t(log error frames and also all data frames)\n", prg); + fprintf(stderr, "%s vcan2,12345678:DFFFFFFF\n\t(match only for extended CAN ID 12345678)\n", prg); + fprintf(stderr, "%s vcan2,123:7FF\n\t(matches CAN ID 123 - including EFF and RTR frames)\n", prg); + fprintf(stderr, "%s vcan2,123:C00007FF\n\t(matches CAN ID 123 - only SFF and non-RTR frames)\n", prg); fprintf(stderr, "\n"); } From c56259ab33a16f30f5721cc7d19b21f0784f437a Mon Sep 17 00:00:00 2001 From: Alexander Gerasiov Date: Sun, 11 Feb 2018 19:03:05 +0300 Subject: [PATCH 09/89] canfdtest.c: Reformat help/usage output to be compatible with help2man. Signed-off-by: Alexander Gerasiov Gbp-Pq: Name 0005-canfdtest.c-Reformat-help-usage-output-to-be-compati.patch --- canfdtest.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/canfdtest.c b/canfdtest.c index cf59a3a..a4b98f5 100644 --- a/canfdtest.c +++ b/canfdtest.c @@ -52,9 +52,11 @@ static int exit_sig; static void print_usage(char *prg) { fprintf(stderr, + "%s - Full-duplex test program (DUT and host part).\n" "Usage: %s [options] \n" "\n" - "Options: -v (low verbosity)\n" + "Options:\n" + " -v (low verbosity)\n" " -vv (high verbosity)\n" " -g (generate messages)\n" " -l COUNT (test loop count)\n" @@ -64,10 +66,12 @@ static void print_usage(char *prg) " are sent back incrementing the CAN id and\n" "all data bytes. The program can be aborted with ^C.\n" "\n" - "Example:\n" - "\ton DUT : %s -v can0\n" - "\ton Host: %s -g -v can2\n", - prg, prg, prg); + "Examples:\n" + "\ton DUT:\n" + "%s -v can0\n" + "\ton Host:\n" + "%s -g -v can2\n", + prg, prg, prg, prg); exit(1); } @@ -320,7 +324,7 @@ int main(int argc, char *argv[]) signal(SIGHUP, signal_handler); signal(SIGINT, signal_handler); - while ((opt = getopt(argc, argv, "gl:v")) != -1) { + while ((opt = getopt(argc, argv, "gl:v?")) != -1) { switch (opt) { case 'v': verbose++; @@ -334,6 +338,7 @@ int main(int argc, char *argv[]) echo_gen = 1; break; + case '?': default: print_usage(basename(argv[0])); break; From f503097a3861bd7be94b8b9a0a536ec1827813be Mon Sep 17 00:00:00 2001 From: Alexander Gerasiov Date: Sun, 11 Feb 2018 19:03:05 +0300 Subject: [PATCH 10/89] cangen.c: Reformat help/usage output to be compatible with help2man. Signed-off-by: Alexander Gerasiov Gbp-Pq: Name 0006-cangen.c-Reformat-help-usage-output-to-be-compatible.patch --- cangen.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/cangen.c b/cangen.c index 9a1914b..9675b8a 100644 --- a/cangen.c +++ b/cangen.c @@ -78,9 +78,11 @@ static unsigned long long enobufs_count; void print_usage(char *prg) { + fprintf(stderr, "%s - CAN frames generator for testing purposes.\n", prg); fprintf(stderr, "\n%s: generate CAN frames\n\n", prg); fprintf(stderr, "Usage: %s [options] \n", prg); - fprintf(stderr, "Options: -g (gap in milli seconds " + fprintf(stderr, "Options:\n"); + fprintf(stderr, " -g (gap in milli seconds " "- default: %d ms)\n", DEFAULT_GAP); fprintf(stderr, " -e (generate extended frame mode " "(EFF) CAN frames)\n"); @@ -106,25 +108,25 @@ void print_usage(char *prg) fprintf(stderr, " -v (increment verbose level for " "printing sent CAN frames)\n\n"); fprintf(stderr, "Generation modes:\n"); - fprintf(stderr, "'r' => random values (default)\n"); - fprintf(stderr, "'i' => increment values\n"); - fprintf(stderr, " => fix value using \n\n"); + fprintf(stderr, " 'r' => random values (default)\n"); + fprintf(stderr, " 'i' => increment values\n"); + fprintf(stderr, " => fix value using \n\n"); fprintf(stderr, "When incrementing the CAN data the data length code " "minimum is set to 1.\n"); fprintf(stderr, "CAN IDs and data content are given and expected in hexadecimal values.\n\n"); fprintf(stderr, "Examples:\n"); - fprintf(stderr, "%s vcan0 -g 4 -I 42A -L 1 -D i -v -v ", prg); - fprintf(stderr, "(fixed CAN ID and length, inc. data)\n"); - fprintf(stderr, "%s vcan0 -e -L i -v -v -v ", prg); - fprintf(stderr, "(generate EFF frames, incr. length)\n"); - fprintf(stderr, "%s vcan0 -D 11223344DEADBEEF -L 8 ", prg); - fprintf(stderr, "(fixed CAN data payload and length)\n"); - fprintf(stderr, "%s vcan0 -g 0 -i -x ", prg); - fprintf(stderr, "(full load test ignoring -ENOBUFS)\n"); - fprintf(stderr, "%s vcan0 -g 0 -p 10 -x ", prg); - fprintf(stderr, "(full load test with polling, 10ms timeout)\n"); - fprintf(stderr, "%s vcan0 ", prg); - fprintf(stderr, "(my favourite default :)\n\n"); + fprintf(stderr, "%s vcan0 -g 4 -I 42A -L 1 -D i -v -v\n", prg); + fprintf(stderr, "\t(fixed CAN ID and length, inc. data)\n"); + fprintf(stderr, "%s vcan0 -e -L i -v -v -v\n", prg); + fprintf(stderr, "\t(generate EFF frames, incr. length)\n"); + fprintf(stderr, "%s vcan0 -D 11223344DEADBEEF -L 8\n", prg); + fprintf(stderr, "\t(fixed CAN data payload and length)\n"); + fprintf(stderr, "%s vcan0 -g 0 -i -x\n", prg); + fprintf(stderr, "\t(full load test ignoring -ENOBUFS)\n"); + fprintf(stderr, "%s vcan0 -g 0 -p 10 -x\n", prg); + fprintf(stderr, "\t(full load test with polling, 10ms timeout)\n"); + fprintf(stderr, "%s vcan0\n", prg); + fprintf(stderr, "\t(my favourite default :)\n\n"); } void sigterm(int signo) From 1127609357701ab7c5e14ed9128a861595a24fb9 Mon Sep 17 00:00:00 2001 From: Alexander GQ Gerasiov Date: Sat, 11 Apr 2020 13:46:56 +0300 Subject: [PATCH 11/89] cangw.c: Reformat help/usage output to be compatible with help2man. Gbp-Pq: Name 0007-cangw.c-Reformat-help-usage-output-to-be-compatible-.patch --- cangw.c | 79 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/cangw.c b/cangw.c index 52314f6..a6b1697 100644 --- a/cangw.c +++ b/cangw.c @@ -222,55 +222,60 @@ void print_cs_crc8(struct cgw_csum_crc8 *cs_crc8) void print_usage(char *prg) { + fprintf(stderr, "%s - manage PF_CAN netlink gateway.\n", prg); fprintf(stderr, "\nUsage: %s [options]\n\n", prg); - fprintf(stderr, "Commands: -A (add a new rule)\n"); - fprintf(stderr, " -D (delete a rule)\n"); - fprintf(stderr, " -F (flush / delete all rules)\n"); - fprintf(stderr, " -L (list all rules)\n"); - fprintf(stderr, "Mandatory: -s (source netdevice)\n"); + fprintf(stderr, "Commands:\n"); + fprintf(stderr, " -A (add a new rule)\n"); + fprintf(stderr, " -D (delete a rule)\n"); + fprintf(stderr, " -F (flush / delete all rules)\n"); + fprintf(stderr, " -L (list all rules)\n"); + fprintf(stderr, "Mandatory:\n"); + fprintf(stderr, " -s (source netdevice)\n"); fprintf(stderr, " -d (destination netdevice)\n"); - fprintf(stderr, "Options: -X (this is a CAN FD rule)\n"); - fprintf(stderr, " -t (preserve src_dev rx timestamp)\n"); - fprintf(stderr, " -e (echo sent frames - recommended on vcanx)\n"); - fprintf(stderr, " -i (allow to route to incoming interface)\n"); - fprintf(stderr, " -u (user defined modification identifier)\n"); - fprintf(stderr, " -l (limit the number of frame hops / routings)\n"); - fprintf(stderr, " -f (set CAN filter)\n"); - fprintf(stderr, " -m (set Classic CAN frame modifications)\n"); - fprintf(stderr, " -M (set CAN FD frame modifications)\n"); - fprintf(stderr, " -x ::: (XOR checksum)\n"); - fprintf(stderr, " -c ::::: (CRC8 cs)\n"); - fprintf(stderr, " -p :[] (CRC8 checksum profile & parameters)\n"); + fprintf(stderr, "Options:\n"); + fprintf(stderr, " -X (this is a CAN FD rule)\n"); + fprintf(stderr, " -t (preserve src_dev rx timestamp)\n"); + fprintf(stderr, " -e (echo sent frames - recommended on vcanx)\n"); + fprintf(stderr, " -i (allow to route to incoming interface)\n"); + fprintf(stderr, " -u (user defined modification identifier)\n"); + fprintf(stderr, " -l (limit the number of frame hops / routings)\n"); + fprintf(stderr, " -f (set CAN filter)\n"); + fprintf(stderr, " -m (set Classic CAN frame modifications)\n"); + fprintf(stderr, " -M (set CAN FD frame modifications)\n"); + fprintf(stderr, " -x ::: (XOR checksum)\n"); + fprintf(stderr, " -c ::::: (CRC8 cs)\n"); + fprintf(stderr, " -p :[] (CRC8 checksum profile & parameters)\n"); fprintf(stderr, "\nValues are given and expected in hexadecimal values. Leading 0s can be omitted.\n"); fprintf(stderr, "\n"); - fprintf(stderr, " is a CAN identifier filter\n"); - fprintf(stderr, " : (matches when & mask == can_id & mask)\n"); - fprintf(stderr, " ~ (matches when & mask != can_id & mask)\n"); + fprintf(stderr, " is a CAN identifier filter:\n"); + fprintf(stderr, " :\t(matches when & mask == can_id & mask)\n"); + fprintf(stderr, " ~\t(matches when & mask != can_id & mask)\n"); fprintf(stderr, "\n"); fprintf(stderr, " is a CAN frame modification instruction consisting of\n"); fprintf(stderr, "::..\n"); - fprintf(stderr, " - is one of 'AND' 'OR' 'XOR' 'SET'\n"); - fprintf(stderr, " - is _one_ or _more_ of 'I'dentifier 'L'ength 'D'ata\n"); - fprintf(stderr, " - is an u32 value containing the CAN Identifier\n"); - fprintf(stderr, " - is an u8 value containing the data length code (0 .. 8)\n"); - fprintf(stderr, " - is always eight(!) u8 values containing the CAN frames data\n"); + fprintf(stderr, " is one of 'AND' 'OR' 'XOR' 'SET'\n"); + fprintf(stderr, " is _one_ or _more_ of 'I'dentifier 'L'ength 'D'ata\n"); + fprintf(stderr, " is an u32 value containing the CAN Identifier\n"); + fprintf(stderr, " is an u8 value containing the data length code (0 .. 8)\n"); + fprintf(stderr, " is always eight(!) u8 values containing the CAN frames data\n"); + fprintf(stderr, "\n"); fprintf(stderr, " is a CAN FD frame modification instruction consisting of\n"); fprintf(stderr, "::...\n"); - fprintf(stderr, " - is one of 'AND' 'OR' 'XOR' 'SET'\n"); - fprintf(stderr, " - is _one_ or _more_ of 'I'd 'F'lags 'L'ength 'D'ata\n"); - fprintf(stderr, " - is an u32 value containing the CAN FD Identifier\n"); - fprintf(stderr, " - is an u8 value containing CAN FD flags (CANFD_BRS, CANFD_ESI)\n"); - fprintf(stderr, " - is an u8 value containing the data length (0 .. 64)\n"); - fprintf(stderr, " - is always 64(!) u8 values containing the CAN FD frames data\n"); + fprintf(stderr, " is one of 'AND' 'OR' 'XOR' 'SET'\n"); + fprintf(stderr, " is _one_ or _more_ of 'I'd 'F'lags 'L'ength 'D'ata\n"); + fprintf(stderr, " is an u32 value containing the CAN FD Identifier\n"); + fprintf(stderr, " is an u8 value containing CAN FD flags (CANFD_BRS, CANFD_ESI)\n"); + fprintf(stderr, " is an u8 value containing the data length (0 .. 64)\n"); + fprintf(stderr, " is always 64(!) u8 values containing the CAN FD frames data\n"); fprintf(stderr, "The max. four modifications are performed in the order AND -> OR -> XOR -> SET\n"); fprintf(stderr, "\n"); - fprintf(stderr, "Example:\n"); - fprintf(stderr, "%s -A -s can0 -d vcan3 -e -f 123:C00007FF -m SET:IL:333.4.1122334455667788\n", prg); - fprintf(stderr, "\n"); fprintf(stderr, "Supported CRC 8 profiles:\n"); - fprintf(stderr, "Profile '%d' (1U8) - add one additional u8 value\n", CGW_CRC8PRF_1U8); - fprintf(stderr, "Profile '%d' (16U8) - add u8 value from table[16] indexed by (data[1] & 0xF)\n", CGW_CRC8PRF_16U8); - fprintf(stderr, "Profile '%d' (SFFID_XOR) - add u8 value (can_id & 0xFF) ^ (can_id >> 8 & 0xFF)\n", CGW_CRC8PRF_SFFID_XOR); + fprintf(stderr, " Profile '%d' (1U8) - add one additional u8 value\n", CGW_CRC8PRF_1U8); + fprintf(stderr, " Profile '%d' (16U8) - add u8 value from table[16] indexed by (data[1] & 0xF)\n", CGW_CRC8PRF_16U8); + fprintf(stderr, " Profile '%d' (SFFID_XOR) - add u8 value (can_id & 0xFF) ^ (can_id >> 8 & 0xFF)\n", CGW_CRC8PRF_SFFID_XOR); + fprintf(stderr, "\n"); + fprintf(stderr, "Examples:\n"); + fprintf(stderr, "%s -A -s can0 -d vcan3 -e -f 123:C00007FF -m SET:IL:333.4.1122334455667788\n", prg); fprintf(stderr, "\n"); } From 65399166c1d6a74354b47e12d08901aef2c219bd Mon Sep 17 00:00:00 2001 From: Alexander Gerasiov Date: Sun, 11 Feb 2018 19:03:05 +0300 Subject: [PATCH 12/89] canlogserver.c: Reformat help/usage output to be compatible with help2man. Signed-off-by: Alexander Gerasiov Gbp-Pq: Name 0008-canlogserver.c-Reformat-help-usage-output-to-be-comp.patch --- canlogserver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/canlogserver.c b/canlogserver.c index 4429ccd..8319684 100644 --- a/canlogserver.c +++ b/canlogserver.c @@ -89,7 +89,8 @@ void print_usage(char *prg) { fprintf(stderr, "\nUsage: %s [options] +\n", prg); fprintf(stderr, " (use CTRL-C to terminate %s)\n\n", prg); - fprintf(stderr, "Options: -m (ID filter mask. Default 0x00000000) *\n"); + fprintf(stderr, "Options:\n"); + fprintf(stderr, " -m (ID filter mask. Default 0x00000000) *\n"); fprintf(stderr, " -v (ID filter value. Default 0x00000000) *\n"); fprintf(stderr, " -i <0|1> (invert the specified ID filter) *\n"); fprintf(stderr, " -e (mask for error frames)\n"); From 3e2c1d3cbd1fc6b7affb90bea8ec73a37a589dea Mon Sep 17 00:00:00 2001 From: Alexander Gerasiov Date: Sun, 11 Feb 2018 19:03:05 +0300 Subject: [PATCH 13/89] canplayer.c: Reformat help/usage output to be compatible with help2man. Signed-off-by: Alexander Gerasiov Gbp-Pq: Name 0009-canplayer.c-Reformat-help-usage-output-to-be-compati.patch --- canplayer.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/canplayer.c b/canplayer.c index 7932f7a..8f84f13 100644 --- a/canplayer.c +++ b/canplayer.c @@ -77,8 +77,10 @@ extern int optind, opterr, optopt; void print_usage(char *prg) { + fprintf(stderr, "%s - replay a compact CAN frame logfile to CAN devices.\n", prg); fprintf(stderr, "\nUsage: %s [interface assignment]*\n\n", prg); - fprintf(stderr, "Options: -I (default stdin)\n"); + fprintf(stderr, "Options:\n"); + fprintf(stderr, " -I (default stdin)\n"); fprintf(stderr, " -l " "(process input file times)\n" " " @@ -93,13 +95,13 @@ void print_usage(char *prg) "loopback of sent CAN frames)\n"); fprintf(stderr, " -v (verbose: print " "sent CAN frames)\n\n"); - fprintf(stderr, "Interface assignment: 0..n assignments like " - "=\n"); - fprintf(stderr, "e.g. vcan2=can0 ( send frames received from can0 on " - "vcan2 )\n"); - fprintf(stderr, "extra hook: stdout=can0 ( print logfile line marked with can0 on " - "stdout )\n"); - fprintf(stderr, "No assignments => send frames to the interface(s) they " + fprintf(stderr, "Interface assignment:\n"); + fprintf(stderr, " 0..n assignments like =\n\n"); + fprintf(stderr, " e.g. vcan2=can0 (send frames received from can0 on " + "vcan2)\n"); + fprintf(stderr, " extra hook: stdout=can0 (print logfile line marked with can0 on " + "stdout)\n"); + fprintf(stderr, " No assignments => send frames to the interface(s) they " "had been received from.\n\n"); fprintf(stderr, "Lines in the logfile not beginning with '(' (start of " "timestamp) are ignored.\n\n"); From 4568d4a180c09de87f5a77ae6aa6958505a0df2e Mon Sep 17 00:00:00 2001 From: Alexander Gerasiov Date: Sun, 11 Feb 2018 19:03:05 +0300 Subject: [PATCH 14/89] cansniffer.c: Reformat help/usage output to be compatible with help2man. Signed-off-by: Alexander Gerasiov Gbp-Pq: Name 0011-cansniffer.c-Reformat-help-usage-output-to-be-compat.patch --- cansniffer.c | 60 ++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/cansniffer.c b/cansniffer.c index 1a41b8a..b388235 100644 --- a/cansniffer.c +++ b/cansniffer.c @@ -134,26 +134,25 @@ void print_usage(char *prg) { const char manual [] = { "commands that can be entered at runtime:\n" - "\n" - "q - quit\n" - "b - toggle binary / HEX-ASCII output\n" - "B - toggle binary with gap / HEX-ASCII output (exceeds 80 chars!)\n" - "c - toggle color mode\n" - "# - notch currently marked/changed bits (can be used repeatedly)\n" - "* - clear notched marked\n" - "rMYNAME - read settings file (filter/notch)\n" - "wMYNAME - write settings file (filter/notch)\n" - "+FILTER - add CAN-IDs to sniff\n" - "-FILTER - remove CAN-IDs to sniff\n" + " q - quit\n" + " b - toggle binary / HEX-ASCII output\n" + " B - toggle binary with gap / HEX-ASCII output (exceeds 80 chars!)\n" + " c - toggle color mode\n" + " # - notch currently marked/changed bits (can be used repeatedly)\n" + " * - clear notched marked\n" + " rMYNAME - read settings file (filter/notch)\n" + " wMYNAME - write settings file (filter/notch)\n" + " +FILTER - add CAN-IDs to sniff\n" + " -FILTER - remove CAN-IDs to sniff\n" "\n" "FILTER can be a single CAN-ID or a CAN-ID/Bitmask:\n" - "+1F5 - add CAN-ID 0x1F5\n" - "-42E - remove CAN-ID 0x42E\n" - "-42E7FF - remove CAN-ID 0x42E (using Bitmask)\n" - "-500700 - remove CAN-IDs 0x500 - 0x5FF\n" - "+400600 - add CAN-IDs 0x400 - 0x5FF\n" - "+000000 - add all CAN-IDs\n" - "-000000 - remove all CAN-IDs\n" + " +1F5 - add CAN-ID 0x1F5\n" + " -42E - remove CAN-ID 0x42E\n" + " -42E7FF - remove CAN-ID 0x42E (using Bitmask)\n" + " -500700 - remove CAN-IDs 0x500 - 0x5FF\n" + " +400600 - add CAN-IDs 0x400 - 0x5FF\n" + " +000000 - add all CAN-IDs\n" + " -000000 - remove all CAN-IDs\n" "\n" "if (id & filter) == (sniff-id & filter) the action (+/-) is performed,\n" "which is quite easy when the filter is 000\n" @@ -161,18 +160,19 @@ void print_usage(char *prg) }; fprintf(stderr, "\nUsage: %s [can-interface]\n", prg); - fprintf(stderr, "Options: -m (initial FILTER default 0x00000000)\n"); - fprintf(stderr, " -v (initial FILTER default 0x00000000)\n"); - fprintf(stderr, " -q (quiet - all IDs deactivated)\n"); - fprintf(stderr, " -r (read %sname from file)\n", SETFNAME); - fprintf(stderr, " -b (start with binary mode)\n"); - fprintf(stderr, " -B (start with binary mode with gap - exceeds 80 chars!)\n"); - fprintf(stderr, " -c (color changes)\n"); - fprintf(stderr, " -f (filter on CAN-ID only)\n"); - fprintf(stderr, " -t