In the case of pending bus errors on some slcan adapters the read of the
status flags resets the adapter and clears the error LED.
This patch adds the commandline option to send the status read command to the
adapter as suggested by Thorsten Godau.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
fprintf(stderr, "\nUsage: %s [options] tty\n\n", prg);
fprintf(stderr, "Options: -o (send open command 'O\\r')\n");
fprintf(stderr, " -c (send close command 'C\\r')\n");
fprintf(stderr, "\nUsage: %s [options] tty\n\n", prg);
fprintf(stderr, "Options: -o (send open command 'O\\r')\n");
fprintf(stderr, " -c (send close command 'C\\r')\n");
+ fprintf(stderr, " -f (read status flags with 'F\\r' to reset error states)\n");
fprintf(stderr, " -s <speed> (set CAN speed 0..8)\n");
fprintf(stderr, " -b <btr> (set bit time register value)\n");
fprintf(stderr, " -d (only detach line discipline)\n");
fprintf(stderr, " -w (attach - wait for keypess - detach)\n");
fprintf(stderr, " -n <name> (assign created netdevice name)\n");
fprintf(stderr, "\nExamples:\n");
fprintf(stderr, " -s <speed> (set CAN speed 0..8)\n");
fprintf(stderr, " -b <btr> (set bit time register value)\n");
fprintf(stderr, " -d (only detach line discipline)\n");
fprintf(stderr, " -w (attach - wait for keypess - detach)\n");
fprintf(stderr, " -n <name> (assign created netdevice name)\n");
fprintf(stderr, "\nExamples:\n");
- fprintf(stderr, "slcan_attach -w -o -s6 -c /dev/ttyS1\n");
+ fprintf(stderr, "slcan_attach -w -o -f -s6 -c /dev/ttyS1\n");
fprintf(stderr, "slcan_attach /dev/ttyS1\n");
fprintf(stderr, "slcan_attach -d /dev/ttyS1\n");
fprintf(stderr, "slcan_attach -w -n can15 /dev/ttyS1\n");
fprintf(stderr, "slcan_attach /dev/ttyS1\n");
fprintf(stderr, "slcan_attach -d /dev/ttyS1\n");
fprintf(stderr, "slcan_attach -w -n can15 /dev/ttyS1\n");
int waitkey = 0;
int send_open = 0;
int send_close = 0;
int waitkey = 0;
int send_open = 0;
int send_close = 0;
+ int send_read_status_flags = 0;
char *speed = NULL;
char *btr = NULL;
char buf[IFNAMSIZ+1];
char *speed = NULL;
char *btr = NULL;
char buf[IFNAMSIZ+1];
char *name = NULL;
int opt;
char *name = NULL;
int opt;
- while ((opt = getopt(argc, argv, "l:dwocs:b:n:?")) != -1) {
+ while ((opt = getopt(argc, argv, "l:dwocfs:b:n:?")) != -1) {
switch (opt) {
case 'l':
fprintf(stderr, "Ignored option '-l'\n");
switch (opt) {
case 'l':
fprintf(stderr, "Ignored option '-l'\n");
+ case 'f':
+ send_read_status_flags = 1;
+ break;
+
case 's':
speed = optarg;
if (strlen(speed) > 1)
case 's':
speed = optarg;
if (strlen(speed) > 1)
write(fd, buf, strlen(buf));
}
write(fd, buf, strlen(buf));
}
+ if (send_read_status_flags) {
+ sprintf(buf, "F\r");
+ write(fd, buf, strlen(buf));
+ }
+
if (send_open) {
sprintf(buf, "O\r");
write(fd, buf, strlen(buf));
if (send_open) {
sprintf(buf, "O\r");
write(fd, buf, strlen(buf));