mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-05 06:20:00 +02:00
candump: print correct interface names on stderr
The cmdlinename[i] output contains the filter definitions e.g. 'can0,300:700' but you want to see only 'can0' when printing on stderr. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
@@ -648,9 +648,11 @@ int main(int argc, char **argv)
|
|||||||
msg.msg_flags = 0;
|
msg.msg_flags = 0;
|
||||||
|
|
||||||
nbytes = recvmsg(s[i], &msg, 0);
|
nbytes = recvmsg(s[i], &msg, 0);
|
||||||
|
idx = idx2dindex(addr.can_ifindex, s[i]);
|
||||||
|
|
||||||
if (nbytes < 0) {
|
if (nbytes < 0) {
|
||||||
if ((errno == ENETDOWN) && !down_causes_exit) {
|
if ((errno == ENETDOWN) && !down_causes_exit) {
|
||||||
fprintf(stderr, "read: %s \t\t(not exiting because of -D flag)\n", strerror(errno));
|
fprintf(stderr, "%s: interface down\n", devname[idx]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
perror("read");
|
perror("read");
|
||||||
@@ -699,17 +701,15 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (silent != SILENT_ON)
|
if (silent != SILENT_ON)
|
||||||
printf("DROPCOUNT: dropped %d CAN frame%s on '%s' socket (total drops %d)\n",
|
printf("DROPCOUNT: dropped %d CAN frame%s on '%s' socket (total drops %d)\n",
|
||||||
frames, (frames > 1)?"s":"", cmdlinename[i], dropcnt[i]);
|
frames, (frames > 1)?"s":"", devname[idx], dropcnt[i]);
|
||||||
|
|
||||||
if (log)
|
if (log)
|
||||||
fprintf(logfile, "DROPCOUNT: dropped %d CAN frame%s on '%s' socket (total drops %d)\n",
|
fprintf(logfile, "DROPCOUNT: dropped %d CAN frame%s on '%s' socket (total drops %d)\n",
|
||||||
frames, (frames > 1)?"s":"", cmdlinename[i], dropcnt[i]);
|
frames, (frames > 1)?"s":"", devname[idx], dropcnt[i]);
|
||||||
|
|
||||||
last_dropcnt[i] = dropcnt[i];
|
last_dropcnt[i] = dropcnt[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = idx2dindex(addr.can_ifindex, s[i]);
|
|
||||||
|
|
||||||
/* once we detected a EFF frame indent SFF frames accordingly */
|
/* once we detected a EFF frame indent SFF frames accordingly */
|
||||||
if (frame.can_id & CAN_EFF_FLAG)
|
if (frame.can_id & CAN_EFF_FLAG)
|
||||||
view |= CANLIB_VIEW_INDENT_SFF;
|
view |= CANLIB_VIEW_INDENT_SFF;
|
||||||
|
|||||||
Reference in New Issue
Block a user