mirror of
https://github.com/linux-can/can-utils.git
synced 2026-09-20 23:12:09 +02:00
isotpsniffer: option for no quitting on invalid message received
This commit is contained in:
+19
-7
@@ -79,6 +79,7 @@ void print_usage(char *prg)
|
|||||||
fprintf(stderr, " -f <format> (1 = HEX, 2 = ASCII, 3 = HEX & ASCII - default: %d)\n", FORMAT_DEFAULT);
|
fprintf(stderr, " -f <format> (1 = HEX, 2 = ASCII, 3 = HEX & ASCII - default: %d)\n", FORMAT_DEFAULT);
|
||||||
fprintf(stderr, " -L (set link layer options for CAN FD)\n");
|
fprintf(stderr, " -L (set link layer options for CAN FD)\n");
|
||||||
fprintf(stderr, " -h <len> (head: print only first <len> bytes)\n");
|
fprintf(stderr, " -h <len> (head: print only first <len> bytes)\n");
|
||||||
|
fprintf(stderr, " -q (don't quit on read error, allows to receive malformed frames)\n");
|
||||||
fprintf(stderr, "\nCAN IDs and addresses are given and expected in hexadecimal values.\n");
|
fprintf(stderr, "\nCAN IDs and addresses are given and expected in hexadecimal values.\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
@@ -189,6 +190,7 @@ int main(int argc, char **argv)
|
|||||||
int head = 0;
|
int head = 0;
|
||||||
int timestamp = 0;
|
int timestamp = 0;
|
||||||
int format = FORMAT_DEFAULT;
|
int format = FORMAT_DEFAULT;
|
||||||
|
int noquit = 0;
|
||||||
canid_t src = NO_CAN_ID;
|
canid_t src = NO_CAN_ID;
|
||||||
canid_t dst = NO_CAN_ID;
|
canid_t dst = NO_CAN_ID;
|
||||||
extern int optind, opterr, optopt;
|
extern int optind, opterr, optopt;
|
||||||
@@ -197,7 +199,7 @@ int main(int argc, char **argv)
|
|||||||
unsigned char buffer[4096];
|
unsigned char buffer[4096];
|
||||||
int nbytes;
|
int nbytes;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "s:d:x:X:h:ct:f:L?")) != -1) {
|
while ((opt = getopt(argc, argv, "s:d:x:X:h:ct:f:L?q")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 's':
|
case 's':
|
||||||
src = strtoul(optarg, NULL, 16);
|
src = strtoul(optarg, NULL, 16);
|
||||||
@@ -249,6 +251,10 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'q':
|
||||||
|
noquit = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
print_usage(basename(argv[0]));
|
print_usage(basename(argv[0]));
|
||||||
goto out;
|
goto out;
|
||||||
@@ -371,14 +377,17 @@ int main(int argc, char **argv)
|
|||||||
if (nbytes < 0) {
|
if (nbytes < 0) {
|
||||||
perror("read socket s");
|
perror("read socket s");
|
||||||
r = 1;
|
r = 1;
|
||||||
goto out;
|
if(!noquit)
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
if (nbytes > 4095) {
|
if (nbytes > 4095) {
|
||||||
r = 1;
|
r = 1;
|
||||||
|
perror("read socket s too much data");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
printbuf(buffer, nbytes, color?2:0, timestamp, format,
|
if(nbytes > 0)
|
||||||
&tv, &last_tv, dst, s, if_name, head);
|
printbuf(buffer, nbytes, color?2:0, timestamp, format,
|
||||||
|
&tv, &last_tv, dst, s, if_name, head);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(t, &rdfs)) {
|
if (FD_ISSET(t, &rdfs)) {
|
||||||
@@ -386,14 +395,17 @@ int main(int argc, char **argv)
|
|||||||
if (nbytes < 0) {
|
if (nbytes < 0) {
|
||||||
perror("read socket t");
|
perror("read socket t");
|
||||||
r = 1;
|
r = 1;
|
||||||
goto out;
|
if(!noquit)
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
if (nbytes > 4095) {
|
if (nbytes > 4095) {
|
||||||
r = 1;
|
r = 1;
|
||||||
|
perror("read socket t too much data");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
printbuf(buffer, nbytes, color?1:0, timestamp, format,
|
if(nbytes > 0)
|
||||||
&tv, &last_tv, src, t, if_name, head);
|
printbuf(buffer, nbytes, color?1:0, timestamp, format,
|
||||||
|
&tv, &last_tv, src, t, if_name, head);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user