commit
f8a2cf01fa
21
canfdtest.c
21
canfdtest.c
|
|
@ -58,11 +58,11 @@ static void print_usage(char *prg)
|
||||||
"Usage: %s [options] <can-interface>\n"
|
"Usage: %s [options] <can-interface>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -v (low verbosity)\n"
|
" -f COUNT (number of frames in flight, default: %d)\n"
|
||||||
" -vv (high verbosity)\n"
|
|
||||||
" -g (generate messages)\n"
|
" -g (generate messages)\n"
|
||||||
" -l COUNT (test loop count)\n"
|
" -l COUNT (test loop count)\n"
|
||||||
" -f COUNT (number of frames in flight, default: %d)\n"
|
" -v (low verbosity)\n"
|
||||||
|
" -vv (high verbosity)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"With the option '-g' CAN messages are generated and checked\n"
|
"With the option '-g' CAN messages are generated and checked\n"
|
||||||
"on <can-interface>, otherwise all messages received on the\n"
|
"on <can-interface>, otherwise all messages received on the\n"
|
||||||
|
|
@ -376,21 +376,22 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "f:gl:v?")) != -1) {
|
while ((opt = getopt(argc, argv, "f:gl:v?")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'v':
|
|
||||||
verbose++;
|
|
||||||
break;
|
|
||||||
case 'f':
|
case 'f':
|
||||||
inflight_count = atoi(optarg);
|
inflight_count = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
|
||||||
test_loops = atoi(optarg);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'g':
|
case 'g':
|
||||||
echo_gen = 1;
|
echo_gen = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
test_loops = atoi(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'v':
|
||||||
|
verbose++;
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
print_usage(basename(argv[0]));
|
print_usage(basename(argv[0]));
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,18 @@ void print_usage(char *prg)
|
||||||
fprintf(stderr, " -d (only detach line discipline)\n");
|
fprintf(stderr, " -d (only detach line discipline)\n");
|
||||||
fprintf(stderr, " -w (attach - wait for keypess - detach)\n");
|
fprintf(stderr, " -w (attach - wait for keypess - detach)\n");
|
||||||
fprintf(stderr, " -n <name> (assign created netdevice name)\n");
|
fprintf(stderr, " -n <name> (assign created netdevice name)\n");
|
||||||
|
fprintf(stderr, "\n"
|
||||||
|
" <speed> Bitrate\n"
|
||||||
|
" 0 10 Kbit/s\n"
|
||||||
|
" 1 20 Kbit/s\n"
|
||||||
|
" 2 50 Kbit/s\n"
|
||||||
|
" 3 100 Kbit/s\n"
|
||||||
|
" 4 125 Kbit/s\n"
|
||||||
|
" 5 250 Kbit/s\n"
|
||||||
|
" 6 500 Kbit/s\n"
|
||||||
|
" 7 800 Kbit/s\n"
|
||||||
|
" 8 1000 Kbit/s\n"
|
||||||
|
"\n");
|
||||||
fprintf(stderr, "\nExamples:\n");
|
fprintf(stderr, "\nExamples:\n");
|
||||||
fprintf(stderr, "slcan_attach -w -o -f -s6 -c /dev/ttyS1\n\n");
|
fprintf(stderr, "slcan_attach -w -o -f -s6 -c /dev/ttyS1\n\n");
|
||||||
fprintf(stderr, "slcan_attach /dev/ttyS1\n\n");
|
fprintf(stderr, "slcan_attach /dev/ttyS1\n\n");
|
||||||
|
|
@ -213,7 +225,7 @@ int main(int argc, char **argv)
|
||||||
/* try to rename the created device if requested */
|
/* try to rename the created device if requested */
|
||||||
if (name) {
|
if (name) {
|
||||||
int s = socket(PF_INET, SOCK_DGRAM, 0);
|
int s = socket(PF_INET, SOCK_DGRAM, 0);
|
||||||
|
|
||||||
printf("rename netdevice %s to %s ... ", buf, name);
|
printf("rename netdevice %s to %s ... ", buf, name);
|
||||||
|
|
||||||
if (s < 0)
|
if (s < 0)
|
||||||
|
|
@ -222,12 +234,12 @@ int main(int argc, char **argv)
|
||||||
/* current slcan%d name is still in ifr.ifr_name */
|
/* current slcan%d name is still in ifr.ifr_name */
|
||||||
memset (ifr.ifr_newname, 0, sizeof(ifr.ifr_newname));
|
memset (ifr.ifr_newname, 0, sizeof(ifr.ifr_newname));
|
||||||
strncpy (ifr.ifr_newname, name, sizeof(ifr.ifr_newname) - 1);
|
strncpy (ifr.ifr_newname, name, sizeof(ifr.ifr_newname) - 1);
|
||||||
|
|
||||||
if (ioctl(s, SIOCSIFNAME, &ifr) < 0)
|
if (ioctl(s, SIOCSIFNAME, &ifr) < 0)
|
||||||
printf("failed!\n");
|
printf("failed!\n");
|
||||||
else
|
else
|
||||||
printf("ok.\n");
|
printf("ok.\n");
|
||||||
|
|
||||||
close(s);
|
close(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue