Merge pull request #468 from marckleinebudde/j1939spy

J1939spy: remove verbose option
pull/149/merge
Marc Kleine-Budde 2023-10-17 10:13:34 +02:00 committed by GitHub
commit 41ea759237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 14 deletions

View File

@ -33,7 +33,6 @@ static const char help_msg[] =
"j1939spy: An SAE J1939 spy utility" "\n" "j1939spy: An SAE J1939 spy utility" "\n"
"Usage: j1939spy [OPTION...] [[IFACE:][NAME|SA][,PGN]]" "\n" "Usage: j1939spy [OPTION...] [[IFACE:][NAME|SA][,PGN]]" "\n"
"Options:\n" "Options:\n"
" -v, --verbose Increase verbosity" "\n"
" -P, --promisc Run in promiscuous mode" "\n" " -P, --promisc Run in promiscuous mode" "\n"
" (= receive traffic not for this ECU)" "\n" " (= receive traffic not for this ECU)" "\n"
" -b, --block=SIZE Use a receive buffer of SIZE (default 1024)" "\n" " -b, --block=SIZE Use a receive buffer of SIZE (default 1024)" "\n"
@ -43,8 +42,6 @@ static const char help_msg[] =
#ifdef _GNU_SOURCE #ifdef _GNU_SOURCE
static struct option long_opts[] = { static struct option long_opts[] = {
{ "help", no_argument, NULL, '?', }, { "help", no_argument, NULL, '?', },
{ "verbose", no_argument, NULL, 'v', },
{ "promisc", no_argument, NULL, 'P', }, { "promisc", no_argument, NULL, 'P', },
{ "block", required_argument, NULL, 'b', }, { "block", required_argument, NULL, 'b', },
{ "time", optional_argument, NULL, 't', }, { "time", optional_argument, NULL, 't', },
@ -60,7 +57,6 @@ static const char optstring[] = "vPb:t::?";
* static variables * static variables
*/ */
static struct { static struct {
int verbose;
struct sockaddr_can addr; struct sockaddr_can addr;
int promisc; int promisc;
int time; int time;
@ -108,9 +104,6 @@ int main(int argc, char **argv)
/* argument parsing */ /* argument parsing */
while ((opt = getopt_long(argc, argv, optstring, long_opts, NULL)) != -1) while ((opt = getopt_long(argc, argv, optstring, long_opts, NULL)) != -1)
switch (opt) { switch (opt) {
case 'v':
++s.verbose;
break;
case 'b': case 'b':
s.pkt_len = strtoul(optarg, 0, 0); s.pkt_len = strtoul(optarg, 0, 0);
break; break;
@ -207,8 +200,6 @@ int main(int argc, char **argv)
msg.msg_control = &ctrlmsg; msg.msg_control = &ctrlmsg;
memset(&tref, 0, sizeof(tref)); memset(&tref, 0, sizeof(tref));
if (s.verbose)
err(0, "listening");
while (1) { while (1) {
/* these settings may be modified by recvmsg() */ /* these settings may be modified by recvmsg() */
iov.iov_len = s.pkt_len; iov.iov_len = s.pkt_len;
@ -267,7 +258,7 @@ int main(int argc, char **argv)
tdut = ttmp; tdut = ttmp;
goto abs_time; goto abs_time;
} else if ('a' == s.time) { } else if ('a' == s.time) {
abs_time: abs_time:
printf("(%lu.%04lu)", tdut.tv_sec, tdut.tv_usec / 100); printf("(%lu.%04lu)", tdut.tv_sec, tdut.tv_usec / 100);
} else if ('A' == s.time) { } else if ('A' == s.time) {
struct tm tm; struct tm tm;
@ -288,7 +279,7 @@ int main(int argc, char **argv)
printf("!%u ", priority); printf("!%u ", priority);
printf("[%i%s]", len, (msg.msg_flags & MSG_TRUNC) ? "..." : ""); printf("[%i%s]", len, (msg.msg_flags & MSG_TRUNC) ? "..." : "");
for (j = 0; j < len; ) { for (j = 0; j < len;) {
unsigned int end = j + 4; unsigned int end = j + 4;
if (end > len) if (end > len)
end = len; end = len;
@ -302,4 +293,3 @@ int main(int argc, char **argv)
free(buf); free(buf);
return 0; return 0;
} }